aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs66
1 files changed, 59 insertions, 7 deletions
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index 21eb790..bc12ef9 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -72,9 +72,9 @@ namespace OpenSim.Server.Handlers.UserAccounts
72 protected override byte[] ProcessRequest(string path, Stream requestData, 72 protected override byte[] ProcessRequest(string path, Stream requestData,
73 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 73 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
74 { 74 {
75 StreamReader sr = new StreamReader(requestData); 75 string body;
76 string body = sr.ReadToEnd(); 76 using(StreamReader sr = new StreamReader(requestData))
77 sr.Close(); 77 body = sr.ReadToEnd();
78 body = body.Trim(); 78 body = body.Trim();
79 79
80 // We need to check the authorization header 80 // We need to check the authorization header
@@ -98,16 +98,18 @@ namespace OpenSim.Server.Handlers.UserAccounts
98 if (m_AllowCreateUser) 98 if (m_AllowCreateUser)
99 return CreateUser(request); 99 return CreateUser(request);
100 else 100 else
101 break; 101 return FailureResult();
102 case "getaccount": 102 case "getaccount":
103 return GetAccount(request); 103 return GetAccount(request);
104 case "getaccounts": 104 case "getaccounts":
105 return GetAccounts(request); 105 return GetAccounts(request);
106 case "getmultiaccounts":
107 return GetMultiAccounts(request);
106 case "setaccount": 108 case "setaccount":
107 if (m_AllowSetAccount) 109 if (m_AllowSetAccount)
108 return StoreAccount(request); 110 return StoreAccount(request);
109 else 111 else
110 break; 112 return FailureResult();
111 } 113 }
112 114
113 m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method); 115 m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method);
@@ -201,6 +203,52 @@ namespace OpenSim.Server.Handlers.UserAccounts
201 return Util.UTF8NoBomEncoding.GetBytes(xmlString); 203 return Util.UTF8NoBomEncoding.GetBytes(xmlString);
202 } 204 }
203 205
206 byte[] GetMultiAccounts(Dictionary<string, object> request)
207 {
208 UUID scopeID = UUID.Zero;
209 if (request.ContainsKey("ScopeID") && !UUID.TryParse(request["ScopeID"].ToString(), out scopeID))
210 return FailureResult();
211
212 if (!request.ContainsKey("IDS"))
213 {
214 m_log.DebugFormat("[USER SERVICE HANDLER]: GetMultiAccounts called without required uuids argument");
215 return FailureResult();
216 }
217
218 if (!(request["IDS"] is List<string>))
219 {
220 m_log.DebugFormat("[USER SERVICE HANDLER]: GetMultiAccounts input argument was of unexpected type {0}", request["IDS"].GetType().ToString());
221 return FailureResult();
222 }
223
224 List<string> userIDs = (List<string>)request["IDS"];
225
226 List<UserAccount> accounts = m_UserAccountService.GetUserAccounts(scopeID, userIDs);
227
228 Dictionary<string, object> result = new Dictionary<string, object>();
229 if ((accounts == null) || ((accounts != null) && (accounts.Count == 0)))
230 {
231 result["result"] = "null";
232 }
233 else
234 {
235 int i = 0;
236 foreach (UserAccount acc in accounts)
237 {
238 if(acc == null)
239 continue;
240 Dictionary<string, object> rinfoDict = acc.ToKeyValuePairs();
241 result["account" + i] = rinfoDict;
242 i++;
243 }
244 }
245
246 string xmlString = ServerUtils.BuildXmlResponse(result);
247
248 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
249 return Util.UTF8NoBomEncoding.GetBytes(xmlString);
250 }
251
204 byte[] StoreAccount(Dictionary<string, object> request) 252 byte[] StoreAccount(Dictionary<string, object> request)
205 { 253 {
206 UUID principalID = UUID.Zero; 254 UUID principalID = UUID.Zero;
@@ -280,12 +328,16 @@ namespace OpenSim.Server.Handlers.UserAccounts
280 if (request.ContainsKey("Email")) 328 if (request.ContainsKey("Email"))
281 email = request["Email"].ToString(); 329 email = request["Email"].ToString();
282 330
331 string model = "";
332 if (request.ContainsKey("Model"))
333 model = request["Model"].ToString();
334
283 UserAccount createdUserAccount = null; 335 UserAccount createdUserAccount = null;
284 336
285 if (m_UserAccountService is UserAccountService) 337 if (m_UserAccountService is UserAccountService)
286 createdUserAccount 338 createdUserAccount
287 = ((UserAccountService)m_UserAccountService).CreateUser( 339 = ((UserAccountService)m_UserAccountService).CreateUser(
288 scopeID, principalID, firstName, lastName, password, email); 340 scopeID, principalID, firstName, lastName, password, email, model);
289 341
290 if (createdUserAccount == null) 342 if (createdUserAccount == null)
291 return FailureResult(); 343 return FailureResult();
@@ -345,4 +397,4 @@ namespace OpenSim.Server.Handlers.UserAccounts
345 return Util.UTF8NoBomEncoding.GetBytes(xmlString); 397 return Util.UTF8NoBomEncoding.GetBytes(xmlString);
346 } 398 }
347 } 399 }
348} \ No newline at end of file 400}