Better error handling on PasswordAuthenticationService
parent
13f0e4a718
commit
d167686adb
|
@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService
|
||||||
public class PasswordAuthenticationService :
|
public class PasswordAuthenticationService :
|
||||||
AuthenticationServiceBase, IAuthenticationService
|
AuthenticationServiceBase, IAuthenticationService
|
||||||
{
|
{
|
||||||
//private static readonly ILog m_log =
|
private static readonly ILog m_log =
|
||||||
// LogManager.GetLogger(
|
LogManager.GetLogger(
|
||||||
// MethodBase.GetCurrentMethod().DeclaringType);
|
MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
public PasswordAuthenticationService(IConfigSource config) :
|
public PasswordAuthenticationService(IConfigSource config) :
|
||||||
base(config)
|
base(config)
|
||||||
|
@ -60,22 +60,26 @@ namespace OpenSim.Services.AuthenticationService
|
||||||
{
|
{
|
||||||
AuthenticationData data = m_Database.Get(principalID);
|
AuthenticationData data = m_Database.Get(principalID);
|
||||||
|
|
||||||
if (!data.Data.ContainsKey("passwordHash") ||
|
if (data != null && data.Data != null)
|
||||||
!data.Data.ContainsKey("passwordSalt"))
|
|
||||||
{
|
{
|
||||||
return String.Empty;
|
if (!data.Data.ContainsKey("passwordHash") ||
|
||||||
}
|
!data.Data.ContainsKey("passwordSalt"))
|
||||||
|
{
|
||||||
string hashed = Util.Md5Hash(password + ":" +
|
return String.Empty;
|
||||||
data.Data["passwordSalt"].ToString());
|
}
|
||||||
|
|
||||||
//m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
|
string hashed = Util.Md5Hash(password + ":" +
|
||||||
|
data.Data["passwordSalt"].ToString());
|
||||||
if (data.Data["passwordHash"].ToString() == hashed)
|
|
||||||
{
|
//m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
|
||||||
return GetToken(principalID, lifetime);
|
|
||||||
|
if (data.Data["passwordHash"].ToString() == hashed)
|
||||||
|
{
|
||||||
|
return GetToken(principalID, lifetime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue