/// <summary> /// Adds the specified application object into the system. /// </summary> /// <param name="applicationId">The application id.</param> public void Add(int applicationId, int isError, int securableObjectTypeId, string securableObjectTypeName) { #region Logging if (log.IsDebugEnabled) log.Debug(Messages.MethodEnter); #endregion //Gets the application object of a specified applicationId. Application application = GatekeeperFactory.ApplicationSvc.Get(applicationId); if (isError == 1) { //this.PropertyBag["securableObjectType"] = GatekeeperFactory.SecurableObjectTypeSvc.Get(application, securableObjectTypeId);//securableObjectType; SecurableObjectType securableObjectType = new SecurableObjectType() { Id = securableObjectTypeId, Name = securableObjectTypeName, Application = application }; this.PropertyBag["securableObjectType"] = securableObjectType; } else { //Creates the PropertyBag variable. this.PropertyBag["securableObjectType"] = new SecurableObjectType() { Application = application }; } this.AddToBreadcrumbTrail(new Link() { Text = "Home", Controller = "home", Action = "default" }); this.AddToBreadcrumbTrail(new Link() { Text = application.Name, Controller = "application", Action = "display", QueryString = string.Format("applicationId={0}", applicationId) }); this.AddToBreadcrumbTrail(new Link() { Text = "Securable Object Types", Controller = "securableObjectType", Action = "default", QueryString = string.Format("applicationId={0}", applicationId) }); this.AddToBreadcrumbTrail(new Link() { Text = "New" }); this.RenderBreadcrumbTrail(); #region Logging if (log.IsDebugEnabled) log.Debug(Messages.MethodLeave); #endregion }
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 }