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