Class PermissionSet
Represents a permission set and provides methods for managing permissions and rules.
Inherited Members
Namespace: DataWeb.Authorization
Assembly: DataWeb.Core.dll
Syntax
public sealed class PermissionSet
Remarks
Initializes a new instance of the PermissionSet class with the required dependencies.
Constructors
PermissionSet(IReflectionService, IAppErrorService, IServiceProvider, IPermissionSetStore)
Represents a permission set and provides methods for managing permissions and rules.
Declaration
public PermissionSet(IReflectionService reflectionService, IAppErrorService appErrorService, IServiceProvider serviceProvider, IPermissionSetStore permissionSetStore)
Parameters
Type | Name | Description |
---|---|---|
IReflectionService | reflectionService | A reference to the IReflectionService implementation. |
IAppErrorService | appErrorService | A reference to the IAppErrorService implementation. |
IServiceProvider | serviceProvider | A reference to the IServiceProvider implementation. |
IPermissionSetStore | permissionSetStore | A reference to the IPermissionSetStore implementation. |
Remarks
Initializes a new instance of the PermissionSet class with the required dependencies.
Fields
PermissionRule
Gets or sets the instance of the permission rule.
Declaration
public IPermissionRule PermissionRule
Field Value
Type | Description |
---|---|
IPermissionRule |
Properties
IdMaster
Gets or sets the unique identifier.
Declaration
public string IdMaster { get; set; }
Property Value
Type | Description |
---|---|
string |
Name
Gets or sets the name of the permission set.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Permissions
Gets or sets the list of permissions.
Declaration
public IEnumerable<PermissionSet.Permission> Permissions { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<PermissionSet.Permission> |
RuleClass
Gets or sets the class name of the permission rule.
Declaration
public string RuleClass { get; set; }
Property Value
Type | Description |
---|---|
string |
User
Gets or sets the user to check permissions for.
Declaration
public IUser User { get; set; }
Property Value
Type | Description |
---|---|
IUser |
Methods
GetRuleIsVisibleFilter(string)
Retrieves a filter expression for the specified table based on the visibility rules implemented by the PermissionRule.
Declaration
public string GetRuleIsVisibleFilter(string tableName)
Parameters
Type | Name | Description |
---|---|---|
string | tableName | The name of the table for which the filter expression should be retrieved. |
Returns
Type | Description |
---|---|
string | Returns the filter expression if the PermissionRule is not null, otherwise returns null. |
GetRuleIsWrite(NavigationContext, ContextItem)
Determines if the current user has write permissions for the specified context item based on the PermissionRule.
Declaration
public Task<bool> GetRuleIsWrite(NavigationContext navigationContext, ContextItem contextItem)
Parameters
Type | Name | Description |
---|---|---|
NavigationContext | navigationContext | The NavigationContext instance representing the navigation context. |
ContextItem | contextItem | The ContextItem instance representing the context item for which the write permission should be checked. |
Returns
Type | Description |
---|---|
Task<bool> | A task that represents the asynchronous operation. Returns true if the user has write permissions, otherwise false. |
InitAsync(PermissionSetData, IUser)
Initializes the PermissionSet instance asynchronously using the specified PermissionSetData and user.
Declaration
public Task InitAsync(PermissionSetData permissionSetData, IUser user)
Parameters
Type | Name | Description |
---|---|---|
PermissionSetData | permissionSetData | The PermissionSetData instance containing the permission set information. |
IUser | user | The IUser instance representing the current user. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation. |
InitAsync(string, IUser)
Initializes the PermissionSet instance asynchronously using the specified name and user.
Declaration
public Task InitAsync(string name, IUser user)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the permission set to retrieve. |
IUser | user | The IUser instance representing the current user. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the name is not defined or the permission set is not valid. |
Is(string)
Checks if the current user has the specified permission.
Declaration
public bool Is(string permissionName)
Parameters
Type | Name | Description |
---|---|---|
string | permissionName | The name of the permission to check. |
Returns
Type | Description |
---|---|
bool | Returns true if the user has the specified permission, otherwise false. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the permission set does not contain the specified permission name. |