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

            return operations;
        }