public RoleType[] GetBooleanRoles(ObjectType type) { var roleList = new ArrayList(); foreach (var metaRole in type.RoleTypes) { if (metaRole.ObjectType.IsBoolean) { roleList.Add(metaRole); } } return (RoleType[])roleList.ToArray(typeof(RoleType)); }
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); } } } }
public void GrantSales(ObjectType objectType, OperandType operandType, params Operation[] operations) { this.Grant(Roles.SalesId, objectType, operandType, operations); }
public abstract IObject[] CreateArray(ObjectType objectType, int count);
/// <summary> /// Derive super types recursively. /// </summary> /// <param name="type">The type .</param> /// <param name="superTypes">The super types.</param> private void DeriveSupertypesRecursively(ObjectType type, HashSet<Interface> superTypes) { foreach (var directSupertype in this.derivedDirectSupertypes) { if (!Equals(directSupertype, type)) { superTypes.Add(directSupertype); directSupertype.DeriveSupertypesRecursively(type, superTypes); } } }
/// <summary> /// The dependee is set up before the dependent object; /// </summary> /// <param name="dependent"></param> /// <param name="dependee"></param> public void AddDependency(ObjectType dependent, ObjectType dependee) { this.objectsGraph.AddDependency(this.objectsByObjectType[dependent], this.objectsByObjectType[dependee]); }
public void GrantOwner(ObjectType objectType, params Operation[] operations) { this.Grant(Roles.OwnerId, objectType, operations); }
public void GrantAdministrator(ObjectType objectType, params Operation[] operations) { this.Grant(Roles.AdministratorId, objectType, operations); }
internal void Sync(ObjectType concreteClass, OperandType operandType, Operation operation) { this.OperandType = operandType; this.Operation = operation; this.ConcreteClassPointer = concreteClass.Id; }
public void GrantEmployee(ObjectType objectType, params Operation[] operations) { this.Grant(Roles.EmployeeId, objectType, operations); }
public void GrantAccountant(ObjectType objectType, params Operation[] operations) { this.Grant(Roles.AccountantId, objectType, operations); }
private IObject[] CreateRolesWithSameClass(ISession session, RelationType relationType, ObjectType roleClass) { IObject[] allRoles = this.CreateArray(relationType.RoleType.ObjectType, this.GetRoleCount()); for (int i = 0; i < allRoles.Length; i++) { allRoles[i] = session.Create(roleClass); } return allRoles; }
private IObject[] CreateRolesWithSameClass(RelationType relationType, ObjectType roleClass) { return this.CreateRolesWithSameClass(this.GetSession(), relationType, roleClass); }
private IObject[] CreateAssociationsWithSameClass(RelationType relationType, ObjectType associationClass) { IObject[] associations = this.CreateArray(relationType.AssociationType.ObjectType, this.GetAssociationCount()); for (int i = 0; i < this.GetAssociationCount(); i++) { associations[i] = this.GetSession().Create(associationClass); } return associations; }
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); } } } }
public void GrantOperations(ObjectType objectType, params Operations[] operations) { this.Grant(Roles.OperationsId, objectType, 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 GrantPartner(ObjectType objectType, params Operations[] operations) { this.Grant(Roles.PartnerRoleId, objectType, operations); }
public void GrantGuest(ObjectType objectType, params Operation[] operations) { this.Grant(Roles.GuestId, objectType, operations); }
public void GrantSupplier(ObjectType objectType, OperandType operandType, params Operations[] operations) { this.Grant(Roles.SupplierRoleId, objectType, operandType, operations); }
public IObject[] CreateArray(ObjectType objectType, int count) { var type = this.GetPopulation().DomainAssembly.GetType(objectType.FullNameForCts); var allorsObjects = (IObject[])Array.CreateInstance(type, count); return allorsObjects; }
private Permission FindPermission(ObjectType objectType, RoleType roleType, Operation operation) { Extent<Permission> permissions = this.DatabaseSession.Extent<Permission>(); permissions.Filter.AddEquals(Permissions.Meta.ConcreteClassPointer, objectType.Id); permissions.Filter.AddEquals(Permissions.Meta.OperandTypePointer, roleType.Id); permissions.Filter.AddEquals(Permissions.Meta.OperationEnum, operation); return permissions.First; }
public Dictionary<Guid, IList<Operation>> GetOperationsByOperandTypeId(HashSet<Guid> roleUniqueIds, ObjectType objectType, out bool hasWriteOperation, out bool hasReadOperation) { var resultOperationsByOperandId = new Dictionary<Guid, IList<Operation>>(); hasWriteOperation = false; hasReadOperation = false; foreach (var roleUniqueId in roleUniqueIds) { var roleOperationsByOperandIdByObjectType = this.operationsByOperandTypeIdByObjectTypeIdByRoleId[roleUniqueId]; Dictionary<Guid, List<Operation>> roleOperationsByOperandObjectId; if (roleOperationsByOperandIdByObjectType.TryGetValue(objectType.Id, out roleOperationsByOperandObjectId)) { foreach (var dictionaryEntry in roleOperationsByOperandObjectId) { var roleOperandTypeId = dictionaryEntry.Key; var roleOperations = dictionaryEntry.Value; IList<Operation> resultOperations; if (!resultOperationsByOperandId.TryGetValue(roleOperandTypeId, out resultOperations)) { resultOperations = new List<Operation>(); resultOperationsByOperandId[roleOperandTypeId] = resultOperations; } foreach (var roleOperation in roleOperations) { if (!resultOperations.Contains(roleOperation)) { if (roleOperation == Operation.Write) { hasWriteOperation = true; } if (roleOperation == Operation.Read) { hasReadOperation = true; } resultOperations.Add(roleOperation); } } } } } return resultOperationsByOperandId; }
public void GrantProcurement(ObjectType objectType, OperandType operandType, params Operation[] operations) { this.Grant(Roles.ProcurementId, objectType, operandType, operations); }
public override IObject[] CreateArray(ObjectType objectType, int count) { return this.profile.CreateArray(objectType, count); }
/// <summary> /// Derive super types recursively. /// </summary> /// <param name="type">The type .</param> /// <param name="subTypes">The super types.</param> private void DeriveSubtypesRecursively(ObjectType type, HashSet<Composite> subTypes) { foreach (var directSubtype in this.derivedDirectSubtypes) { if (!Equals(directSubtype, type)) { subTypes.Add(directSubtype); if (directSubtype is IInterface) { ((Interface)directSubtype).DeriveSubtypesRecursively(this, subTypes); } } } }