diff options
author | Adam Frisby | 2007-05-20 23:34:29 +0000 |
---|---|---|
committer | Adam Frisby | 2007-05-20 23:34:29 +0000 |
commit | b2fe47ecb11d4e6c6b0f9bc124cd7a8d4703784d (patch) | |
tree | 18de3f48a8afa7bb2e03063bf026ab43765d4088 | |
parent | Finished adding comments (diff) | |
download | opensim-SC-b2fe47ecb11d4e6c6b0f9bc124cd7a8d4703784d.zip opensim-SC-b2fe47ecb11d4e6c6b0f9bc124cd7a8d4703784d.tar.gz opensim-SC-b2fe47ecb11d4e6c6b0f9bc124cd7a8d4703784d.tar.bz2 opensim-SC-b2fe47ecb11d4e6c6b0f9bc124cd7a8d4703784d.tar.xz |
* 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
Diffstat (limited to '')
-rw-r--r-- | OpenGridServices.GridServer/Main.cs | 2 | ||||
-rw-r--r-- | OpenGridServices.UserServer/UserManager.cs | 31 | ||||
-rw-r--r-- | OpenSim.Framework/Util.cs | 11 |
3 files changed, 31 insertions, 13 deletions
diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs index 97f15c9..cad5fae 100644 --- a/OpenGridServices.GridServer/Main.cs +++ b/OpenGridServices.GridServer/Main.cs | |||
@@ -49,7 +49,7 @@ namespace OpenGridServices.GridServer | |||
49 | public class OpenGrid_Main : BaseServer, conscmd_callback | 49 | public class OpenGrid_Main : BaseServer, conscmd_callback |
50 | { | 50 | { |
51 | private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; | 51 | private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; |
52 | private string GridDll = "OpenGrid.Framework.Data.DB4o.dll"; | 52 | private string GridDll = "OpenGrid.Framework.Data.MySQL.dll"; |
53 | public GridConfig Cfg; | 53 | public GridConfig Cfg; |
54 | 54 | ||
55 | public static OpenGrid_Main thegrid; | 55 | public static OpenGrid_Main thegrid; |
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 | |||
114 | try | 114 | try |
115 | { | 115 | { |
116 | UserProfileData profile = plugin.Value.getUserByName(fname,lname); | 116 | UserProfileData profile = plugin.Value.getUserByName(fname,lname); |
117 | profile.currentAgent = getUserAgent(profile.UUID); | 117 | try |
118 | { | ||
119 | profile.currentAgent = getUserAgent(profile.UUID); | ||
120 | } | ||
121 | catch (Exception e) | ||
122 | { | ||
123 | // Ignore | ||
124 | } | ||
118 | return profile; | 125 | return profile; |
119 | } | 126 | } |
120 | catch (Exception e) | 127 | catch (Exception e) |
@@ -295,18 +302,13 @@ namespace OpenGridServices.UserServer | |||
295 | /// <returns>Authenticated?</returns> | 302 | /// <returns>Authenticated?</returns> |
296 | public bool AuthenticateUser(ref UserProfileData profile, string password) | 303 | public bool AuthenticateUser(ref UserProfileData profile, string password) |
297 | { | 304 | { |
298 | password = password.Remove(0, 3); //remove $1$ | 305 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine( |
306 | OpenSim.Framework.Console.LogPriority.LOW, | ||
307 | "Authenticating " + profile.username + " " + profile.surname); | ||
299 | 308 | ||
300 | MD5CryptoServiceProvider MD5summer = new MD5CryptoServiceProvider(); | 309 | password = password.Remove(0, 3); //remove $1$ |
301 | |||
302 | byte[] byteString = System.Text.Encoding.ASCII.GetBytes(password + ":" + profile.passwordSalt); | ||
303 | 310 | ||
304 | byteString = MD5summer.ComputeHash(byteString); | 311 | string s = Util.Md5Hash(password + ":" + profile.passwordSalt); |
305 | System.Text.StringBuilder s = new System.Text.StringBuilder(); | ||
306 | foreach (byte b in byteString) | ||
307 | { | ||
308 | s.Append(b.ToString("x2").ToLower()); | ||
309 | } | ||
310 | 312 | ||
311 | return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); | 313 | return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); |
312 | } | 314 | } |
@@ -360,7 +362,9 @@ namespace OpenGridServices.UserServer | |||
360 | 362 | ||
361 | // Current location | 363 | // Current location |
362 | agent.regionID = new LLUUID(); // Fill in later | 364 | agent.regionID = new LLUUID(); // Fill in later |
363 | agent.currentRegion = ""; // Fill in later | 365 | agent.currentRegion = new LLUUID(); // Fill in later |
366 | |||
367 | profile.currentAgent = agent; | ||
364 | } | 368 | } |
365 | 369 | ||
366 | /// <summary> | 370 | /// <summary> |
@@ -399,6 +403,9 @@ namespace OpenGridServices.UserServer | |||
399 | passwd = (string)requestData["passwd"]; | 403 | passwd = (string)requestData["passwd"]; |
400 | 404 | ||
401 | TheUser = getUserProfile(firstname, lastname); | 405 | TheUser = getUserProfile(firstname, lastname); |
406 | if (TheUser == null) | ||
407 | return CreateLoginErrorResponse(); | ||
408 | |||
402 | GoodLogin = AuthenticateUser(ref TheUser, passwd); | 409 | GoodLogin = AuthenticateUser(ref TheUser, passwd); |
403 | } | 410 | } |
404 | else | 411 | else |
diff --git a/OpenSim.Framework/Util.cs b/OpenSim.Framework/Util.cs index 6f60925..400f415 100644 --- a/OpenSim.Framework/Util.cs +++ b/OpenSim.Framework/Util.cs | |||
@@ -1,4 +1,5 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Security.Cryptography; | ||
2 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
3 | using System.Text; | 4 | using System.Text; |
4 | using libsecondlife; | 5 | using libsecondlife; |
@@ -43,6 +44,16 @@ namespace OpenSim.Framework.Utilities | |||
43 | return timestamp; | 44 | return timestamp; |
44 | } | 45 | } |
45 | 46 | ||
47 | public static string Md5Hash(string pass) | ||
48 | { | ||
49 | MD5 md5 = MD5CryptoServiceProvider.Create(); | ||
50 | byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass)); | ||
51 | StringBuilder sb = new StringBuilder(); | ||
52 | for (int i = 0; i < dataMd5.Length; i++) | ||
53 | sb.AppendFormat("{0:x2}", dataMd5[i]); | ||
54 | return sb.ToString(); | ||
55 | } | ||
56 | |||
46 | //public static int fast_distance2d(int x, int y) | 57 | //public static int fast_distance2d(int x, int y) |
47 | //{ | 58 | //{ |
48 | // x = System.Math.Abs(x); | 59 | // x = System.Math.Abs(x); |