Example #1
0
 public void WriteSecurity(XmlWriter writer)
 {
     Security.UserInformation[] array = new Security.UserInformation[this._userList.Count];
     this._userList.Values.CopyTo(array, 0);
     new XmlSerializer(typeof(Security.UserInformation[]), new XmlRootAttribute("Authority")).Serialize(writer, array, new XmlSerializerNamespaces(new XmlQualifiedName[]
     {
         XmlQualifiedName.Empty
     }));
 }
Example #2
0
 public Authority GetUserAuthority(string id)
 {
     Security.UserInformation userInformation = this._userList[id];
     if (userInformation == null)
     {
         return(Authority.None);
     }
     return(userInformation.Authority);
 }
Example #3
0
        private void GetUserList(User user)
        {
            GetUserListReply getUserListReply = new GetUserListReply();

            foreach (object obj in Base.Security.Users)
            {
                Security.UserInformation userInformation = (Security.UserInformation)obj;
                getUserListReply.AddUser(userInformation.ID, userInformation.Authority);
            }
            user.Send <GetUserListReply>(getUserListReply);
        }
Example #4
0
 public void ChangeAuthority(string id, Authority newAuthority)
 {
     if (newAuthority == Authority.None)
     {
         throw new ArgumentException("newAuthority", "it cannot be none!");
     }
     Security.UserInformation userInformation = this._userList[id];
     if (userInformation != null)
     {
         userInformation.Authority = newAuthority;
     }
 }
Example #5
0
 public void ChangePassword(string id, byte[] newPassword)
 {
     if (newPassword == null)
     {
         throw new ArgumentNullException("newPassword");
     }
     Security.UserInformation userInformation = this._userList[id];
     if (userInformation != null)
     {
         userInformation.HashedPassword = newPassword;
     }
 }
Example #6
0
 private bool IsPassword(Security.UserInformation user, byte[] hashedPassword)
 {
     if (hashedPassword.Length != user.HashedPassword.Length)
     {
         return(false);
     }
     for (int i = 0; i < hashedPassword.Length; i++)
     {
         if (hashedPassword[i] != user.HashedPassword[i])
         {
             return(false);
         }
     }
     return(true);
 }
Example #7
0
 public Authority GetUserAuthority(string id, byte[] password)
 {
     if (this._userList.ContainsKey(id))
     {
         Security.UserInformation userInformation = this._userList[id];
         if (userInformation == null)
         {
             return(Authority.None);
         }
         if (this.IsPassword(userInformation, password))
         {
             return(userInformation.Authority);
         }
     }
     return(Authority.None);
 }
Example #8
0
        private void ControlEnter(User user)
        {
            User user2 = User.RequireMutex(user);
            ControlEnterReply controlEnterReply = new ControlEnterReply(user2.AccountId);

            if (user2 == user)
            {
                controlEnterReply.AddTemplate(Base.ProcessTemplate);
                foreach (object obj in Base.Security.Users)
                {
                    Security.UserInformation userInformation = (Security.UserInformation)obj;
                    controlEnterReply.AddUser(userInformation.ID, userInformation.Authority);
                }
            }
            user.Send <ControlEnterReply>(controlEnterReply);
            if (user2 == user)
            {
                this.NotifyMessage(MessageType.Message, "{0} entered control mode", new object[]
                {
                    user.AccountId
                });
            }
        }
Example #9
0
 public bool IsPassword(string id, byte[] hashedPassword)
 {
     Security.UserInformation userInformation = this._userList[id];
     return(userInformation != null && this.IsPassword(userInformation, hashedPassword));
 }
Example #10
0
 public bool CheckAuthority(string id, Authority authority)
 {
     Security.UserInformation userInformation = this._userList[id];
     return(userInformation != null && userInformation.Authority >= authority);
 }