Table of Contents

Class AppAuthorization

Namespace
Arc4u.Security.Principal
Assembly
Arc4u.dll

The default IAuthorization implementation, built from an Authorization data object. Roles and operations are grouped by scope; the methods without a scope parameter use the empty scope (Empty).

public class AppAuthorization : IAuthorization
Inheritance
AppAuthorization
Implements
Inherited Members

Constructors

AppAuthorization(Authorization)

Initializes a new instance of the AppAuthorization class and indexes the roles and operations of the authorization data for fast look-up.

public AppAuthorization(Authorization authorizationData)

Parameters

authorizationData Authorization

The authorization data (scopes, roles and operations) of the user.

Exceptions

ConfigurationException

An entry of Operations or Roles has no scope; the default scope is the empty string.

Properties

AuthorizationType

Gets the type of the authorization.

public string AuthorizationType { get; }

Property Value

string

The type of the authorization.

Methods

IsAuthorized(params int[])

Determines whether the specified operations are authorized.

public bool IsAuthorized(params int[] operations)

Parameters

operations int[]

The operations.

Returns

bool

true if the specified operations is authorized; otherwise, false.

IsAuthorized(string)

Determines whether the specified operation is authorized in the default (empty) scope.

public bool IsAuthorized(string operation)

Parameters

operation string

The operation name.

Returns

bool

true if 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(string, params int[])

Determines whether the specified operations are authorized in the specified scope.

public bool IsAuthorized(string scope, params int[] operations)

Parameters

scope string

The scope.

operations int[]

The operations.

Returns

bool

true if the specified scope is authorized; otherwise, false.

IsAuthorized(string, params string[])

Determines whether the specified operations are authorized in the specified scope.

public bool IsAuthorized(string scope, params string[] operations)

Parameters

scope string

The scope.

operations string[]

The operations.

Returns

bool

true if the specified scope is authorized; otherwise, false.

IsAuthorized(params string[])

Determines whether the specified operations are authorized.

public bool IsAuthorized(params string[] operations)

Parameters

operations string[]

The operations.

Returns

bool

true if the specified operations is authorized; otherwise, false.

IsAuthorized<TAccess>(string, params TAccess[])

Determines whether all the specified operations, expressed with an enumeration, are authorized in the specified scope. The numeric value of each enumeration member is the operation identifier.

public bool IsAuthorized<TAccess>(string scope, params TAccess[] operations) where TAccess : struct, Enum

Parameters

scope string

The scope.

operations TAccess[]

The operations.

Returns

bool

true if all the operations are authorized in the scope; otherwise false.

Type Parameters

TAccess

The enumeration type whose members identify the operations.

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

operations TAccess[]

The operations.

Returns

bool

true if all the operations are authorized; otherwise false.

Type Parameters

TAccess

The enumeration type whose members identify the operations.

IsInRole(string)

Determines whether the user is defined in the specified role.

public bool IsInRole(string role)

Parameters

role string

The role.

Returns

bool

true if [is in role] [the specified role]; otherwise, false.

IsInRole(string, string)

/// Determines whether the user is defined in the specified role for the specific scope.

public bool IsInRole(string scope, string role)

Parameters

scope string

The scope.

role string

The role.

Returns

bool

true if [is in role] [the specified scope]; otherwise, false.

Operations()

Operations defined.

public string[] Operations()

Returns

string[]

Operations(string)

Operations defined in the specified scope.

public string[] Operations(string scope)

Parameters

scope string

The scope.

Returns

string[]

Roles()

Roleses defined.

public string[] Roles()

Returns

string[]

Roles(string)

Roleses defined in the specified scope.

public string[] Roles(string scope)

Parameters

scope string

The scope.

Returns

string[]

Scopes()

Scopeses for roles and operations.

public string[] Scopes()

Returns

string[]