Example #1
0
        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));
        }
Example #2
0
        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);
                    }
                }
            }
        }
Example #3
0
 public void GrantSales(ObjectType objectType, OperandType operandType, params Operation[] operations)
 {
     this.Grant(Roles.SalesId, objectType, operandType, operations);
 }
Example #4
0
 public abstract IObject[] CreateArray(ObjectType objectType, int count);
Example #5
0
 /// <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);
         }
     }
 }
Example #6
0
 /// <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]);
 }
Example #7
0
 public void GrantOwner(ObjectType objectType, params Operation[] operations)
 {
     this.Grant(Roles.OwnerId, objectType, operations);
 }
Example #8
0
 public void GrantAdministrator(ObjectType objectType, params Operation[] operations)
 {
     this.Grant(Roles.AdministratorId, objectType, operations);
 }
Example #9
0
 internal void Sync(ObjectType concreteClass, OperandType operandType, Operation operation)
 {
     this.OperandType = operandType;
     this.Operation = operation;
     this.ConcreteClassPointer = concreteClass.Id;
 }
Example #10
0
 public void GrantEmployee(ObjectType objectType, params Operation[] operations)
 {
     this.Grant(Roles.EmployeeId, objectType, operations);
 }
Example #11
0
 public void GrantAccountant(ObjectType objectType, params Operation[] operations)
 {
     this.Grant(Roles.AccountantId, objectType, operations);
 }
Example #12
0
        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;
        }
Example #13
0
 private IObject[] CreateRolesWithSameClass(RelationType relationType, ObjectType roleClass)
 {
     return this.CreateRolesWithSameClass(this.GetSession(), relationType, roleClass);
 }
Example #14
0
        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;
        }
Example #15
0
 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);
             }
         }
     }
 }
Example #16
0
 public void GrantOperations(ObjectType objectType, params Operations[] operations)
 {
     this.Grant(Roles.OperationsId, objectType, operations);
 }
Example #17
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);
                        }
                    }
                }
            }
        }
Example #18
0
 public void GrantPartner(ObjectType objectType, params Operations[] operations)
 {
     this.Grant(Roles.PartnerRoleId, objectType, operations);
 }
Example #19
0
 public void GrantGuest(ObjectType objectType, params Operation[] operations)
 {
     this.Grant(Roles.GuestId, objectType, operations);
 }
Example #20
0
 public void GrantSupplier(ObjectType objectType, OperandType operandType, params Operations[] operations)
 {
     this.Grant(Roles.SupplierRoleId, objectType, operandType, operations);
 }
Example #21
0
 public IObject[] CreateArray(ObjectType objectType, int count)
 {
     var type = this.GetPopulation().DomainAssembly.GetType(objectType.FullNameForCts);
     var allorsObjects = (IObject[])Array.CreateInstance(type, count);
     return allorsObjects;
 }
Example #22
0
 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;
 }
Example #23
0
        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;
        }
Example #24
0
 public void GrantProcurement(ObjectType objectType, OperandType operandType, params Operation[] operations)
 {
     this.Grant(Roles.ProcurementId, objectType, operandType, operations);
 }
Example #25
0
 public override IObject[] CreateArray(ObjectType objectType, int count)
 {
     return this.profile.CreateArray(objectType, count);
 }
Example #26
0
 /// <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);
             }
         }
     }
 }