Exemplo n.º 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
     }));
 }
Exemplo n.º 2
0
 public Authority GetUserAuthority(string id)
 {
     Security.UserInformation userInformation = this._userList[id];
     if (userInformation == null)
     {
         return(Authority.None);
     }
     return(userInformation.Authority);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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
                });
            }
        }
Exemplo n.º 9
0
 public bool IsPassword(string id, byte[] hashedPassword)
 {
     Security.UserInformation userInformation = this._userList[id];
     return(userInformation != null && this.IsPassword(userInformation, hashedPassword));
 }
Exemplo n.º 10
0
 public bool CheckAuthority(string id, Authority authority)
 {
     Security.UserInformation userInformation = this._userList[id];
     return(userInformation != null && userInformation.Authority >= authority);
 }