Esempio n. 1
0
        public void DenyExcept(ObjectType objectType, ObjectState objectState, IEnumerable <IOperandType> excepts, params Operations[] operations)
        {
            var actualOperations = operations ?? ReadWriteExecute;

            foreach (var operation in actualOperations)
            {
                Dictionary <IOperandType, Permission> permissionByOperandType;
                switch (operation)
                {
                case Operations.Read:
                    this.readPermissionsByObjectTypeId.TryGetValue(objectType.Id, out permissionByOperandType);
                    break;

                case Operations.Write:
                    this.writePermissionsByObjectTypeId.TryGetValue(objectType.Id, out permissionByOperandType);
                    break;

                case Operations.Execute:
                    this.executePermissionsByObjectTypeId.TryGetValue(objectType.Id, out permissionByOperandType);
                    break;

                default:
                    throw new Exception("Unkown operation: " + operations);
                }

                if (permissionByOperandType != null)
                {
                    foreach (var dictionaryEntry in permissionByOperandType.Where(v => !excepts.Contains(v.Key)))
                    {
                        objectState.AddDeniedPermission(dictionaryEntry.Value);
                    }
                }
            }
        }
Esempio n. 2
0
 public void Deny(ObjectType objectType, ObjectState objectState, IEnumerable <OperandType> operandTypes)
 {
     if (this.deniablePermissionByOperandTypeIdByObjectTypeId.TryGetValue(objectType.Id, out var deniablePermissionByOperandTypeId))
     {
         foreach (var operandType in operandTypes)
         {
             if (deniablePermissionByOperandTypeId.TryGetValue(operandType.Id, out var permission))
             {
                 objectState.AddDeniedPermission(permission);
             }
         }
     }
 }
Esempio n. 3
0
        public void Deny(ObjectType objectType, ObjectState objectState, params OperandType[] operandTypes)
        {
            Dictionary <Guid, Permission> deniablePermissionByOperandTypeId;

            if (this.deniablePermissionByOperandTypeIdByObjectTypeId.TryGetValue(objectType.Id, out deniablePermissionByOperandTypeId))
            {
                foreach (var operandType in operandTypes)
                {
                    Permission permission;
                    if (deniablePermissionByOperandTypeId.TryGetValue(operandType.Id, out permission))
                    {
                        objectState.AddDeniedPermission(permission);
                    }
                }
            }
        }
Esempio n. 4
0
 public void Deny(ObjectType objectType, ObjectState objectState, params OperandType[] operandTypes)
 {
     Dictionary<Guid, Permission> deniablePermissionByOperandTypeId;
     if (this.deniablePermissionByOperandTypeIdByObjectTypeId.TryGetValue(objectType.Id, out deniablePermissionByOperandTypeId))
     {
         foreach (var operandType in operandTypes)
         {
             Permission permission;
             if (deniablePermissionByOperandTypeId.TryGetValue(operandType.Id, out permission))
             {
                 objectState.AddDeniedPermission(permission);
             }
         }
     }
 }
Esempio n. 5
0
        public void Deny(ObjectType objectType, ObjectState objectState, params Operation[] operations)
        {
            var actualOperations = operations ?? ReadWriteExecute;
            foreach (var operation in actualOperations)
            {
                Dictionary<OperandType, Permission> permissionByOperandType;
                switch (operation)
                {
                    case Operation.Read:
                        this.readPermissionsByObjectTypeId.TryGetValue(objectType.Id, out permissionByOperandType);
                        break;

                    case Operation.Write:
                        this.writePermissionsByObjectTypeId.TryGetValue(objectType.Id, out permissionByOperandType);
                        break;

                    case Operation.Execute:
                        this.executePermissionsByObjectTypeId.TryGetValue(objectType.Id, out permissionByOperandType);
                        break;

                    default:
                        throw new Exception("Unkown operation: " + operations);
                }

                if (permissionByOperandType != null)
                {
                    foreach (var dictionaryEntry in permissionByOperandType)
                    {
                        objectState.AddDeniedPermission(dictionaryEntry.Value);
                    }
                }
            }
        }