Beispiel #1
0
 public void DenyPermission(PermissionId permissionId)
 {
     ThrowIfArchived();
     if (IsKnownPermission(permissionId))
     {
         Apply(
             new RolePermissionDenied(Id, permissionId));
     }
 }
Beispiel #2
0
 public void RemovePermission(PermissionId permissionId)
 {
     ThrowIfArchived();
     if (IsKnownPermission(permissionId))
     {
         Apply(
             new RemovedPermissionFromRole(Id, permissionId));
     }
 }
Beispiel #3
0
 public void AllowPermission(PermissionId permissionId)
 {
     ThrowIfArchived();
     if (IsKnownPermission(permissionId))
     {
         Apply(
             new RolePermissionAllowed(Id, permissionId));
     }
 }
Beispiel #4
0
 public void AddPermission(PermissionId permissionId)
 {
     ThrowIfArchived();
     if (IsUnknownPermission(permissionId))
     {
         Apply(
             new AddedPermissionToRole(Id, permissionId));
     }
 }
Beispiel #5
0
        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);
        }
Beispiel #7
0
 public RolePermission(PermissionId permissionId, AccessDecision accessDecision)
 {
     _permissionId   = permissionId;
     _accessDecision = accessDecision;
 }
Beispiel #8
0
 RolePermission FindPermission(PermissionId permissionId)
 {
     return(_permissions.Find(permission => permission.PermissionId == permissionId));
 }
Beispiel #9
0
 bool IsKnownPermission(PermissionId permissionId)
 {
     return(_permissions.Exists(permission => permission.PermissionId == permissionId));
 }