Class PermissionEvaluator
- Namespace
- TimeCockpit.Data.Security
- Assembly
- TimeCockpit.Data.dll
Represents a utility class that evaluates permissions.
public static class PermissionEvaluator
- Inheritance
-
ObjectPermissionEvaluator
- Inherited Members
-
Object.ToString()Object.Equals(Object)Object.Equals(Object, Object)Object.ReferenceEquals(Object, Object)Object.GetHashCode()Object.GetType()Object.MemberwiseClone()
Methods
GetUnsatisfiedEntityCrudPermissions(EntityObject, Environment)
Gets the unsatisfied entity permissions.
public static IEnumerable<Permission> GetUnsatisfiedEntityCrudPermissions(EntityObject entityObject, Environment environment)
Parameters
entityObjectEntityObjectThe entity object.
environmentEnvironmentThe environment.
Returns
- IEnumerable<Permission>
A list of Permissions that are not satisfied in the context of the instance of EntityObject
GetUnsatisfiedFieldPermissions(EntityObject, Environment)
Gets the unsatisfied field permissions of an entity object.
public static Dictionary<string, Permission[]> GetUnsatisfiedFieldPermissions(EntityObject entityObject, Environment environment)
Parameters
entityObjectEntityObjectThe entityobject.
environmentEnvironmentThe environment.
Returns
- Dictionary<String, Permission[]>
Returns a dictionary holding the unsatisfied permissions per property field.
HasEntityPermission(EntityObject, PermissionType)
Check if the permission is valid in the context of the entityObject.
public static bool HasEntityPermission(EntityObject entityObject, PermissionType permissionType)
Parameters
entityObjectEntityObjectEntity object to validate permissions against.
permissionTypePermissionTypePermission type to check.
Returns
- Boolean
True if the permission is valid.
HasMemberPermission(EntityObject, String, PermissionType)
Check if the permission is valid in the context of the entityObject and property.
public static bool HasMemberPermission(EntityObject entityObject, string memberName, PermissionType permissionType)
Parameters
entityObjectEntityObjectEntity object to validate permissions against.
memberNameStringProperty or relation to validate permissions for.
permissionTypePermissionTypePermission type to check.
Returns
- Boolean
True if the permission is valid.
HasModelEntityPermission(IDataContext, ModelEntityBase, PermissionType)
Checks if the permission is valid for a model entity.
public static bool? HasModelEntityPermission(IDataContext dataContext, ModelEntityBase modelEntity, PermissionType permissionType)
Parameters
dataContextIDataContextThe data context to use.
modelEntityModelEntityBaseThe model entity to check.
permissionTypePermissionTypeThe type of the permission.
Returns
- Nullable<Boolean>
True if the permission is valid, false if the permission is not valid and null if the permission cannot be evaluated without specific entity object.
HasPermissionForGivenPermissionTarget(Permission[], PermissionTarget, Environment, PermissionType)
Determines whether any of the permissions with type "permissionIdentifier" evalualtes to true.
public static bool HasPermissionForGivenPermissionTarget(Permission[] permissions, PermissionTarget permissionTarget, Environment environment, PermissionType permissionType)
Parameters
permissionsPermission[]The permissions to check for satisfaction.
permissionTargetPermissionTargetThe permission target.
environmentEnvironmentThe environment.
permissionTypePermissionTypeThe permission identifier.
Returns
- Boolean
trueif any of the specified permissions evaluates to true; otherwise,false.
Exceptions
- System.ArgumentException
thrown if permissionIdentifier is nof valid for the given permissionTarge