Class AppPrincipal
AppPrincipal is the principal which knows all the information on a person (authorization, authentication and profile information). We use a principal because it is copied from thrad to thead (new in .Net 2.0).
public class AppPrincipal : ClaimsPrincipal, IPrincipal, IAuthorization
- Inheritance
-
AppPrincipal
- Implements
- Inherited Members
Constructors
AppPrincipal(Authorization, IIdentity, string)
Initializes a new instance of the AppPrincipal class.
public AppPrincipal(Authorization authorizationData, IIdentity identity, string sid)
Parameters
authorizationDataAuthorizationThe authorization data.
identityIIdentityThe identity.
sidstringThe sid.
Properties
Profile
Gets or sets the profile.
public UserProfile Profile { get; set; }
Property Value
- UserProfile
The profile.
Sid
public string Sid { get; }
Property Value
Methods
IsAuthorized(string)
Determines whether the specified operation is authorized in the default (empty) scope.
public bool IsAuthorized(string operation)
Parameters
operationstringThe operation name.
Returns
- bool
trueif the specified operation is authorized; otherwise,false.
Remarks
This overload exists so that IsAuthorized("Name") compiles: without it, a single string argument
matches both IsAuthorized(string, params int[]) and IsAuthorized(string, params string[])
with an empty operations array, which is ambiguous.
IsAuthorized<TAccess>(params TAccess[])
Determines whether all the specified operations, expressed with an enumeration, are authorized in the empty scope. The numeric value of each enumeration member is the operation identifier.
public bool IsAuthorized<TAccess>(params TAccess[] operations) where TAccess : struct, Enum
Parameters
operationsTAccess[]The operations.
Returns
Type Parameters
TAccessThe enumeration type whose members identify the operations.
Examples
public enum Access { Read = 1, Write = 2 }
if (principal.IsAuthorized(Access.Read, Access.Write))
{
// The user can read and write.
}