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
ownerIdstringId of the permission owner
GetExplicitPermissionInfos(IPermissionEntity)
Gets permission info for all explicit permissions for the specified entity.
public IEnumerable<PermissionInfo> GetExplicitPermissionInfos(IPermissionEntity entity)
Parameters
entityIPermissionEntityPermission 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
identifierPermissionEntityIdentifierPermission 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
entityIPermissionEntityPermission 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
identifierPermissionEntityIdentifierPermission 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
ownerIdstringPermission owner id
identifierPermissionEntityIdentifierPermission 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
identifierPermissionEntityIdentifierPermission 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
ownerIdstringPermission owner identifier
namestringPermission name
subNamestringPermission 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
queryPermissionQueryPermission query
Returns
- IEnumerable<Permission>
Permissions matching the specified query.
RemovePermission(Permission)
Removes a given permission.
public void RemovePermission(Permission permission)
Parameters
permissionPermissionPermission to remove
RemovePermission(string, PermissionEntityIdentifier)
Removes all permissions for the specified owner and identifier.
public void RemovePermission(string ownerId, PermissionEntityIdentifier identifier)
Parameters
ownerIdstringIdentifier of owner
identifierPermissionEntityIdentifierIdentifier of entity
RemovePermissionsByQuery(PermissionQuery)
Removes all permissions for the specified query.
public void RemovePermissionsByQuery(PermissionQuery query)
Parameters
queryPermissionQueryTarget of permission
SetPermission(Permission)
Sets a given permission.
public void SetPermission(Permission permission)
Parameters
permissionPermissionPermission 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
ownerIdstringIdentifier of owner
identifierPermissionEntityIdentifierIdentifier of entity
levelPermissionLevelPermission level
SetPermissionsByQuery(PermissionQuery, PermissionLevel)
Removes all permissions for the specified query.
public void SetPermissionsByQuery(PermissionQuery query, PermissionLevel level)
Parameters
queryPermissionQueryTarget of permission
levelPermissionLevel
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
ownerIdstringPermission owner id
identifierPermissionEntityIdentifierPermission entity identifier
permissionPermissionPermission
Returns
- bool
true, if permission was found; otherwise,false