* 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 incorrectzircon^2
parent
7d29bd138f
commit
b2fe47ecb1
|
@ -49,7 +49,7 @@ namespace OpenGridServices.GridServer
|
|||
public class OpenGrid_Main : BaseServer, conscmd_callback
|
||||
{
|
||||
private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll";
|
||||
private string GridDll = "OpenGrid.Framework.Data.DB4o.dll";
|
||||
private string GridDll = "OpenGrid.Framework.Data.MySQL.dll";
|
||||
public GridConfig Cfg;
|
||||
|
||||
public static OpenGrid_Main thegrid;
|
||||
|
|
|
@ -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
|
|||
/// <returns>Authenticated?</returns>
|
||||
public bool AuthenticateUser(ref UserProfileData profile, string password)
|
||||
{
|
||||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(
|
||||
OpenSim.Framework.Console.LogPriority.LOW,
|
||||
"Authenticating " + profile.username + " " + profile.surname);
|
||||
|
||||
password = password.Remove(0, 3); //remove $1$
|
||||
|
||||
MD5CryptoServiceProvider MD5summer = new MD5CryptoServiceProvider();
|
||||
|
||||
byte[] byteString = System.Text.Encoding.ASCII.GetBytes(password + ":" + profile.passwordSalt);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
|
@ -43,6 +44,16 @@ namespace OpenSim.Framework.Utilities
|
|||
return timestamp;
|
||||
}
|
||||
|
||||
public static string Md5Hash(string pass)
|
||||
{
|
||||
MD5 md5 = MD5CryptoServiceProvider.Create();
|
||||
byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < dataMd5.Length; i++)
|
||||
sb.AppendFormat("{0:x2}", dataMd5[i]);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
//public static int fast_distance2d(int x, int y)
|
||||
//{
|
||||
// x = System.Math.Abs(x);
|
||||
|
|
Loading…
Reference in New Issue