Class PermissionService
- Namespace
- Dynamicweb.Security.Permissions
- Assembly
- Dynamicweb.Core.dll
Handles fetching, adding, updating and removing permissions in the system.
public sealed class PermissionService : ICacheStorage<string, ConcurrentDictionary<PermissionEntityIdentifier, Permission>>, ICacheStorage<string>, ICacheStorage
- Inheritance
-
PermissionService
- Implements
- Inherited Members
Methods
ClearCache()
Clears the cache for all permissions.
public void ClearCache()
ClearCacheByOwnerId(string)
Clears the cache for specified permission owner id.
public void ClearCacheByOwnerId(string ownerId)
Parameters
ownerId
stringId of the permission owner
GetExplicitPermissionInfos(IPermissionEntity)
Gets permission info for all explicit permissions for the specified entity.
public IEnumerable<PermissionInfo> GetExplicitPermissionInfos(IPermissionEntity entity)
Parameters
entity
IPermissionEntityPermission entity
Returns
- IEnumerable<PermissionInfo>
Permission infos
GetExplicitPermissionInfos(PermissionEntityIdentifier)
Gets permission info for all explicit permissions matching the identifier.
public IEnumerable<PermissionInfo> GetExplicitPermissionInfos(PermissionEntityIdentifier identifier)
Parameters
identifier
PermissionEntityIdentifierPermission entity identifier
Returns
- IEnumerable<PermissionInfo>
Permission infos
GetInheritedPermissionInfos(IPermissionEntity)
Gets permission info for all permissions inherited from parent entities for the specified entity.
public IEnumerable<PermissionInfo> GetInheritedPermissionInfos(IPermissionEntity entity)
Parameters
entity
IPermissionEntityPermission entity
Returns
- IEnumerable<PermissionInfo>
Permission infos
GetInheritedPermissionInfos(PermissionEntityIdentifier)
Gets permission info for all inherited permissions matching the identifier.
public IEnumerable<PermissionInfo> GetInheritedPermissionInfos(PermissionEntityIdentifier identifier)
Parameters
identifier
PermissionEntityIdentifierPermission entity identifier
Returns
- IEnumerable<PermissionInfo>
Permission infos
GetPermission(string, PermissionEntityIdentifier)
Gets a permission for the specified owner and entity identifier.
public Permission? GetPermission(string ownerId, PermissionEntityIdentifier identifier)
Parameters
ownerId
stringPermission owner id
identifier
PermissionEntityIdentifierPermission entity identifier
Returns
- Permission
Permission, if found; otherwise,
null
GetPermissionInfos(PermissionEntityIdentifier)
Gets permission info for all permissions matching the identifier (explicit, inherited and default permissions).
public IEnumerable<PermissionInfo> GetPermissionInfos(PermissionEntityIdentifier identifier)
Parameters
identifier
PermissionEntityIdentifierPermission entity identifier
Returns
- IEnumerable<PermissionInfo>
Permission infos
GetPermissionsByName(string, string)
Gets all permissions matching the specified name for a given permission owner.
public IEnumerable<Permission> GetPermissionsByName(string ownerId, string name)
Parameters
Returns
- IEnumerable<Permission>
All permissions matching the owner and name.
GetPermissionsByName(string, string, string?)
Gets all permissions matching the specified name and subName for a given permission owner.
public IEnumerable<Permission> GetPermissionsByName(string ownerId, string name, string? subName)
Parameters
ownerId
stringPermission owner identifier
name
stringPermission name
subName
stringPermission subname
Returns
- IEnumerable<Permission>
All permissions matching the owner, name and subname.
GetPermissionsByQuery(PermissionQuery)
Gets all permissions matching the specified query.
public IEnumerable<Permission> GetPermissionsByQuery(PermissionQuery query)
Parameters
query
PermissionQueryPermission query
Returns
- IEnumerable<Permission>
Permissions matching the specified query.
RemovePermission(Permission)
Removes a given permission.
public void RemovePermission(Permission permission)
Parameters
permission
PermissionPermission to remove
RemovePermission(string, PermissionEntityIdentifier)
Removes all permissions for the specified owner and identifier.
public void RemovePermission(string ownerId, PermissionEntityIdentifier identifier)
Parameters
ownerId
stringIdentifier of owner
identifier
PermissionEntityIdentifierIdentifier of entity
RemovePermissionsByQuery(PermissionQuery)
Removes all permissions for the specified query.
public void RemovePermissionsByQuery(PermissionQuery query)
Parameters
query
PermissionQueryTarget of permission
SetPermission(Permission)
Sets a given permission.
public void SetPermission(Permission permission)
Parameters
permission
PermissionPermission to set
SetPermission(string, PermissionEntityIdentifier, PermissionLevel)
Sets permission level for the specified owner and identifier.
public void SetPermission(string ownerId, PermissionEntityIdentifier identifier, PermissionLevel level)
Parameters
ownerId
stringIdentifier of owner
identifier
PermissionEntityIdentifierIdentifier of entity
level
PermissionLevelPermission level
SetPermissionsByQuery(PermissionQuery, PermissionLevel)
Removes all permissions for the specified query.
public void SetPermissionsByQuery(PermissionQuery query, PermissionLevel level)
Parameters
query
PermissionQueryTarget of permission
level
PermissionLevel
TryGetPermission(string, PermissionEntityIdentifier, out Permission?)
Tries to get a permission for the specified owner and entity identifier.
public bool TryGetPermission(string ownerId, PermissionEntityIdentifier identifier, out Permission? permission)
Parameters
ownerId
stringPermission owner id
identifier
PermissionEntityIdentifierPermission entity identifier
permission
PermissionPermission
Returns
- bool
true
, if permission was found; otherwise,false