private void InitializeApplication(Application application) { var securableApplication = new SecurableApplication(); securableApplication.CopyFrom(application); // adding the system securable object type. SecurableObjectType systemObjectType = new SecurableObjectType() { Id = 0, Application = securableApplication, Name = "system", Description = "System Securable Object Type" }; // adding the systemObjectType as a securable object type. GatekeeperFactory.SecurableObjectTypeSvc.Add(systemObjectType); securableApplication.SecurableObjectType = systemObjectType; // adding the application as a securable object. GatekeeperFactory.SecurableObjectSvc.Add(securableApplication as ISecurableObject); // defining the system administrator role. Role systemAdministerRole = new Role() { Application = securableApplication, Name = "system_admin", Description = "Administers 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. // defining the Administer_System right. Right administerSystemRight = new Right() { Application = securableApplication, Name = "administer_system", Description = "Administers the System", SecurableObjectType = systemObjectType }; // defining the View_System right. Right viewSystemRight = new Right() { Application = securableApplication, 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 = securableApplication, Role = systemAdministerRole, Right = administerSystemRight, SecurableObjectType = systemObjectType }; // adding the role-right assignment (System Admin - View_System) RoleRightAssignment admin_view = new RoleRightAssignment() { Application = securableApplication, Role = systemAdministerRole, Right = viewSystemRight, SecurableObjectType = systemObjectType }; IRoleRightAssignmentSvc rraSvc = GatekeeperFactory.RoleRightAssignmentSvc; rraSvc.Add(admin_administer); rraSvc.Add(admin_view); var adminUser = GatekeeperFactory.UserSvc.GetByLoginName("admin"); IApplicationUserSvc appUserSvc = GatekeeperFactory.ApplicationUserSvc; appUserSvc.Save(new ApplicationUser(){Application = securableApplication, User = adminUser, Role = systemAdministerRole}); }
void ImportRightAssignment(Application application, Role role, XmlNode node) { var rightName = node.Attributes["name"].Value; var right = GatekeeperFactory.RightSvc.Get(application, rightName); var item = new RoleRightAssignment() { Role = role, Right = right, Application = application, SecurableObjectType = role.SecurableObjectType }; Console.WriteLine("Adding Role Right Assignment '{0} - {1}'.", role.Name, rightName); try { GatekeeperFactory.RoleRightAssignmentSvc.Add(item); Console.WriteLine("Completed adding Role Right Assignment '{0} - {1}'.", role.Name, rightName); } catch(Exception ex) { Console.WriteLine("Error occurred while adding Role Right Assignment '{0} - {1}'.", role.Name, rightName); Console.WriteLine(ex.ToString()); } }
/// <summary> /// Deletes the specified role right assignment from the system. /// </summary> /// <param name="roleRightAssignment">The role right assignment.</param> public void Delete(RoleRightAssignment roleRightAssignment) { this.roleRightAssignmentDao.Delete(roleRightAssignment); }
void PopulateDetails(RoleRightAssignment assignment) { assignment.Role = this.roleSvc.Get(assignment.Role.Id); assignment.Right = this.rightSvc.Get(assignment.Right.Id); }
/// <summary> /// Adds the specified rra,inserts the Role-Right-Assignment object into the system. /// </summary> /// <param name="rra">The rra.</param> public void Add(RoleRightAssignment rra) { this.roleRightAssignmentDao.Add(rra); }