public void DenyPermission(PermissionId permissionId) { ThrowIfArchived(); if (IsKnownPermission(permissionId)) { Apply( new RolePermissionDenied(Id, permissionId)); } }
public void RemovePermission(PermissionId permissionId) { ThrowIfArchived(); if (IsKnownPermission(permissionId)) { Apply( new RemovedPermissionFromRole(Id, permissionId)); } }
public void AllowPermission(PermissionId permissionId) { ThrowIfArchived(); if (IsKnownPermission(permissionId)) { Apply( new RolePermissionAllowed(Id, permissionId)); } }
public void AddPermission(PermissionId permissionId) { ThrowIfArchived(); if (IsUnknownPermission(permissionId)) { Apply( new AddedPermissionToRole(Id, permissionId)); } }
public bool IsAllowed(PermissionId permissionId) { AccessDecision decision; if (_decisions.TryGetValue(permissionId, out decision)) { return(decision == AccessDecision.Allow); } return(false); }
public IAccessDecisionCombinator CombineDecision(PermissionId permissionId, AccessDecision decision) { AccessDecision otherDecision; if (_decisions.TryGetValue(permissionId, out otherDecision)) { _decisions[permissionId] = Combinations[new Tuple <AccessDecision, AccessDecision>(otherDecision, decision)]; } else { _decisions[permissionId] = decision; } return(this); }
public RolePermission(PermissionId permissionId, AccessDecision accessDecision) { _permissionId = permissionId; _accessDecision = accessDecision; }
RolePermission FindPermission(PermissionId permissionId) { return(_permissions.Find(permission => permission.PermissionId == permissionId)); }
bool IsKnownPermission(PermissionId permissionId) { return(_permissions.Exists(permission => permission.PermissionId == permissionId)); }