Esempio n. 1
0
 public void GrantSales(ObjectType objectType, OperandType operandType, params Operation[] operations)
 {
     this.Grant(Roles.SalesId, objectType, operandType, operations);
 }
Esempio n. 2
0
        public void Grant(Guid roleId, ObjectType objectType, OperandType operandType, params Operation[] operations)
        {
            Role role;
            if (this.roleById.TryGetValue(roleId, out role))
            {
                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)
                    {
                        Permission permission;
                        if (permissionByOperandType.TryGetValue(operandType, out permission))
                        {
                            role.AddPermission(permission);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 public void GrantProcurement(ObjectType objectType, OperandType operandType, params Operation[] operations)
 {
     this.Grant(Roles.ProcurementId, objectType, operandType, operations);
 }
Esempio n. 4
0
 public void GrantSupplier(ObjectType objectType, OperandType operandType, params Operations[] operations)
 {
     this.Grant(Roles.SupplierRoleId, objectType, operandType, operations);
 }
Esempio n. 5
0
 internal void Sync(ObjectType concreteClass, OperandType operandType, Operation operation)
 {
     this.OperandType = operandType;
     this.Operation = operation;
     this.ConcreteClassPointer = concreteClass.Id;
 }
Esempio n. 6
0
 public bool IsPermitted(OperandType operandType, Operation operation)
 {
     return this.IsPermitted(operandType.Id, operation);
 }
Esempio n. 7
0
        public IList<Operation> GetOperations(OperandType operandType)
        {
            IList<Operation> operations;
            if (!this.OperationsByOperandTypeId.TryGetValue(operandType.Id, out operations))
            {
                return EmptyOperations;
            }

            return operations;
        }