/// <summary>
        /// Gets the collection of roles of a specified right.
        /// </summary>
        /// <param name="right">The right.</param>
        /// <returns></returns>
        public RoleCollection GetRoles(Right right)
        {
            RoleCollection roles = new RoleCollection();

            //Checking whether that specified right is in each and every Role-Right-assignment object of RoleRightAssignments collection.
            //If it is there,find the role of that Role-Right-Assignment object and add that to RoleCollection-roles.
            foreach (RoleRightAssignment rra in this.RoleRightAssignments)
            {
                if (rra.Right.Id == right.Id)
                    roles.Add(rra.Role);
            }

            //returns the RoleCollection.
            return roles;
        }
Пример #2
0
        public void AddSystemSecurableObject(SecurableApplication application)
        {
            #region Adding the application initialization data.

            GatekeeperFactory.ApplicationSvc.Add(application);

            // adding the system securable object type.
            SecurableObjectType systemObjectType = new SecurableObjectType()
            {
                    Id = 0,
                    Application = application,
                    Name = "System",
                    Description = "System Securable Object Type"
            };

            // adding the systemObjectType as a securable object type.
            GatekeeperFactory.SecurableObjectTypeSvc.Add(systemObjectType);

            application.SecurableObjectType = systemObjectType;

            // adding the application as a securable object.
            this.AddSecurableObject(application);

            // defining the system administrator role.
            Role systemAdministerRole = new Role()
            {
                Application = application,
                Name = "Administrator",
                Description = "Administers the System",
                SecurableObjectType = systemObjectType
            };

            // defining the system user role.
            Role systemUserRole = new Role()
            {
                Application = application,
                Name = "User",
                Description = "Uses the System",
                SecurableObjectType = systemObjectType
            };

            // adding the system administrator and the system user roles.
            IRoleSvc roleSvc = GatekeeperFactory.RoleSvc;
            roleSvc.Add(systemAdministerRole);//adding the systemAdministerRole as a role.
            roleSvc.Add(systemUserRole);//adding the systemUserRole as a role.

            // defining the Administer_System right.
            Right administerSystemRight = new Right()
            {
                Application = application,
                Name = "Administer_System",
                Description = "Administers the System",
                SecurableObjectType = systemObjectType
            };

            // defining the View_System right.
            Right viewSystemRight = new Right()
            {
                Application = application,
                Name = "View_System",
                Description = "Views the System",
                SecurableObjectType = systemObjectType
            };

            // adding the Administer_System and the View_System rights.
            IRightSvc rightSvc = GatekeeperFactory.RightSvc;
            rightSvc.Add(administerSystemRight);//adding the administerSystemRight as a right.
            rightSvc.Add(viewSystemRight);//adding the viewSystemRight as a right.

            // adding the role-right assignment (System Admin - Administer_System)
            RoleRightAssignment admin_administer = new RoleRightAssignment()
            {
                Application = application,
                Role = systemAdministerRole,
                Right = administerSystemRight,
                SecurableObjectType = systemObjectType
            };

            // adding the role-right assignment (System Admin - View_System)
            RoleRightAssignment admin_view = new RoleRightAssignment()
            {
                Application = application,
                Role = systemAdministerRole,
                Right = viewSystemRight,
                SecurableObjectType = systemObjectType
            };

            // adding the role-right assignment (System User - View_System)
            RoleRightAssignment user_view = new RoleRightAssignment()
            {
                Application = application,
                Role = systemUserRole,
                Right = viewSystemRight,
                SecurableObjectType = systemObjectType
            };

            IRoleRightAssignmentSvc rraSvc = GatekeeperFactory.RoleRightAssignmentSvc;
            rraSvc.Add(admin_administer);
            rraSvc.Add(admin_view);
            rraSvc.Add(user_view);

            #endregion
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the ObjectRight class with two parameters.
 /// </summary>
 /// <param name="securableObjectGUID">The securable object GUID,object if Guid class.</param>
 /// <param name="right">The right,object of Right Class.</param>
 public ObjectRight(long securableObjectId, Right right)
 {
     this.Right = right;
     this.SecurableObjectId = securableObjectId;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the ObjectRight class with two parameters.
 /// </summary>
 /// <param name="securableObject">The securable object.</param>
 /// <param name="right">The right.</param>
 public ObjectRight(ISecurableObject securableObject, Right right)
     : this(securableObject.SecurableObjectId, right)
 {
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the UserRightAssignment class.
 /// </summary>
 /// <param name="user">The user of the application.</param>
 /// <param name="securableObject">The securable object.</param>
 /// <param name="right">The right.</param>
 public UserRightAssignment(User user, ISecurableObject securableObject, Right right)
     : base(securableObject, right)
 {
     this.User = user;
 }