diff options
Switched in NameSpaceChanges
Diffstat (limited to 'OpenSim/Framework/UserManager')
4 files changed, 1455 insertions, 0 deletions
diff --git a/OpenSim/Framework/UserManager/LoginResponse.cs b/OpenSim/Framework/UserManager/LoginResponse.cs new file mode 100644 index 0000000..d1cd8cf --- /dev/null +++ b/OpenSim/Framework/UserManager/LoginResponse.cs | |||
@@ -0,0 +1,646 @@ | |||
1 | using System; | ||
2 | using System.Text; | ||
3 | using System.Text.RegularExpressions; | ||
4 | using System.Threading; | ||
5 | using System.Collections; | ||
6 | using System.Xml; | ||
7 | using libsecondlife; | ||
8 | using OpenSim.Framework.Utilities; | ||
9 | using OpenSim.Framework.Interfaces; | ||
10 | using Nwc.XmlRpc; | ||
11 | |||
12 | namespace OpenSim.Framework.UserManagement | ||
13 | { | ||
14 | |||
15 | /// <summary> | ||
16 | /// A temp class to handle login response. | ||
17 | /// Should make use of UserProfileManager where possible. | ||
18 | /// </summary> | ||
19 | |||
20 | public class LoginResponse | ||
21 | { | ||
22 | private Hashtable loginFlagsHash; | ||
23 | private Hashtable globalTexturesHash; | ||
24 | private Hashtable loginError; | ||
25 | private Hashtable eventCategoriesHash; | ||
26 | private Hashtable uiConfigHash; | ||
27 | private Hashtable classifiedCategoriesHash; | ||
28 | |||
29 | private ArrayList loginFlags; | ||
30 | private ArrayList globalTextures; | ||
31 | private ArrayList eventCategories; | ||
32 | private ArrayList uiConfig; | ||
33 | private ArrayList classifiedCategories; | ||
34 | private ArrayList inventoryRoot; | ||
35 | private ArrayList initialOutfit; | ||
36 | private ArrayList agentInventory; | ||
37 | |||
38 | private UserInfo userProfile; | ||
39 | |||
40 | private LLUUID agentID; | ||
41 | private LLUUID sessionID; | ||
42 | private LLUUID secureSessionID; | ||
43 | |||
44 | // Login Flags | ||
45 | private string dst; | ||
46 | private string stipendSinceLogin; | ||
47 | private string gendered; | ||
48 | private string everLoggedIn; | ||
49 | private string login; | ||
50 | private int simPort; | ||
51 | private string simAddress; | ||
52 | private string agentAccess; | ||
53 | private Int32 circuitCode; | ||
54 | private uint regionX; | ||
55 | private uint regionY; | ||
56 | |||
57 | // Login | ||
58 | private string firstname; | ||
59 | private string lastname; | ||
60 | |||
61 | // Global Textures | ||
62 | private string sunTexture; | ||
63 | private string cloudTexture; | ||
64 | private string moonTexture; | ||
65 | |||
66 | // Error Flags | ||
67 | private string errorReason; | ||
68 | private string errorMessage; | ||
69 | |||
70 | // Response | ||
71 | private XmlRpcResponse xmlRpcResponse; | ||
72 | private XmlRpcResponse defaultXmlRpcResponse; | ||
73 | |||
74 | private string welcomeMessage; | ||
75 | private string startLocation; | ||
76 | private string allowFirstLife; | ||
77 | private string home; | ||
78 | private string seedCapability; | ||
79 | private string lookAt; | ||
80 | |||
81 | public LoginResponse() | ||
82 | { | ||
83 | this.loginFlags = new ArrayList(); | ||
84 | this.globalTextures = new ArrayList(); | ||
85 | this.eventCategories = new ArrayList(); | ||
86 | this.uiConfig = new ArrayList(); | ||
87 | this.classifiedCategories = new ArrayList(); | ||
88 | |||
89 | this.loginError = new Hashtable(); | ||
90 | this.eventCategoriesHash = new Hashtable(); | ||
91 | this.classifiedCategoriesHash = new Hashtable(); | ||
92 | this.uiConfigHash = new Hashtable(); | ||
93 | |||
94 | this.defaultXmlRpcResponse = new XmlRpcResponse(); | ||
95 | this.userProfile = new UserInfo(); | ||
96 | this.inventoryRoot = new ArrayList(); | ||
97 | this.initialOutfit = new ArrayList(); | ||
98 | this.agentInventory = new ArrayList(); | ||
99 | |||
100 | this.xmlRpcResponse = new XmlRpcResponse(); | ||
101 | this.defaultXmlRpcResponse = new XmlRpcResponse(); | ||
102 | |||
103 | this.SetDefaultValues(); | ||
104 | } // LoginServer | ||
105 | |||
106 | public void SetDefaultValues() | ||
107 | { | ||
108 | this.DST = "N"; | ||
109 | this.StipendSinceLogin = "N"; | ||
110 | this.Gendered = "Y"; | ||
111 | this.EverLoggedIn = "Y"; | ||
112 | this.login = "false"; | ||
113 | this.firstname = "Test"; | ||
114 | this.lastname = "User"; | ||
115 | this.agentAccess = "M"; | ||
116 | this.startLocation = "last"; | ||
117 | this.allowFirstLife = "Y"; | ||
118 | |||
119 | this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
120 | this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
121 | this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
122 | |||
123 | this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; | ||
124 | this.ErrorReason = "key"; | ||
125 | this.welcomeMessage = "Welcome to OpenSim!"; | ||
126 | this.seedCapability = ""; | ||
127 | this.home = "{'region_handle':[r" + (1000 * 256).ToString() + ",r" + (1000 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}"; | ||
128 | this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; | ||
129 | this.RegionX = (uint)255232; | ||
130 | this.RegionY = (uint)254976; | ||
131 | |||
132 | // Classifieds; | ||
133 | this.AddClassifiedCategory((Int32)1, "Shopping"); | ||
134 | this.AddClassifiedCategory((Int32)2, "Land Rental"); | ||
135 | this.AddClassifiedCategory((Int32)3, "Property Rental"); | ||
136 | this.AddClassifiedCategory((Int32)4, "Special Attraction"); | ||
137 | this.AddClassifiedCategory((Int32)5, "New Products"); | ||
138 | this.AddClassifiedCategory((Int32)6, "Employment"); | ||
139 | this.AddClassifiedCategory((Int32)7, "Wanted"); | ||
140 | this.AddClassifiedCategory((Int32)8, "Service"); | ||
141 | this.AddClassifiedCategory((Int32)9, "Personal"); | ||
142 | |||
143 | |||
144 | this.SessionID = LLUUID.Random(); | ||
145 | this.SecureSessionID = LLUUID.Random(); | ||
146 | this.AgentID = LLUUID.Random(); | ||
147 | |||
148 | Hashtable InitialOutfitHash = new Hashtable(); | ||
149 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
150 | InitialOutfitHash["gender"] = "female"; | ||
151 | this.initialOutfit.Add(InitialOutfitHash); | ||
152 | |||
153 | |||
154 | } // SetDefaultValues | ||
155 | |||
156 | #region Login Failure Methods | ||
157 | public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) | ||
158 | { | ||
159 | // Overwrite any default values; | ||
160 | this.xmlRpcResponse = new XmlRpcResponse(); | ||
161 | |||
162 | // Ensure Login Failed message/reason; | ||
163 | this.ErrorMessage = message; | ||
164 | this.ErrorReason = reason; | ||
165 | |||
166 | this.loginError["reason"] = this.ErrorReason; | ||
167 | this.loginError["message"] = this.ErrorMessage; | ||
168 | this.loginError["login"] = login; | ||
169 | this.xmlRpcResponse.Value = this.loginError; | ||
170 | return (this.xmlRpcResponse); | ||
171 | } // GenerateResponse | ||
172 | |||
173 | public XmlRpcResponse CreateFailedResponse() | ||
174 | { | ||
175 | return (this.CreateLoginFailedResponse()); | ||
176 | } // CreateErrorConnectingToGridResponse() | ||
177 | |||
178 | public XmlRpcResponse CreateLoginFailedResponse() | ||
179 | { | ||
180 | return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false")); | ||
181 | } // LoginFailedResponse | ||
182 | |||
183 | public XmlRpcResponse CreateAlreadyLoggedInResponse() | ||
184 | { | ||
185 | return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false")); | ||
186 | } // CreateAlreadyLoggedInResponse() | ||
187 | |||
188 | public XmlRpcResponse CreateDeadRegionResponse() | ||
189 | { | ||
190 | return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false")); | ||
191 | } | ||
192 | |||
193 | public XmlRpcResponse CreateGridErrorResponse() | ||
194 | { | ||
195 | return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false")); | ||
196 | } | ||
197 | |||
198 | #endregion | ||
199 | |||
200 | public XmlRpcResponse ToXmlRpcResponse() | ||
201 | { | ||
202 | try | ||
203 | { | ||
204 | |||
205 | Hashtable responseData = new Hashtable(); | ||
206 | |||
207 | this.loginFlagsHash = new Hashtable(); | ||
208 | this.loginFlagsHash["daylight_savings"] = this.DST; | ||
209 | this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin; | ||
210 | this.loginFlagsHash["gendered"] = this.Gendered; | ||
211 | this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn; | ||
212 | this.loginFlags.Add(this.loginFlagsHash); | ||
213 | |||
214 | responseData["first_name"] = this.Firstname; | ||
215 | responseData["last_name"] = this.Lastname; | ||
216 | responseData["agent_access"] = this.agentAccess; | ||
217 | |||
218 | this.globalTexturesHash = new Hashtable(); | ||
219 | this.globalTexturesHash["sun_texture_id"] = this.SunTexture; | ||
220 | this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture; | ||
221 | this.globalTexturesHash["moon_texture_id"] = this.MoonTexture; | ||
222 | this.globalTextures.Add(this.globalTexturesHash); | ||
223 | this.eventCategories.Add(this.eventCategoriesHash); | ||
224 | |||
225 | this.AddToUIConfig("allow_first_life", this.allowFirstLife); | ||
226 | this.uiConfig.Add(this.uiConfigHash); | ||
227 | |||
228 | responseData["sim_port"] =(Int32) this.SimPort; | ||
229 | responseData["sim_ip"] = this.SimAddress; | ||
230 | Console.MainLog.Instance.Warn("SIM IP: " + responseData["sim_ip"] + "; SIM PORT: " + responseData["sim_port"]); | ||
231 | responseData["agent_id"] = this.AgentID.ToStringHyphenated(); | ||
232 | responseData["session_id"] = this.SessionID.ToStringHyphenated(); | ||
233 | responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated(); | ||
234 | responseData["circuit_code"] = this.CircuitCode; | ||
235 | responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
236 | responseData["login-flags"] = this.loginFlags; | ||
237 | responseData["global-textures"] = this.globalTextures; | ||
238 | responseData["seed_capability"] = this.seedCapability; | ||
239 | |||
240 | responseData["event_categories"] = this.eventCategories; | ||
241 | responseData["event_notifications"] = new ArrayList(); // todo | ||
242 | responseData["classified_categories"] = this.classifiedCategories; | ||
243 | responseData["ui-config"] = this.uiConfig; | ||
244 | |||
245 | responseData["inventory-skeleton"] = this.agentInventory; | ||
246 | responseData["inventory-skel-lib"] = new ArrayList(); // todo | ||
247 | responseData["inventory-root"] = this.inventoryRoot; | ||
248 | responseData["gestures"] = new ArrayList(); // todo | ||
249 | responseData["inventory-lib-owner"] = new ArrayList(); // todo | ||
250 | responseData["initial-outfit"] = this.initialOutfit; | ||
251 | responseData["start_location"] = this.startLocation; | ||
252 | responseData["seed_capability"] = this.seedCapability; | ||
253 | responseData["home"] = this.home; | ||
254 | responseData["look_at"] = this.lookAt; | ||
255 | responseData["message"] = this.welcomeMessage; | ||
256 | responseData["region_x"] = (Int32)this.RegionX * 256; | ||
257 | responseData["region_y"] = (Int32)this.RegionY * 256; | ||
258 | |||
259 | //responseData["inventory-lib-root"] = new ArrayList(); // todo | ||
260 | //responseData["buddy-list"] = new ArrayList(); // todo | ||
261 | |||
262 | responseData["login"] = "true"; | ||
263 | this.xmlRpcResponse.Value = responseData; | ||
264 | |||
265 | return (this.xmlRpcResponse); | ||
266 | } | ||
267 | catch (Exception e) | ||
268 | { | ||
269 | OpenSim.Framework.Console.MainLog.Instance.WriteLine( | ||
270 | OpenSim.Framework.Console.LogPriority.LOW, | ||
271 | "LoginResponse: Error creating XML-RPC Response: " + e.Message | ||
272 | ); | ||
273 | return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); | ||
274 | |||
275 | } | ||
276 | |||
277 | } // ToXmlRpcResponse | ||
278 | |||
279 | public void SetEventCategories(string category, string value) | ||
280 | { | ||
281 | this.eventCategoriesHash[category] = value; | ||
282 | } // SetEventCategories | ||
283 | |||
284 | public void AddToUIConfig(string itemName, string item) | ||
285 | { | ||
286 | this.uiConfigHash[itemName] = item; | ||
287 | } // SetUIConfig | ||
288 | |||
289 | public void AddClassifiedCategory(Int32 ID, string categoryName) | ||
290 | { | ||
291 | this.classifiedCategoriesHash["category_name"] = categoryName; | ||
292 | this.classifiedCategoriesHash["category_id"] = ID; | ||
293 | this.classifiedCategories.Add(this.classifiedCategoriesHash); | ||
294 | // this.classifiedCategoriesHash.Clear(); | ||
295 | } // SetClassifiedCategory | ||
296 | |||
297 | #region Properties | ||
298 | public string Login | ||
299 | { | ||
300 | get | ||
301 | { | ||
302 | return this.login; | ||
303 | } | ||
304 | set | ||
305 | { | ||
306 | this.login = value; | ||
307 | } | ||
308 | } // Login | ||
309 | |||
310 | public string DST | ||
311 | { | ||
312 | get | ||
313 | { | ||
314 | return this.dst; | ||
315 | } | ||
316 | set | ||
317 | { | ||
318 | this.dst = value; | ||
319 | } | ||
320 | } // DST | ||
321 | |||
322 | public string StipendSinceLogin | ||
323 | { | ||
324 | get | ||
325 | { | ||
326 | return this.stipendSinceLogin; | ||
327 | } | ||
328 | set | ||
329 | { | ||
330 | this.stipendSinceLogin = value; | ||
331 | } | ||
332 | } // StipendSinceLogin | ||
333 | |||
334 | public string Gendered | ||
335 | { | ||
336 | get | ||
337 | { | ||
338 | return this.gendered; | ||
339 | } | ||
340 | set | ||
341 | { | ||
342 | this.gendered = value; | ||
343 | } | ||
344 | } // Gendered | ||
345 | |||
346 | public string EverLoggedIn | ||
347 | { | ||
348 | get | ||
349 | { | ||
350 | return this.everLoggedIn; | ||
351 | } | ||
352 | set | ||
353 | { | ||
354 | this.everLoggedIn = value; | ||
355 | } | ||
356 | } // EverLoggedIn | ||
357 | |||
358 | public int SimPort | ||
359 | { | ||
360 | get | ||
361 | { | ||
362 | return this.simPort; | ||
363 | } | ||
364 | set | ||
365 | { | ||
366 | this.simPort = value; | ||
367 | } | ||
368 | } // SimPort | ||
369 | |||
370 | public string SimAddress | ||
371 | { | ||
372 | get | ||
373 | { | ||
374 | return this.simAddress; | ||
375 | } | ||
376 | set | ||
377 | { | ||
378 | this.simAddress = value; | ||
379 | } | ||
380 | } // SimAddress | ||
381 | |||
382 | public LLUUID AgentID | ||
383 | { | ||
384 | get | ||
385 | { | ||
386 | return this.agentID; | ||
387 | } | ||
388 | set | ||
389 | { | ||
390 | this.agentID = value; | ||
391 | } | ||
392 | } // AgentID | ||
393 | |||
394 | public LLUUID SessionID | ||
395 | { | ||
396 | get | ||
397 | { | ||
398 | return this.sessionID; | ||
399 | } | ||
400 | set | ||
401 | { | ||
402 | this.sessionID = value; | ||
403 | } | ||
404 | } // SessionID | ||
405 | |||
406 | public LLUUID SecureSessionID | ||
407 | { | ||
408 | get | ||
409 | { | ||
410 | return this.secureSessionID; | ||
411 | } | ||
412 | set | ||
413 | { | ||
414 | this.secureSessionID = value; | ||
415 | } | ||
416 | } // SecureSessionID | ||
417 | |||
418 | public Int32 CircuitCode | ||
419 | { | ||
420 | get | ||
421 | { | ||
422 | return this.circuitCode; | ||
423 | } | ||
424 | set | ||
425 | { | ||
426 | this.circuitCode = value; | ||
427 | } | ||
428 | } // CircuitCode | ||
429 | |||
430 | public uint RegionX | ||
431 | { | ||
432 | get | ||
433 | { | ||
434 | return this.regionX; | ||
435 | } | ||
436 | set | ||
437 | { | ||
438 | this.regionX = value; | ||
439 | } | ||
440 | } // RegionX | ||
441 | |||
442 | public uint RegionY | ||
443 | { | ||
444 | get | ||
445 | { | ||
446 | return this.regionY; | ||
447 | } | ||
448 | set | ||
449 | { | ||
450 | this.regionY = value; | ||
451 | } | ||
452 | } // RegionY | ||
453 | |||
454 | public string SunTexture | ||
455 | { | ||
456 | get | ||
457 | { | ||
458 | return this.sunTexture; | ||
459 | } | ||
460 | set | ||
461 | { | ||
462 | this.sunTexture = value; | ||
463 | } | ||
464 | } // SunTexture | ||
465 | |||
466 | public string CloudTexture | ||
467 | { | ||
468 | get | ||
469 | { | ||
470 | return this.cloudTexture; | ||
471 | } | ||
472 | set | ||
473 | { | ||
474 | this.cloudTexture = value; | ||
475 | } | ||
476 | } // CloudTexture | ||
477 | |||
478 | public string MoonTexture | ||
479 | { | ||
480 | get | ||
481 | { | ||
482 | return this.moonTexture; | ||
483 | } | ||
484 | set | ||
485 | { | ||
486 | this.moonTexture = value; | ||
487 | } | ||
488 | } // MoonTexture | ||
489 | |||
490 | public string Firstname | ||
491 | { | ||
492 | get | ||
493 | { | ||
494 | return this.firstname; | ||
495 | } | ||
496 | set | ||
497 | { | ||
498 | this.firstname = value; | ||
499 | } | ||
500 | } // Firstname | ||
501 | |||
502 | public string Lastname | ||
503 | { | ||
504 | get | ||
505 | { | ||
506 | return this.lastname; | ||
507 | } | ||
508 | set | ||
509 | { | ||
510 | this.lastname = value; | ||
511 | } | ||
512 | } // Lastname | ||
513 | |||
514 | public string AgentAccess | ||
515 | { | ||
516 | get | ||
517 | { | ||
518 | return this.agentAccess; | ||
519 | } | ||
520 | set | ||
521 | { | ||
522 | this.agentAccess = value; | ||
523 | } | ||
524 | } | ||
525 | |||
526 | public string StartLocation | ||
527 | { | ||
528 | get | ||
529 | { | ||
530 | return this.startLocation; | ||
531 | } | ||
532 | set | ||
533 | { | ||
534 | this.startLocation = value; | ||
535 | } | ||
536 | } // StartLocation | ||
537 | |||
538 | public string LookAt | ||
539 | { | ||
540 | get | ||
541 | { | ||
542 | return this.lookAt; | ||
543 | } | ||
544 | set | ||
545 | { | ||
546 | this.lookAt = value; | ||
547 | } | ||
548 | } | ||
549 | |||
550 | public string SeedCapability | ||
551 | { | ||
552 | get | ||
553 | { | ||
554 | return this.seedCapability; | ||
555 | } | ||
556 | set | ||
557 | { | ||
558 | this.seedCapability = value; | ||
559 | } | ||
560 | } // SeedCapability | ||
561 | |||
562 | public string ErrorReason | ||
563 | { | ||
564 | get | ||
565 | { | ||
566 | return this.errorReason; | ||
567 | } | ||
568 | set | ||
569 | { | ||
570 | this.errorReason = value; | ||
571 | } | ||
572 | } // ErrorReason | ||
573 | |||
574 | public string ErrorMessage | ||
575 | { | ||
576 | get | ||
577 | { | ||
578 | return this.errorMessage; | ||
579 | } | ||
580 | set | ||
581 | { | ||
582 | this.errorMessage = value; | ||
583 | } | ||
584 | } // ErrorMessage | ||
585 | |||
586 | public ArrayList InventoryRoot | ||
587 | { | ||
588 | get | ||
589 | { | ||
590 | return this.inventoryRoot; | ||
591 | } | ||
592 | set | ||
593 | { | ||
594 | this.inventoryRoot = value; | ||
595 | } | ||
596 | } | ||
597 | |||
598 | public ArrayList InventorySkeleton | ||
599 | { | ||
600 | get | ||
601 | { | ||
602 | return this.agentInventory; | ||
603 | } | ||
604 | set | ||
605 | { | ||
606 | this.agentInventory = value; | ||
607 | } | ||
608 | } | ||
609 | |||
610 | public string Home | ||
611 | { | ||
612 | get | ||
613 | { | ||
614 | return this.home; | ||
615 | } | ||
616 | set | ||
617 | { | ||
618 | this.home = value; | ||
619 | } | ||
620 | } | ||
621 | |||
622 | public string Message | ||
623 | { | ||
624 | get | ||
625 | { | ||
626 | return this.welcomeMessage; | ||
627 | } | ||
628 | set | ||
629 | { | ||
630 | this.welcomeMessage = value; | ||
631 | } | ||
632 | } | ||
633 | #endregion | ||
634 | |||
635 | |||
636 | public class UserInfo | ||
637 | { | ||
638 | public string firstname; | ||
639 | public string lastname; | ||
640 | public ulong homeregionhandle; | ||
641 | public LLVector3 homepos; | ||
642 | public LLVector3 homelookat; | ||
643 | } | ||
644 | } | ||
645 | } | ||
646 | |||
diff --git a/OpenSim/Framework/UserManager/OpenSim.Framework.UserManagement.csproj b/OpenSim/Framework/UserManager/OpenSim.Framework.UserManagement.csproj new file mode 100644 index 0000000..02aa3f3 --- /dev/null +++ b/OpenSim/Framework/UserManager/OpenSim.Framework.UserManagement.csproj | |||
@@ -0,0 +1,125 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{586E2916-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenSim.Framework.UserManagement</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.Framework.UserManagement</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="Db4objects.Db4o.dll" > | ||
62 | <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="libsecondlife.dll" > | ||
66 | <HintPath>..\..\..\bin\libsecondlife.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="OpenSim.Framework" > | ||
70 | <HintPath>OpenSim.Framework.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | <Reference Include="OpenSim.Framework.Console" > | ||
74 | <HintPath>OpenSim.Framework.Console.dll</HintPath> | ||
75 | <Private>False</Private> | ||
76 | </Reference> | ||
77 | <Reference Include="OpenSim.Framework.GenericConfig.Xml" > | ||
78 | <HintPath>OpenSim.Framework.GenericConfig.Xml.dll</HintPath> | ||
79 | <Private>False</Private> | ||
80 | </Reference> | ||
81 | <Reference Include="OpenSim.Framework.Servers" > | ||
82 | <HintPath>OpenSim.Framework.Servers.dll</HintPath> | ||
83 | <Private>False</Private> | ||
84 | </Reference> | ||
85 | <Reference Include="System" > | ||
86 | <HintPath>System.dll</HintPath> | ||
87 | <Private>False</Private> | ||
88 | </Reference> | ||
89 | <Reference Include="System.Data" > | ||
90 | <HintPath>System.Data.dll</HintPath> | ||
91 | <Private>False</Private> | ||
92 | </Reference> | ||
93 | <Reference Include="System.Xml" > | ||
94 | <HintPath>System.Xml.dll</HintPath> | ||
95 | <Private>False</Private> | ||
96 | </Reference> | ||
97 | <Reference Include="XMLRPC.dll" > | ||
98 | <HintPath>..\..\..\bin\XMLRPC.dll</HintPath> | ||
99 | <Private>False</Private> | ||
100 | </Reference> | ||
101 | </ItemGroup> | ||
102 | <ItemGroup> | ||
103 | <ProjectReference Include="..\Data\OpenSim.Framework.Data.csproj"> | ||
104 | <Name>OpenSim.Framework.Data</Name> | ||
105 | <Project>{36B72A9B-0000-0000-0000-000000000000}</Project> | ||
106 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
107 | <Private>False</Private> | ||
108 | </ProjectReference> | ||
109 | </ItemGroup> | ||
110 | <ItemGroup> | ||
111 | <Compile Include="LoginResponse.cs"> | ||
112 | <SubType>Code</SubType> | ||
113 | </Compile> | ||
114 | <Compile Include="UserManagerBase.cs"> | ||
115 | <SubType>Code</SubType> | ||
116 | </Compile> | ||
117 | </ItemGroup> | ||
118 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
119 | <PropertyGroup> | ||
120 | <PreBuildEvent> | ||
121 | </PreBuildEvent> | ||
122 | <PostBuildEvent> | ||
123 | </PostBuildEvent> | ||
124 | </PropertyGroup> | ||
125 | </Project> | ||
diff --git a/OpenSim/Framework/UserManager/OpenSim.Framework.UserManagement.dll.build b/OpenSim/Framework/UserManager/OpenSim.Framework.UserManagement.dll.build new file mode 100644 index 0000000..d2f4345 --- /dev/null +++ b/OpenSim/Framework/UserManager/OpenSim.Framework.UserManagement.dll.build | |||
@@ -0,0 +1,50 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenSim.Framework.UserManagement" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenSim.Framework.UserManagement" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="LoginResponse.cs" /> | ||
15 | <include name="UserManagerBase.cs" /> | ||
16 | </sources> | ||
17 | <references basedir="${project::get-base-directory()}"> | ||
18 | <lib> | ||
19 | <include name="${project::get-base-directory()}" /> | ||
20 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
21 | </lib> | ||
22 | <include name="../../../bin/Db4objects.Db4o.dll" /> | ||
23 | <include name="../../../bin/libsecondlife.dll" /> | ||
24 | <include name="OpenSim.Framework.dll" /> | ||
25 | <include name="OpenSim.Framework.Console.dll" /> | ||
26 | <include name="../../../bin/OpenSim.Framework.Data.dll" /> | ||
27 | <include name="OpenSim.Framework.GenericConfig.Xml.dll" /> | ||
28 | <include name="OpenSim.Framework.Servers.dll" /> | ||
29 | <include name="System.dll" /> | ||
30 | <include name="System.Data.dll" /> | ||
31 | <include name="System.Xml.dll" /> | ||
32 | <include name="../../../bin/XMLRPC.dll" /> | ||
33 | </references> | ||
34 | </csc> | ||
35 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" /> | ||
36 | <mkdir dir="${project::get-base-directory()}/../../../bin/"/> | ||
37 | <copy todir="${project::get-base-directory()}/../../../bin/"> | ||
38 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
39 | <include name="*.dll"/> | ||
40 | <include name="*.exe"/> | ||
41 | </fileset> | ||
42 | </copy> | ||
43 | </target> | ||
44 | <target name="clean"> | ||
45 | <delete dir="${bin.dir}" failonerror="false" /> | ||
46 | <delete dir="${obj.dir}" failonerror="false" /> | ||
47 | </target> | ||
48 | <target name="doc" description="Creates documentation."> | ||
49 | </target> | ||
50 | </project> | ||
diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs new file mode 100644 index 0000000..d06059e --- /dev/null +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs | |||
@@ -0,0 +1,634 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using OpenSim.Framework.Data; | ||
33 | using libsecondlife; | ||
34 | using System.Reflection; | ||
35 | |||
36 | using System.Xml; | ||
37 | using Nwc.XmlRpc; | ||
38 | using OpenSim.Framework.Sims; | ||
39 | using OpenSim.Framework.Inventory; | ||
40 | using OpenSim.Framework.Utilities; | ||
41 | |||
42 | using System.Security.Cryptography; | ||
43 | |||
44 | namespace OpenSim.Framework.UserManagement | ||
45 | { | ||
46 | public class UserManagerBase | ||
47 | { | ||
48 | public OpenSim.Framework.Interfaces.UserConfig _config; | ||
49 | Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>(); | ||
50 | |||
51 | /// <summary> | ||
52 | /// Adds a new user server plugin - user servers will be requested in the order they were loaded. | ||
53 | /// </summary> | ||
54 | /// <param name="FileName">The filename to the user server plugin DLL</param> | ||
55 | public void AddPlugin(string FileName) | ||
56 | { | ||
57 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Attempting to load " + FileName); | ||
58 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
59 | |||
60 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | ||
61 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
62 | { | ||
63 | if (!pluginType.IsAbstract) | ||
64 | { | ||
65 | Type typeInterface = pluginType.GetInterface("IUserData", true); | ||
66 | |||
67 | if (typeInterface != null) | ||
68 | { | ||
69 | IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
70 | plug.Initialise(); | ||
71 | this._plugins.Add(plug.getName(), plug); | ||
72 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface"); | ||
73 | } | ||
74 | |||
75 | typeInterface = null; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | pluginAssembly = null; | ||
80 | } | ||
81 | |||
82 | #region Get UserProfile | ||
83 | /// <summary> | ||
84 | /// Loads a user profile from a database by UUID | ||
85 | /// </summary> | ||
86 | /// <param name="uuid">The target UUID</param> | ||
87 | /// <returns>A user profile</returns> | ||
88 | public UserProfileData getUserProfile(LLUUID uuid) | ||
89 | { | ||
90 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
91 | { | ||
92 | try | ||
93 | { | ||
94 | UserProfileData profile = plugin.Value.getUserByUUID(uuid); | ||
95 | profile.currentAgent = getUserAgent(profile.UUID); | ||
96 | return profile; | ||
97 | } | ||
98 | catch (Exception e) | ||
99 | { | ||
100 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | return null; | ||
105 | } | ||
106 | |||
107 | |||
108 | /// <summary> | ||
109 | /// Loads a user profile by name | ||
110 | /// </summary> | ||
111 | /// <param name="name">The target name</param> | ||
112 | /// <returns>A user profile</returns> | ||
113 | public UserProfileData getUserProfile(string name) | ||
114 | { | ||
115 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
116 | { | ||
117 | try | ||
118 | { | ||
119 | UserProfileData profile = plugin.Value.getUserByName(name); | ||
120 | profile.currentAgent = getUserAgent(profile.UUID); | ||
121 | return profile; | ||
122 | } | ||
123 | catch (Exception e) | ||
124 | { | ||
125 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | return null; | ||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// Loads a user profile by name | ||
134 | /// </summary> | ||
135 | /// <param name="fname">First name</param> | ||
136 | /// <param name="lname">Last name</param> | ||
137 | /// <returns>A user profile</returns> | ||
138 | public UserProfileData getUserProfile(string fname, string lname) | ||
139 | { | ||
140 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
141 | { | ||
142 | try | ||
143 | { | ||
144 | UserProfileData profile = plugin.Value.getUserByName(fname,lname); | ||
145 | try | ||
146 | { | ||
147 | profile.currentAgent = getUserAgent(profile.UUID); | ||
148 | } | ||
149 | catch (Exception e) | ||
150 | { | ||
151 | // Ignore | ||
152 | } | ||
153 | return profile; | ||
154 | } | ||
155 | catch (Exception e) | ||
156 | { | ||
157 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | return null; | ||
162 | } | ||
163 | #endregion | ||
164 | |||
165 | #region Get UserAgent | ||
166 | /// <summary> | ||
167 | /// Loads a user agent by uuid (not called directly) | ||
168 | /// </summary> | ||
169 | /// <param name="uuid">The agents UUID</param> | ||
170 | /// <returns>Agent profiles</returns> | ||
171 | public UserAgentData getUserAgent(LLUUID uuid) | ||
172 | { | ||
173 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
174 | { | ||
175 | try | ||
176 | { | ||
177 | return plugin.Value.getAgentByUUID(uuid); | ||
178 | } | ||
179 | catch (Exception e) | ||
180 | { | ||
181 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | return null; | ||
186 | } | ||
187 | |||
188 | /// <summary> | ||
189 | /// Loads a user agent by name (not called directly) | ||
190 | /// </summary> | ||
191 | /// <param name="name">The agents name</param> | ||
192 | /// <returns>A user agent</returns> | ||
193 | public UserAgentData getUserAgent(string name) | ||
194 | { | ||
195 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
196 | { | ||
197 | try | ||
198 | { | ||
199 | return plugin.Value.getAgentByName(name); | ||
200 | } | ||
201 | catch (Exception e) | ||
202 | { | ||
203 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | return null; | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Loads a user agent by name (not called directly) | ||
212 | /// </summary> | ||
213 | /// <param name="fname">The agents firstname</param> | ||
214 | /// <param name="lname">The agents lastname</param> | ||
215 | /// <returns>A user agent</returns> | ||
216 | public UserAgentData getUserAgent(string fname, string lname) | ||
217 | { | ||
218 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
219 | { | ||
220 | try | ||
221 | { | ||
222 | return plugin.Value.getAgentByName(fname,lname); | ||
223 | } | ||
224 | catch (Exception e) | ||
225 | { | ||
226 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | return null; | ||
231 | } | ||
232 | |||
233 | #endregion | ||
234 | |||
235 | #region CreateAgent | ||
236 | /// <summary> | ||
237 | /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB | ||
238 | /// </summary> | ||
239 | /// <param name="profile">The users profile</param> | ||
240 | /// <param name="request">The users loginrequest</param> | ||
241 | public void CreateAgent(ref UserProfileData profile, XmlRpcRequest request) | ||
242 | { | ||
243 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
244 | |||
245 | UserAgentData agent = new UserAgentData(); | ||
246 | |||
247 | // User connection | ||
248 | agent.agentIP = ""; | ||
249 | agent.agentOnline = true; | ||
250 | agent.agentPort = 0; | ||
251 | |||
252 | // Generate sessions | ||
253 | RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); | ||
254 | byte[] randDataS = new byte[16]; | ||
255 | byte[] randDataSS = new byte[16]; | ||
256 | rand.GetBytes(randDataS); | ||
257 | rand.GetBytes(randDataSS); | ||
258 | |||
259 | agent.secureSessionID = new LLUUID(randDataSS, 0); | ||
260 | agent.sessionID = new LLUUID(randDataS, 0); | ||
261 | |||
262 | // Profile UUID | ||
263 | agent.UUID = profile.UUID; | ||
264 | |||
265 | // Current position (from Home) | ||
266 | agent.currentHandle = profile.homeRegion; | ||
267 | agent.currentPos = profile.homeLocation; | ||
268 | |||
269 | // If user specified additional start, use that | ||
270 | if (requestData.ContainsKey("start")) | ||
271 | { | ||
272 | string startLoc = ((string)requestData["start"]).Trim(); | ||
273 | if (!(startLoc == "last" || startLoc == "home")) | ||
274 | { | ||
275 | // Format: uri:Ahern&162&213&34 | ||
276 | try | ||
277 | { | ||
278 | string[] parts = startLoc.Remove(0, 4).Split('&'); | ||
279 | string region = parts[0]; | ||
280 | |||
281 | //////////////////////////////////////////////////// | ||
282 | //SimProfile SimInfo = new SimProfile(); | ||
283 | //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); | ||
284 | } | ||
285 | catch (Exception e) | ||
286 | { | ||
287 | |||
288 | } | ||
289 | } | ||
290 | } | ||
291 | |||
292 | // What time did the user login? | ||
293 | agent.loginTime = Util.UnixTimeSinceEpoch(); | ||
294 | agent.logoutTime = 0; | ||
295 | |||
296 | // Current location | ||
297 | agent.regionID = new LLUUID(); // Fill in later | ||
298 | agent.currentRegion = new LLUUID(); // Fill in later | ||
299 | |||
300 | profile.currentAgent = agent; | ||
301 | } | ||
302 | |||
303 | /// <summary> | ||
304 | /// Saves a target agent to the database | ||
305 | /// </summary> | ||
306 | /// <param name="profile">The users profile</param> | ||
307 | /// <returns>Successful?</returns> | ||
308 | public bool CommitAgent(ref UserProfileData profile) | ||
309 | { | ||
310 | // Saves the agent to database | ||
311 | return true; | ||
312 | } | ||
313 | |||
314 | #endregion | ||
315 | |||
316 | /// <summary> | ||
317 | /// Checks a user against it's password hash | ||
318 | /// </summary> | ||
319 | /// <param name="profile">The users profile</param> | ||
320 | /// <param name="password">The supplied password</param> | ||
321 | /// <returns>Authenticated?</returns> | ||
322 | public virtual bool AuthenticateUser(ref UserProfileData profile, string password) | ||
323 | { | ||
324 | OpenSim.Framework.Console.MainLog.Instance.Verbose( | ||
325 | "Authenticating " + profile.username + " " + profile.surname); | ||
326 | |||
327 | password = password.Remove(0, 3); //remove $1$ | ||
328 | |||
329 | string s = Util.Md5Hash(password + ":" + profile.passwordSalt); | ||
330 | |||
331 | return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); | ||
332 | } | ||
333 | |||
334 | #region Xml Response | ||
335 | |||
336 | /// <summary> | ||
337 | /// | ||
338 | /// </summary> | ||
339 | /// <param name="firstname"></param> | ||
340 | /// <param name="lastname"></param> | ||
341 | /// <returns></returns> | ||
342 | public virtual UserProfileData GetTheUser(string firstname, string lastname) | ||
343 | { | ||
344 | return getUserProfile(firstname, lastname); | ||
345 | } | ||
346 | |||
347 | /// <summary> | ||
348 | /// | ||
349 | /// </summary> | ||
350 | /// <returns></returns> | ||
351 | public virtual string GetMessage() | ||
352 | { | ||
353 | return _config.DefaultStartupMsg; | ||
354 | } | ||
355 | |||
356 | /// <summary> | ||
357 | /// Customises the login response and fills in missing values. | ||
358 | /// </summary> | ||
359 | /// <param name="response">The existing response</param> | ||
360 | /// <param name="theUser">The user profile</param> | ||
361 | public virtual void CustomiseResponse(ref LoginResponse response, ref UserProfileData theUser) | ||
362 | { | ||
363 | |||
364 | } | ||
365 | |||
366 | /// <summary> | ||
367 | /// Main user login function | ||
368 | /// </summary> | ||
369 | /// <param name="request">The XMLRPC request</param> | ||
370 | /// <returns>The response to send</returns> | ||
371 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
372 | { | ||
373 | XmlRpcResponse response = new XmlRpcResponse(); | ||
374 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
375 | |||
376 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); | ||
377 | bool GoodLogin = false; | ||
378 | string firstname = ""; | ||
379 | string lastname = ""; | ||
380 | string passwd = ""; | ||
381 | |||
382 | UserProfileData TheUser; | ||
383 | LoginResponse logResponse = new LoginResponse(); | ||
384 | |||
385 | if (GoodXML) | ||
386 | { | ||
387 | firstname = (string)requestData["first"]; | ||
388 | lastname = (string)requestData["last"]; | ||
389 | passwd = (string)requestData["passwd"]; | ||
390 | |||
391 | TheUser = GetTheUser(firstname, lastname); | ||
392 | if (TheUser == null) | ||
393 | return logResponse.CreateLoginFailedResponse(); | ||
394 | |||
395 | GoodLogin = AuthenticateUser(ref TheUser, passwd); | ||
396 | } | ||
397 | else | ||
398 | { | ||
399 | return logResponse.CreateGridErrorResponse(); | ||
400 | } | ||
401 | |||
402 | if (!GoodLogin) | ||
403 | { | ||
404 | return logResponse.CreateLoginFailedResponse(); | ||
405 | } | ||
406 | else | ||
407 | { | ||
408 | // If we already have a session... | ||
409 | if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline) | ||
410 | { | ||
411 | // Reject the login | ||
412 | return logResponse.CreateAlreadyLoggedInResponse(); | ||
413 | } | ||
414 | // Otherwise... | ||
415 | // Create a new agent session | ||
416 | CreateAgent(ref TheUser, request); | ||
417 | |||
418 | try | ||
419 | { | ||
420 | |||
421 | LLUUID AgentID = TheUser.UUID; | ||
422 | |||
423 | // Inventory Library Section | ||
424 | ArrayList AgentInventoryArray = new ArrayList(); | ||
425 | Hashtable TempHash; | ||
426 | |||
427 | AgentInventory Library = new AgentInventory(); | ||
428 | Library.CreateRootFolder(AgentID, true); | ||
429 | |||
430 | foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values) | ||
431 | { | ||
432 | TempHash = new Hashtable(); | ||
433 | TempHash["name"] = InvFolder.FolderName; | ||
434 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
435 | TempHash["version"] = (Int32)InvFolder.Version; | ||
436 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
437 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
438 | AgentInventoryArray.Add(TempHash); | ||
439 | } | ||
440 | |||
441 | Hashtable InventoryRootHash = new Hashtable(); | ||
442 | InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated(); | ||
443 | ArrayList InventoryRoot = new ArrayList(); | ||
444 | InventoryRoot.Add(InventoryRootHash); | ||
445 | |||
446 | // Circuit Code | ||
447 | uint circode = (uint)(Util.RandomClass.Next()); | ||
448 | |||
449 | logResponse.Lastname = TheUser.surname; | ||
450 | logResponse.Firstname = TheUser.username; | ||
451 | logResponse.AgentID = AgentID.ToStringHyphenated(); | ||
452 | logResponse.SessionID = TheUser.currentAgent.sessionID.ToStringHyphenated(); | ||
453 | logResponse.SecureSessionID = TheUser.currentAgent.secureSessionID.ToStringHyphenated(); | ||
454 | logResponse.InventoryRoot = InventoryRoot; | ||
455 | logResponse.InventorySkeleton = AgentInventoryArray; | ||
456 | logResponse.CircuitCode = (Int32)circode; | ||
457 | logResponse.RegionX = 0; //overwritten | ||
458 | logResponse.RegionY = 0; //overwritten | ||
459 | logResponse.Home = "!!null temporary value {home}!!"; // Overwritten | ||
460 | //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; | ||
461 | logResponse.SimAddress = "127.0.0.1"; //overwritten | ||
462 | logResponse.SimPort = 0; //overwritten | ||
463 | logResponse.Message = this.GetMessage(); | ||
464 | |||
465 | try | ||
466 | { | ||
467 | this.CustomiseResponse(ref logResponse, ref TheUser); | ||
468 | } | ||
469 | catch (Exception e) | ||
470 | { | ||
471 | System.Console.WriteLine(e.ToString()); | ||
472 | return logResponse.CreateDeadRegionResponse(); | ||
473 | } | ||
474 | CommitAgent(ref TheUser); | ||
475 | return logResponse.ToXmlRpcResponse(); | ||
476 | |||
477 | } | ||
478 | catch (Exception E) | ||
479 | { | ||
480 | System.Console.WriteLine(E.ToString()); | ||
481 | } | ||
482 | //} | ||
483 | } | ||
484 | return response; | ||
485 | |||
486 | } | ||
487 | |||
488 | #endregion | ||
489 | |||
490 | /// <summary> | ||
491 | /// Deletes an active agent session | ||
492 | /// </summary> | ||
493 | /// <param name="request">The request</param> | ||
494 | /// <param name="path">The path (eg /bork/narf/test)</param> | ||
495 | /// <param name="param">Parameters sent</param> | ||
496 | /// <returns>Success "OK" else error</returns> | ||
497 | public string RestDeleteUserSessionMethod(string request, string path, string param) | ||
498 | { | ||
499 | // TODO! Important! | ||
500 | |||
501 | return "OK"; | ||
502 | } | ||
503 | |||
504 | /// <summary> | ||
505 | /// | ||
506 | /// </summary> | ||
507 | /// <param name="user"></param> | ||
508 | public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) | ||
509 | { | ||
510 | UserProfileData user = new UserProfileData(); | ||
511 | user.homeLocation = new LLVector3(128, 128, 100); | ||
512 | user.UUID = LLUUID.Random(); | ||
513 | user.username = firstName; | ||
514 | user.surname = lastName; | ||
515 | user.passwordHash = pass; | ||
516 | user.passwordSalt = ""; | ||
517 | user.created = Util.UnixTimeSinceEpoch(); | ||
518 | user.homeLookAt = new LLVector3(100, 100, 100); | ||
519 | user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256)); | ||
520 | |||
521 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
522 | { | ||
523 | try | ||
524 | { | ||
525 | plugin.Value.addNewUserProfile(user); | ||
526 | |||
527 | } | ||
528 | catch (Exception e) | ||
529 | { | ||
530 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
531 | } | ||
532 | } | ||
533 | } | ||
534 | |||
535 | /// <summary> | ||
536 | /// Returns an error message that the user could not be found in the database | ||
537 | /// </summary> | ||
538 | /// <returns>XML string consisting of a error element containing individual error(s)</returns> | ||
539 | public XmlRpcResponse CreateUnknownUserErrorResponse() | ||
540 | { | ||
541 | XmlRpcResponse response = new XmlRpcResponse(); | ||
542 | Hashtable responseData = new Hashtable(); | ||
543 | responseData["error_type"] = "unknown_user"; | ||
544 | responseData["error_desc"] = "The user requested is not in the database"; | ||
545 | |||
546 | response.Value = responseData; | ||
547 | return response; | ||
548 | } | ||
549 | |||
550 | /// <summary> | ||
551 | /// Converts a user profile to an XML element which can be returned | ||
552 | /// </summary> | ||
553 | /// <param name="profile">The user profile</param> | ||
554 | /// <returns>A string containing an XML Document of the user profile</returns> | ||
555 | public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) | ||
556 | { | ||
557 | XmlRpcResponse response = new XmlRpcResponse(); | ||
558 | Hashtable responseData = new Hashtable(); | ||
559 | |||
560 | // Account information | ||
561 | responseData["firstname"] = profile.username; | ||
562 | responseData["lastname"] = profile.surname; | ||
563 | responseData["uuid"] = profile.UUID.ToStringHyphenated(); | ||
564 | // Server Information | ||
565 | responseData["server_inventory"] = profile.userInventoryURI; | ||
566 | responseData["server_asset"] = profile.userAssetURI; | ||
567 | // Profile Information | ||
568 | responseData["profile_about"] = profile.profileAboutText; | ||
569 | responseData["profile_firstlife_about"] = profile.profileFirstText; | ||
570 | responseData["profile_firstlife_image"] = profile.profileFirstImage.ToStringHyphenated(); | ||
571 | responseData["profile_can_do"] = profile.profileCanDoMask.ToString(); | ||
572 | responseData["profile_want_do"] = profile.profileWantDoMask.ToString(); | ||
573 | responseData["profile_image"] = profile.profileImage.ToStringHyphenated(); | ||
574 | responseData["profile_created"] = profile.created.ToString(); | ||
575 | responseData["profile_lastlogin"] = profile.lastLogin.ToString(); | ||
576 | // Home region information | ||
577 | responseData["home_coordinates"] = profile.homeLocation.ToString(); | ||
578 | responseData["home_region"] = profile.homeRegion.ToString(); | ||
579 | responseData["home_look"] = profile.homeLookAt.ToString(); | ||
580 | |||
581 | response.Value = responseData; | ||
582 | return response; | ||
583 | } | ||
584 | |||
585 | #region XMLRPC User Methods | ||
586 | //should most likely move out of here and into the grid's userserver sub class | ||
587 | public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) | ||
588 | { | ||
589 | XmlRpcResponse response = new XmlRpcResponse(); | ||
590 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
591 | UserProfileData userProfile; | ||
592 | |||
593 | if (requestData.Contains("avatar_name")) | ||
594 | { | ||
595 | userProfile = getUserProfile((string)requestData["avatar_name"]); | ||
596 | if (userProfile == null) | ||
597 | { | ||
598 | return CreateUnknownUserErrorResponse(); | ||
599 | } | ||
600 | } | ||
601 | else | ||
602 | { | ||
603 | return CreateUnknownUserErrorResponse(); | ||
604 | } | ||
605 | |||
606 | |||
607 | return ProfileToXmlRPCResponse(userProfile); | ||
608 | } | ||
609 | |||
610 | public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) | ||
611 | { | ||
612 | XmlRpcResponse response = new XmlRpcResponse(); | ||
613 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
614 | UserProfileData userProfile; | ||
615 | if (requestData.Contains("avatar_uuid")) | ||
616 | { | ||
617 | userProfile = getUserProfile((LLUUID)requestData["avatar_uuid"]); | ||
618 | if (userProfile == null) | ||
619 | { | ||
620 | return CreateUnknownUserErrorResponse(); | ||
621 | } | ||
622 | } | ||
623 | else | ||
624 | { | ||
625 | return CreateUnknownUserErrorResponse(); | ||
626 | } | ||
627 | |||
628 | |||
629 | return ProfileToXmlRPCResponse(userProfile); | ||
630 | } | ||
631 | #endregion | ||
632 | |||
633 | } | ||
634 | } | ||