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