Exemplo n.º 1
0
 public void CopyFrom(Application application)
 {
     this.Id = application.Id;
     this.Name = application.Name;
     this.Description = application.Description;
     this.Guid = application.Guid;
 }
 /// <summary>
 /// Initializes a new instance of the ApplicationSecurityContext class with application.
 /// </summary>
 /// <param name="application">The application.</param>
 public ApplicationSecurityContext(Application application)
 {
     this.Initialize(application);
 }
        /// <summary>
        /// Initializes the specified application,it lets roles,rights,securableobject-types,role-right-assignments of that specified application to be initialized.
        /// </summary>
        /// <param name="application">The application.</param>
        private void Initialize(Application application)
        {
            //sets the property Application to application
            this.Application = application;

            //gets the collection of roles of specified application and assign that to property Roles.
            this.Roles = GatekeeperFactory.RoleSvc.Get(this.Application);
            #region logging
            log.Debug("Loaded Application Roles:");
            foreach(var role in this.Roles) log.Debug(role.Name);

            #endregion

            //gets the collection of rights of specified application and assign that to property Rights.
            this.Rights = GatekeeperFactory.RightSvc.Get(this.Application);

            //gets the collection of securableObjectType of specified application and assign that to SecurableObjectTypes.
            this.SecurableObjectTypes = GatekeeperFactory.SecurableObjectTypeSvc.Get(this.Application);

            //gets the collection of roleRightAssignment of specified application and assign that to RoleRightAssignments.
            this.RoleRightAssignments = GatekeeperFactory.RoleRightAssignmentSvc.Get(this.Application);

            //Initializes Right,Role,SecurableObjectType of every RoleRightAssignment object in RoleRightAssignments collection.
            foreach (RoleRightAssignment rra in this.RoleRightAssignments)
            {
                rra.Right = this.Rights[rra.Right.Id];
                rra.Role = this.Roles[rra.Role.Id];
                rra.SecurableObjectType = this.SecurableObjectTypes[rra.SecurableObjectType.Id];
                rra.Right.SecurableObjectType = rra.SecurableObjectType;
                rra.Role.SecurableObjectType = rra.SecurableObjectType;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Edits the specified application id.
        /// </summary>
        /// <param name="applicationId">The application id.</param>
        public void Edit(int applicationId, string applicationName, string applicationDescription)
        {
            #region Logging
            if (log.IsDebugEnabled) log.Debug(Messages.MethodEnter);
            #endregion

            //            //Creates a ObjectRight object.
            //            ObjectRight or1 = new ObjectRight(this.Application, "Administer_System");
            //            //ObjectRight or2 = new ObjectRight(myObject, "Edit_MyObject");
            //
            //            //Creates a ObjectRightCollection.
            //            ObjectRightCollection objectRights = new ObjectRightCollection();
            //
            //            //Adds object or1 into ObjectRightCollection.
            //            objectRights.Add(or1);
            //            //objectRights.Add(or2);
            //            new Permission(objectRights).Demand();

            Application application;

            if (applicationDescription == null || applicationName == null)
            {
                //Gets the Application object of that particular applicationId.
                application = GatekeeperFactory.ApplicationSvc.Get(applicationId);
            }
            else
            {
                application = new Application()
                {
                    Name = applicationName,
                    Description = applicationName
                };
            }

            //Creates a PropertyBag variable application.
            this.PropertyBag["application"] = application;

            #region BreadcrumbTrail
            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 = "Edit" });
            this.RenderBreadcrumbTrail();
            #endregion

            #region Logging
            if (log.IsDebugEnabled) log.Debug(Messages.MethodLeave);
            #endregion
        }
Exemplo n.º 5
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.º 6
0
 public SecurableApplication(Application application)
 {
     this.Application = application;
     this.CopyFrom(application);
 }
Exemplo n.º 7
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.º 8
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.º 9
0
 public UserRoleAssignmentCollection GetUsersByApplication(Application application)
 {
     UserRoleAssignmentCollection uras = this.userRoleAssignmentDao.Get(application);
     this.PopulateDetails(uras);
     return uras;
 }
Exemplo n.º 10
0
 public UserRoleAssignment Get(Application application, User user, SecurableObject securableObject)
 {
     UserRoleAssignment ura = this.userRoleAssignmentDao.Get(application, user, securableObject);
     this.PopulateDetails(ura);
     return ura;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Gets all the User-Right-Assignment objects of a specified application id and user id,it returns collection of UserRightAssignment objects.
 /// </summary>
 /// <param name="application">The application.</param>
 /// <param name="user">The user.</param>
 /// <returns></returns>
 public UserRightAssignmentCollection GetByApplicationUser(Application application, User user)
 {
     return this._dao.GetByApplicationUser(application, user);
 }