InMemoryPermitManager<TId>

Namespace: ASPSecurityKit
Assembly: ASPSecurityKit.dll

Summary

Implements a memory-based IPermitManager<TId> without any optimization for external caching.

Generic Types
Name Description
TId Type of key identifier used in the application.

Constructors

#ctor(sessionService)

Summary

Initializes a new instance of the InMemoryPermitManager<TId> class.

Parameters
Name Type Description
sessionService ASPSecurityKit.ISessionService The session service.

Properties

SessionService

Summary

Gets the session service.

Value

The session service.

PermissionsMap

Summary

Gets or sets the permissions map.

Value

The permissions map.

Exceptions
Type Description
System.InvalidOperationException When permits key is missing in the session store.

Initialized

Summary

Gets a value indicating whether this instance is initialized.

Value

true if this instance is initialized; otherwise, false.

Remarks

Most operations are only available once the instance is initialized using Initialize. An exception could be thrown otherwise. Use this property to determine the initialization status safely.

Methods

Initialize(permits)

Summary

Initializes this instance with specified permits.

Parameters
Name Type Description
permits System.Collections.Generic.IEnumerable<IPermit<TId>> The permits.
Exceptions
Type Description
System.ArgumentNullException When permits is null.
Remarks

Every call to this method will completely override existing permits collection it holds.

Add(permit)

Summary

Adds the specified permit to the collection this instance holds.

Parameters
Name Type Description
permit ASPSecurityKit.IPermit<TId> The permit to add.
Exceptions
Type Description
System.ArgumentNullException When permit is null.

Contains(permitHash)

Summary

Determines whether this instance contains the specified permit.

Returns

true if this instance contains the specified permit; otherwise, false.

Parameters
Name Type Description
permitHash System.String The permit hash.
Exceptions
Type Description
System.ArgumentNullException When permitHash is null/whitespace.

Possesses(permissionCode)

Summary

Determines whether this instance contains any permit having the specified permissionCode.

Returns

true if this instance contains some permit having the specified permissionCode; otherwise, false.

Parameters
Name Type Description
permissionCode System.String The permission code.
Exceptions
Type Description
System.ArgumentNullException When permissionCode is null/whitespace.

GetEntityIds(permissionCode)

Summary

Gets all the entity ids associated with the specified permissionCode across the entire permits collection this instance holds.

Returns

All the entity ids associated with the specified permissionCode across the entire permits collection this instance holds.

Parameters
Name Type Description
permissionCode System.String The permission code.
Exceptions
Type Description
System.ArgumentNullException When permissionCode is null/whitespace.

GetPermits()

Summary

Gets the entire permits collection this instance holds.

Returns

The entire permits collection this instance holds.

Parameters

This method has no parameters.

CreatePermitHash(permissionCode,entityId)

Summary

Creates a unique hash for the specified permissionCode and entityId.

Returns

A unique hash for the specified permissionCode and entityId.

Parameters
Name Type Description
permissionCode System.String The permission code.
entityId System.String The entity identifier.
Exceptions
Type Description
System.ArgumentNullException When permissionCode is null/whitespace.

CreatePermitHash(permissionCode,entityId)

Summary

Creates a unique hash for the specified permissionCode and entityId.

Returns

A unique hash for the specified permissionCode and entityId.

Parameters
Name Type Description
permissionCode System.String The permission code.
entityId System.Nullable<TId> The entity identifier.
Exceptions
Type Description
System.ArgumentNullException When permissionCode is null/whitespace.

GetStorageData()

Summary

Gets the data this instance holds in a raw format (to persist in external cache, for instance).

Returns

The data this instance holds in a raw format.

Parameters

This method has no parameters.

SetStorageData(data)

Summary

Re-initializes this instance with the specified raw data (previously obtained via GetStorageData).

Parameters
Name Type Description
data System.Object The raw data.

Clear()

Summary

Clears the data this instance holds.

Parameters

This method has no parameters.

Add(permits,permit)

Summary

Adds the given permit to the specified permits collection only if it isn’t already added.

Parameters
Name Type Description
permits System.Collections.Generic.Dictionary<String, IPermit<TId>> The permits collection into which permit is to be added.
permit ASPSecurityKit.IPermit<TId> The permit to add.
Exceptions
Type Description
System.ArgumentNullException When permits is null or permit.PermissionCode is null/whitespace.