CSLA.NET
6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
PermissionsRoot.cs
Go to the documentation of this file.
1
//-----------------------------------------------------------------------
2
// <copyright file="PermissionsRoot.cs" company="Marimer LLC">
3
// Copyright (c) Marimer LLC. All rights reserved.
4
// Website: https://cslanet.com
5
// </copyright>
6
// <summary>no summary</summary>
7
//-----------------------------------------------------------------------
8
using
System;
9
using
System.Collections.Generic;
10
using
System.Text;
11
using
Csla
.
Core
;
12
using
Csla
.
Rules
;
13
using
Csla
.
Rules
.
CommonRules
;
14
using
Csla
.
Serialization
;
15
using
Csla
.
DataPortalClient
;
16
using
System.Diagnostics;
17
18
namespace
Csla.Test.Security
19
{
20
#if TESTING
21
[DebuggerNonUserCode]
22
#endif
23
[
Serializable
()]
24
public
class
PermissionsRoot
:
BusinessBase
<PermissionsRoot>
25
{
26
private
int
_ID = 0;
27
protected
override
object
GetIdValue
()
28
{
29
return
_ID;
30
}
31
32
public
static
PropertyInfo<string>
FirstNameProperty
= RegisterProperty<string>(c => c.FirstName,
RelationshipTypes
.PrivateField);
33
private
string
_firstName =
FirstNameProperty
.DefaultValue;
34
public
string
FirstName
35
{
36
get
37
{
38
if
(CanReadProperty(
"FirstName"
))
39
{
40
return
_firstName;
41
}
42
else
43
{
44
throw
new
Csla
.
Security
.
SecurityException
(
"Property get not allowed"
);
45
}
46
}
47
set
48
{
49
if
(CanWriteProperty(
"FirstName"
))
50
{
51
_firstName = value;
52
}
53
else
54
{
55
throw
new
Csla
.
Security
.
SecurityException
(
"Property set not allowed"
);
56
}
57
}
58
}
59
60
public
readonly
static
Csla
.
Core
.
IMemberInfo
DoWorkMethod
=
RegisterMethod
(typeof(
PermissionsRoot
),
"DoWork"
);
61
62
public
void
DoWork
()
63
{
64
CanExecuteMethod(
DoWorkMethod
,
true
);
65
}
66
67
#region Authorization
68
69
70
public
static
void
AddObjectAuthorizationRules
()
71
{
72
// add rules for default ruleset
73
BusinessRules
.
AddRule
(typeof(
PermissionsRoot
),
new
IsInRole
(
AuthorizationActions
.DeleteObject,
"User"
),
ApplicationContext
.
DefaultRuleSet
);
74
BusinessRules
.
AddRule
(typeof(
PermissionsRoot
),
new
IsInRole
(
AuthorizationActions
.DeleteObject,
"Admin"
),
"custom1"
);
75
BusinessRules
.
AddRule
(typeof(
PermissionsRoot
),
new
IsInRole
(
AuthorizationActions
.DeleteObject,
"User"
,
"Admin"
),
"custom2"
);
76
}
77
78
protected
override
void
AddBusinessRules
()
79
{
80
BusinessRules
.
AddRule
(
new
IsInRole
(Rules.AuthorizationActions.ReadProperty,
FirstNameProperty
,
new
List<string> {
"Admin"
}));
81
BusinessRules
.
AddRule
(
new
IsInRole
(Rules.AuthorizationActions.WriteProperty,
FirstNameProperty
,
new
List<string> {
"Admin"
}));
82
BusinessRules
.
AddRule
(
new
IsInRole
(Rules.AuthorizationActions.ExecuteMethod,
DoWorkMethod
,
new
List<string> {
"Admin"
}));
83
}
84
85
#endregion
86
87
#region "Criteria"
88
89
[
Serializable
()]
90
private
class
Criteria
91
{
92
//implement
93
}
94
95
#endregion
96
97
[RunLocal()]
98
[
Create
]
99
protected
void
DataPortal_Create
()
100
{
101
_firstName =
"default value"
;
//for now...
102
}
103
}
104
}
Csla.ApplicationContext
Provides consistent context information between the client and server DataPortal objects.
Definition:
ApplicationContext.cs:22
Csla.ApplicationContext.DefaultRuleSet
const string DefaultRuleSet
The default RuleSet name
Definition:
ApplicationContext.cs:268
Csla.BusinessBase
This is the base class from which most business objects will be derived.
Definition:
BusinessBase.cs:38
Csla.BusinessBase< PermissionsRoot >::RegisterMethod
static MethodInfo RegisterMethod(string methodName)
Registers a method for use in Authorization.
Definition:
BusinessBase.cs:524
Csla.PropertyInfo
Maintains metadata about a property.
Definition:
Csla/PropertyInfo.cs:22
Csla.Rules.BusinessRules
Tracks the business rules for a business object.
Definition:
BusinessRules.cs:26
Csla.Rules.BusinessRules.AddRule
void AddRule(IBusinessRuleBase rule)
Associates a business rule with the business object.
Definition:
BusinessRules.cs:174
Csla.Rules.CommonRules.IsInRole
IsInRole authorization rule.
Definition:
AuthorizationRules.cs:19
Csla.Security.SecurityException
Security exception.
Definition:
SecurityException.cs:17
Csla.Test.Security.PermissionsRoot
Definition:
PermissionsRoot.cs:25
Csla.Test.Security.PermissionsRoot.DataPortal_Create
void DataPortal_Create()
Definition:
PermissionsRoot.cs:99
Csla.Test.Security.PermissionsRoot.DoWork
void DoWork()
Definition:
PermissionsRoot.cs:62
Csla.Test.Security.PermissionsRoot.FirstNameProperty
static PropertyInfo< string > FirstNameProperty
Definition:
PermissionsRoot.cs:32
Csla.Test.Security.PermissionsRoot.AddObjectAuthorizationRules
static void AddObjectAuthorizationRules()
Definition:
PermissionsRoot.cs:70
Csla.Test.Security.PermissionsRoot.AddBusinessRules
override void AddBusinessRules()
Definition:
PermissionsRoot.cs:78
Csla.Test.Security.PermissionsRoot.FirstName
string FirstName
Definition:
PermissionsRoot.cs:35
Csla.Test.Security.PermissionsRoot.DoWorkMethod
static readonly Csla.Core.IMemberInfo DoWorkMethod
Definition:
PermissionsRoot.cs:60
Csla.Test.Security.PermissionsRoot.GetIdValue
override object GetIdValue()
Override this method to return a unique identifying value for this object.
Definition:
PermissionsRoot.cs:27
Csla.Core.IMemberInfo
Maintains metadata about a method or property.
Definition:
IMemberInfo.cs:19
Csla.Core
Definition:
AddedNewEventArgs.cs:11
Csla.DataPortalClient
Definition:
Csla/DataPortalClient/DataPortalFactory.cs:11
Csla.Rules.CommonRules
Definition:
AuthorizationRules.cs:14
Csla.Rules
Definition:
AddObjectAuthorizationRulesContext.cs:11
Csla.Rules.AuthorizationActions
AuthorizationActions
Authorization actions.
Definition:
AuthorizationActions.cs:19
Csla.Security
Definition:
CslaClaimsPrincipal.cs:15
Csla.Serialization
Definition:
AutoNonSerializedAttribute.cs:11
Csla.Test.Security
Definition:
PermissionsRoot.cs:19
Csla
Definition:
BusinessRuleCases.cs:5
Csla.RelationshipTypes
RelationshipTypes
List of valid relationship types between a parent object and another object through a managed propert...
Definition:
RelationshipTypes.cs:19
Csla.TransactionIsolationLevel.Serializable
@ Serializable
Prevents updating or inserting until the transaction is complete.
Csla.DataPortalOperations.Create
@ Create
Create operation.
Generated by
1.9.2