aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers')
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs74
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs2
2 files changed, 73 insertions, 3 deletions
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
index ae71945..4d1b0ff 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -46,9 +46,12 @@ namespace OpenSim.Server.Handlers.Authentication
46{ 46{
47 public class AuthenticationServerPostHandler : BaseStreamHandler 47 public class AuthenticationServerPostHandler : BaseStreamHandler
48 { 48 {
49 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private IAuthenticationService m_AuthenticationService; 51 private IAuthenticationService m_AuthenticationService;
52
53 private bool m_AllowGetAuthInfo = false;
54 private bool m_AllowSetAuthInfo = false;
52 private bool m_AllowSetPassword = false; 55 private bool m_AllowSetPassword = false;
53 56
54 public AuthenticationServerPostHandler(IAuthenticationService service) : 57 public AuthenticationServerPostHandler(IAuthenticationService service) :
@@ -61,6 +64,8 @@ namespace OpenSim.Server.Handlers.Authentication
61 64
62 if (config != null) 65 if (config != null)
63 { 66 {
67 m_AllowGetAuthInfo = config.GetBoolean("AllowGetAuthInfo", m_AllowGetAuthInfo);
68 m_AllowSetAuthInfo = config.GetBoolean("AllowSetAuthInfo", m_AllowSetAuthInfo);
64 m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword); 69 m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword);
65 } 70 }
66 } 71 }
@@ -161,6 +166,18 @@ namespace OpenSim.Server.Handlers.Authentication
161 return SuccessResult(); 166 return SuccessResult();
162 167
163 return FailureResult(); 168 return FailureResult();
169
170 case "getauthinfo":
171 if (m_AllowGetAuthInfo)
172 return GetAuthInfo(principalID);
173
174 break;
175
176 case "setauthinfo":
177 if (m_AllowSetAuthInfo)
178 return SetAuthInfo(principalID, request);
179
180 break;
164 } 181 }
165 182
166 return FailureResult(); 183 return FailureResult();
@@ -193,6 +210,54 @@ namespace OpenSim.Server.Handlers.Authentication
193 return DocToBytes(doc); 210 return DocToBytes(doc);
194 } 211 }
195 212
213 byte[] GetAuthInfo(UUID principalID)
214 {
215 AuthInfo info = m_AuthenticationService.GetAuthInfo(principalID);
216
217 if (info != null)
218 {
219 Dictionary<string, object> result = new Dictionary<string, object>();
220 result["result"] = info.ToKeyValuePairs();
221
222 return ResultToBytes(result);
223 }
224 else
225 {
226 return FailureResult();
227 }
228 }
229
230 byte[] SetAuthInfo(UUID principalID, Dictionary<string, object> request)
231 {
232 AuthInfo existingInfo = m_AuthenticationService.GetAuthInfo(principalID);
233
234 if (existingInfo == null)
235 return FailureResult();
236
237 if (request.ContainsKey("AccountType"))
238 existingInfo.AccountType = request["AccountType"].ToString();
239
240 if (request.ContainsKey("PasswordHash"))
241 existingInfo.PasswordHash = request["PasswordHash"].ToString();
242
243 if (request.ContainsKey("PasswordSalt"))
244 existingInfo.PasswordSalt = request["PasswordSalt"].ToString();
245
246 if (request.ContainsKey("WebLoginKey"))
247 existingInfo.WebLoginKey = request["WebLoginKey"].ToString();
248
249 if (!m_AuthenticationService.SetAuthInfo(existingInfo))
250 {
251 m_log.ErrorFormat(
252 "[AUTHENTICATION SERVER POST HANDLER]: Authentication info store failed for account {0} {1} {2}",
253 existingInfo.PrincipalID);
254
255 return FailureResult();
256 }
257
258 return SuccessResult();
259 }
260
196 private byte[] FailureResult() 261 private byte[] FailureResult()
197 { 262 {
198 XmlDocument doc = new XmlDocument(); 263 XmlDocument doc = new XmlDocument();
@@ -252,5 +317,12 @@ namespace OpenSim.Server.Handlers.Authentication
252 317
253 return ms.GetBuffer(); 318 return ms.GetBuffer();
254 } 319 }
320
321 private byte[] ResultToBytes(Dictionary<string, object> result)
322 {
323 string xmlString = ServerUtils.BuildXmlResponse(result);
324 UTF8Encoding encoding = new UTF8Encoding();
325 return encoding.GetBytes(xmlString);
326 }
255 } 327 }
256} 328}
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index f987383..5ab4caf 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -356,7 +356,5 @@ namespace OpenSim.Server.Handlers.UserAccounts
356 UTF8Encoding encoding = new UTF8Encoding(); 356 UTF8Encoding encoding = new UTF8Encoding();
357 return encoding.GetBytes(xmlString); 357 return encoding.GetBytes(xmlString);
358 } 358 }
359
360
361 } 359 }
362} 360}