mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Merge commit '4c9400e6460a73baa2d687afe73a62c6efca9f37' into bigmerge
Conflicts: OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
This commit is contained in:
@@ -46,9 +46,12 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
{
|
||||
public class AuthenticationServerPostHandler : BaseStreamHandler
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IAuthenticationService m_AuthenticationService;
|
||||
|
||||
private bool m_AllowGetAuthInfo = false;
|
||||
private bool m_AllowSetAuthInfo = false;
|
||||
private bool m_AllowSetPassword = false;
|
||||
|
||||
public AuthenticationServerPostHandler(IAuthenticationService service) :
|
||||
@@ -61,6 +64,8 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
m_AllowGetAuthInfo = config.GetBoolean("AllowGetAuthInfo", m_AllowGetAuthInfo);
|
||||
m_AllowSetAuthInfo = config.GetBoolean("AllowSetAuthInfo", m_AllowSetAuthInfo);
|
||||
m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword);
|
||||
}
|
||||
}
|
||||
@@ -161,6 +166,18 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
return SuccessResult();
|
||||
|
||||
return FailureResult();
|
||||
|
||||
case "getauthinfo":
|
||||
if (m_AllowGetAuthInfo)
|
||||
return GetAuthInfo(principalID);
|
||||
|
||||
break;
|
||||
|
||||
case "setauthinfo":
|
||||
if (m_AllowSetAuthInfo)
|
||||
return SetAuthInfo(principalID, request);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return FailureResult();
|
||||
@@ -193,6 +210,54 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
return DocToBytes(doc);
|
||||
}
|
||||
|
||||
byte[] GetAuthInfo(UUID principalID)
|
||||
{
|
||||
AuthInfo info = m_AuthenticationService.GetAuthInfo(principalID);
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
result["result"] = info.ToKeyValuePairs();
|
||||
|
||||
return ResultToBytes(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FailureResult();
|
||||
}
|
||||
}
|
||||
|
||||
byte[] SetAuthInfo(UUID principalID, Dictionary<string, object> request)
|
||||
{
|
||||
AuthInfo existingInfo = m_AuthenticationService.GetAuthInfo(principalID);
|
||||
|
||||
if (existingInfo == null)
|
||||
return FailureResult();
|
||||
|
||||
if (request.ContainsKey("AccountType"))
|
||||
existingInfo.AccountType = request["AccountType"].ToString();
|
||||
|
||||
if (request.ContainsKey("PasswordHash"))
|
||||
existingInfo.PasswordHash = request["PasswordHash"].ToString();
|
||||
|
||||
if (request.ContainsKey("PasswordSalt"))
|
||||
existingInfo.PasswordSalt = request["PasswordSalt"].ToString();
|
||||
|
||||
if (request.ContainsKey("WebLoginKey"))
|
||||
existingInfo.WebLoginKey = request["WebLoginKey"].ToString();
|
||||
|
||||
if (!m_AuthenticationService.SetAuthInfo(existingInfo))
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[AUTHENTICATION SERVER POST HANDLER]: Authentication info store failed for account {0} {1} {2}",
|
||||
existingInfo.PrincipalID);
|
||||
|
||||
return FailureResult();
|
||||
}
|
||||
|
||||
return SuccessResult();
|
||||
}
|
||||
|
||||
private byte[] FailureResult()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
@@ -252,5 +317,12 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
|
||||
return ms.GetBuffer();
|
||||
}
|
||||
|
||||
private byte[] ResultToBytes(Dictionary<string, object> result)
|
||||
{
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
return encoding.GetBytes(xmlString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +356,5 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
return encoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user