예제 #1
0
파일: Security.cs 프로젝트: whesius/allors
 public void GrantSales(ObjectType objectType, OperandType operandType, params Operation[] operations)
 {
     this.Grant(Roles.SalesId, objectType, operandType, operations);
 }
예제 #2
0
파일: Security.cs 프로젝트: whesius/allors
        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);
                        }
                    }
                }
            }
        }
예제 #3
0
파일: Security.cs 프로젝트: whesius/allors
 public void GrantProcurement(ObjectType objectType, OperandType operandType, params Operation[] operations)
 {
     this.Grant(Roles.ProcurementId, objectType, operandType, operations);
 }
예제 #4
0
 public void GrantSupplier(ObjectType objectType, OperandType operandType, params Operations[] operations)
 {
     this.Grant(Roles.SupplierRoleId, objectType, operandType, operations);
 }
예제 #5
0
 internal void Sync(ObjectType concreteClass, OperandType operandType, Operation operation)
 {
     this.OperandType = operandType;
     this.Operation = operation;
     this.ConcreteClassPointer = concreteClass.Id;
 }
예제 #6
0
 public bool IsPermitted(OperandType operandType, Operation operation)
 {
     return this.IsPermitted(operandType.Id, operation);
 }
예제 #7
0
        public IList<Operation> GetOperations(OperandType operandType)
        {
            IList<Operation> operations;
            if (!this.OperationsByOperandTypeId.TryGetValue(operandType.Id, out operations))
            {
                return EmptyOperations;
            }

            return operations;
        }