From b2fe47ecb11d4e6c6b0f9bc124cd7a8d4703784d Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Sun, 20 May 2007 23:34:29 +0000
Subject: * Minor tweaks with new userserver * Fixed password encoding to match
MD5 standard properly. * Fixed exception caused on user first login (minor) *
Fixed exception caused by incorrect username (minor) * Returns login error
rather than grid error if username is incorrect
---
OpenGridServices.UserServer/UserManager.cs | 31 ++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
(limited to 'OpenGridServices.UserServer/UserManager.cs')
diff --git a/OpenGridServices.UserServer/UserManager.cs b/OpenGridServices.UserServer/UserManager.cs
index b579732..a312445 100644
--- a/OpenGridServices.UserServer/UserManager.cs
+++ b/OpenGridServices.UserServer/UserManager.cs
@@ -114,7 +114,14 @@ namespace OpenGridServices.UserServer
try
{
UserProfileData profile = plugin.Value.getUserByName(fname,lname);
- profile.currentAgent = getUserAgent(profile.UUID);
+ try
+ {
+ profile.currentAgent = getUserAgent(profile.UUID);
+ }
+ catch (Exception e)
+ {
+ // Ignore
+ }
return profile;
}
catch (Exception e)
@@ -295,18 +302,13 @@ namespace OpenGridServices.UserServer
/// Authenticated?
public bool AuthenticateUser(ref UserProfileData profile, string password)
{
- password = password.Remove(0, 3); //remove $1$
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine(
+ OpenSim.Framework.Console.LogPriority.LOW,
+ "Authenticating " + profile.username + " " + profile.surname);
- MD5CryptoServiceProvider MD5summer = new MD5CryptoServiceProvider();
-
- byte[] byteString = System.Text.Encoding.ASCII.GetBytes(password + ":" + profile.passwordSalt);
+ password = password.Remove(0, 3); //remove $1$
- byteString = MD5summer.ComputeHash(byteString);
- System.Text.StringBuilder s = new System.Text.StringBuilder();
- foreach (byte b in byteString)
- {
- s.Append(b.ToString("x2").ToLower());
- }
+ string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
}
@@ -360,7 +362,9 @@ namespace OpenGridServices.UserServer
// Current location
agent.regionID = new LLUUID(); // Fill in later
- agent.currentRegion = ""; // Fill in later
+ agent.currentRegion = new LLUUID(); // Fill in later
+
+ profile.currentAgent = agent;
}
///
@@ -399,6 +403,9 @@ namespace OpenGridServices.UserServer
passwd = (string)requestData["passwd"];
TheUser = getUserProfile(firstname, lastname);
+ if (TheUser == null)
+ return CreateLoginErrorResponse();
+
GoodLogin = AuthenticateUser(ref TheUser, passwd);
}
else
--
cgit v1.1