コード例 #1
0
        public User AddUser(string userName, string password, string firstName, string lastName)
        {
            string salt = CryptoHelper.CreateSalt(5);
            string hash = CryptoHelper.CreatePasswordHash(password, salt);
            User user = new User()
            {
                LoginName = userName,
                FirstName = firstName,
                LastName = lastName,
                PasswordHash = hash,
                PasswordSalt = salt
            };

            GatekeeperFactory.UserSvc.Add(user);

            return user;
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: chamith/gatekeeper
        /// <summary>
        /// Adds user.
        /// </summary>
        public void Add()
        {
            #region Logging
            if (log.IsDebugEnabled) log.Debug(Messages.MethodEnter);
            #endregion

            User user = new User();
            this.PropertyBag["user"] = user;

            this.AddToBreadcrumbTrail(new Link() { Text = "Users", Controller = "user", Action = "default" });
            this.AddToBreadcrumbTrail(new Link() { Text = "New" });
            this.RenderBreadcrumbTrail();

            #region Logging
            if (log.IsDebugEnabled) log.Debug(Messages.MethodLeave);
            #endregion
        }
コード例 #3
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);
        }
コード例 #4
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);
            }
        }
コード例 #5
0
 public UserRoleAssignmentCollection Get(Application application, User user)
 {
     UserRoleAssignmentCollection uras = this.userRoleAssignmentDao.Get(application, user);
     this.PopulateDetails(uras);
     return uras;
 }
コード例 #6
0
 public UserRoleAssignment Get(Application application, User user, SecurableObject securableObject)
 {
     UserRoleAssignment ura = this.userRoleAssignmentDao.Get(application, user, securableObject);
     this.PopulateDetails(ura);
     return ura;
 }
コード例 #7
0
 public UserRoleAssignment Get(User user, Role role, Guid securableObjectGUID)
 {
     return null;
 }
コード例 #8
0
 /// <summary>
 /// Initializes the specified user.
 /// </summary>
 /// <param name="user">The user.</param>
 private void Initialize(User user)
 {
     this.User = user;
     this.RoleAssignments =
         GatekeeperFactory.UserRoleAssignmentSvc.Get(this.ApplicationSecurityContext.Application, this.User);
     this.RightAssignments =
         GatekeeperFactory.UserRightAssignmentSvc.GetByApplicationUser(this.ApplicationSecurityContext.Application, this.User);
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the UserSecurityContext class.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="appSecContext">The app sec context.</param>
 public UserSecurityContext(User user, ApplicationSecurityContext appSecContext)
 {
     this.ApplicationSecurityContext = appSecContext;
     this.Initialize(user);
 }
コード例 #10
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);
 }
コード例 #11
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;
 }