Exemplo n.º 1
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
        }
        /// <summary>
        /// Gets the collection of rights of a specified role.
        /// </summary>
        /// <param name="role">The role.</param>
        /// <returns></returns>
        public RightCollection GetRights(Role role)
        {
            RightCollection rights = new RightCollection();

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

            //returns the RightCollection.
            return rights;
        }
Exemplo n.º 3
0
 public UserRoleAssignmentCollection Get(Application application, Role role, Guid securableObjectGUID)
 {
     UserRoleAssignmentCollection uras = this.userRoleAssignmentDao.Get(application, role, securableObjectGUID);
     this.PopulateDetails(uras);
     return uras;
 }
Exemplo n.º 4
0
 ///// <summary>
 ///// Updates the specified role.
 ///// </summary>
 ///// <param name="role">The role.</param>
 //public void Update(UserRoleAssignment userRoleAssignment)
 //{
 //    this.userRoleAssignmentDao.Update(userRoleAssignment);
 //}
 /// <summary>
 /// Deletes the specified role.
 /// </summary>
 /// <param name="role">The role.</param>
 public void Delete(Role role)
 {
     //this.userRoleAssignmentDao.Delete(role);
 }
Exemplo n.º 5
0
        public void Save(Application application, User user, Role role, SecurableObject securableObject)
        {
            UserRoleAssignmentDao uraDao = new UserRoleAssignmentDao();
            //long securableObjectId = new SecurableObjectDao().GetId(securableObject.SecurableObjectGuid);
            UserRoleAssignment ura = uraDao.Get(application, user, securableObject);

            if (ura == null)
            {
                ura = new UserRoleAssignment()
                {
                    Application = application,
                    User = user,
                    Role = role,
                    SecurableObjectId = securableObject.Id
                };

                uraDao.Add(ura);
            }
            else
            {
                ura.Role = role;
                uraDao.Update(ura);
            }
        }
Exemplo n.º 6
0
        public void Save(Application application, User user, Role role, ISecurableObject securableObject)
        {
            SecurableObject sObj = GatekeeperFactory.SecurableObjectSvc.Get(securableObject.SecurableObjectGuid);

            this.Save(application, user, role, sObj);
        }
Exemplo n.º 7
0
 public UserRoleAssignment Get(User user, Role role, Guid securableObjectGUID)
 {
     return null;
 }