aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Servers/LoginResponse.cs
diff options
context:
space:
mode:
authorMW2007-05-24 12:35:32 +0000
committerMW2007-05-24 12:35:32 +0000
commitf95b6081cba084d1b067acea99c0effa2b3bf42c (patch)
tree7a7ab4aa037f75afa54f403c701a735acb101575 /Common/OpenSim.Servers/LoginResponse.cs
parentDie ServiceManager! (Not really Gareth, just the old directory, new directory... (diff)
downloadopensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.zip
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.gz
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.bz2
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.xz
Renamed the new Directories. (removed the "-Source" from the end of them)
Diffstat (limited to 'Common/OpenSim.Servers/LoginResponse.cs')
-rw-r--r--Common/OpenSim.Servers/LoginResponse.cs670
1 files changed, 670 insertions, 0 deletions
diff --git a/Common/OpenSim.Servers/LoginResponse.cs b/Common/OpenSim.Servers/LoginResponse.cs
new file mode 100644
index 0000000..7333d1f
--- /dev/null
+++ b/Common/OpenSim.Servers/LoginResponse.cs
@@ -0,0 +1,670 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using Nwc.XmlRpc;
29using System;
30using System.IO;
31using System.Net;
32using System.Net.Sockets;
33using System.Text;
34using System.Text.RegularExpressions;
35using System.Threading;
36using System.Collections;
37using System.Security.Cryptography;
38using System.Xml;
39using libsecondlife;
40using OpenSim;
41using OpenSim.Framework.User;
42using OpenSim.Framework.Inventory;
43using OpenSim.Framework.Utilities;
44using OpenSim.Framework.Interfaces;
45
46// ?
47using OpenSim.Framework.Grid;
48
49namespace OpenSim.UserServer
50{
51 /// <summary>
52 /// A temp class to handle login response.
53 /// Should make use of UserProfileManager where possible.
54 /// </summary>
55
56 public class LoginResponse
57 {
58 private Hashtable loginFlagsHash;
59 private Hashtable globalTexturesHash;
60 private Hashtable loginError;
61 private Hashtable eventCategoriesHash;
62 private Hashtable uiConfigHash;
63 private Hashtable classifiedCategoriesHash;
64
65 private ArrayList loginFlags;
66 private ArrayList globalTextures;
67 private ArrayList eventCategories;
68 private ArrayList uiConfig;
69 private ArrayList classifiedCategories;
70 private ArrayList inventoryRoot;
71 private ArrayList initialOutfit;
72 private ArrayList agentInventory;
73
74 private UserProfile userProfile;
75
76 private LLUUID agentID;
77 private LLUUID sessionID;
78 private LLUUID secureSessionID;
79 private LLUUID baseFolderID;
80 private LLUUID inventoryFolderID;
81
82 // Login Flags
83 private string dst;
84 private string stipendSinceLogin;
85 private string gendered;
86 private string everLoggedIn;
87 private string login;
88 private string simPort;
89 private string simAddress;
90 private string agentAccess;
91 private Int32 circuitCode;
92 private uint regionX;
93 private uint regionY;
94
95 // Login
96 private string firstname;
97 private string lastname;
98
99 // Global Textures
100 private string sunTexture;
101 private string cloudTexture;
102 private string moonTexture;
103
104 // Error Flags
105 private string errorReason;
106 private string errorMessage;
107
108 // Response
109 private XmlRpcResponse xmlRpcResponse;
110 private XmlRpcResponse defaultXmlRpcResponse;
111
112 private string welcomeMessage;
113 private string startLocation;
114 private string allowFirstLife;
115 private string home;
116 private string seedCapability;
117 private string lookAt;
118
119 public LoginResponse()
120 {
121 this.loginFlags = new ArrayList();
122 this.globalTextures = new ArrayList();
123 this.eventCategories = new ArrayList();
124 this.uiConfig = new ArrayList();
125 this.classifiedCategories = new ArrayList();
126
127 this.loginError = new Hashtable();
128 this.eventCategoriesHash = new Hashtable();
129 this.classifiedCategoriesHash = new Hashtable();
130 this.uiConfigHash = new Hashtable();
131
132 this.defaultXmlRpcResponse = new XmlRpcResponse();
133 this.userProfile = new UserProfile();
134 this.inventoryRoot = new ArrayList();
135 this.initialOutfit = new ArrayList();
136 this.agentInventory = new ArrayList();
137
138 this.xmlRpcResponse = new XmlRpcResponse();
139 this.defaultXmlRpcResponse = new XmlRpcResponse();
140
141 this.SetDefaultValues();
142 } // LoginServer
143
144 public void SetDefaultValues()
145 {
146 try
147 {
148 this.DST = "N";
149 this.StipendSinceLogin = "N";
150 this.Gendered = "Y";
151 this.EverLoggedIn = "Y";
152 this.login = "false";
153 this.firstname = "Test";
154 this.lastname = "User";
155 this.agentAccess = "M";
156 this.startLocation = "last";
157 this.allowFirstLife = "Y";
158
159 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
160 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
161 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
162
163 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
164 this.ErrorReason = "key";
165 this.welcomeMessage = "Welcome to OpenSim!";
166 this.seedCapability = "";
167 this.home = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 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() + "]}";
168 this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
169 this.RegionX = (uint)255232;
170 this.RegionY = (uint)254976;
171
172 // Classifieds;
173 this.AddClassifiedCategory((Int32)1, "Shopping");
174 this.AddClassifiedCategory((Int32)2, "Land Rental");
175 this.AddClassifiedCategory((Int32)3, "Property Rental");
176 this.AddClassifiedCategory((Int32)4, "Special Attraction");
177 this.AddClassifiedCategory((Int32)5, "New Products");
178 this.AddClassifiedCategory((Int32)6, "Employment");
179 this.AddClassifiedCategory((Int32)7, "Wanted");
180 this.AddClassifiedCategory((Int32)8, "Service");
181 this.AddClassifiedCategory((Int32)9, "Personal");
182
183 int SessionRand = Util.RandomClass.Next(1, 999);
184 this.SessionID = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
185 this.SecureSessionID = LLUUID.Random();
186
187 this.userProfile.Inventory.CreateRootFolder(this.userProfile.UUID, true);
188 this.baseFolderID = this.userProfile.Inventory.GetFolderID("Textures");
189 this.inventoryFolderID = this.userProfile.Inventory.GetFolderID("My Inventory-");
190 Hashtable InventoryRootHash = new Hashtable();
191 InventoryRootHash["folder_id"] = this.userProfile.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
192 this.inventoryRoot.Add(InventoryRootHash);
193
194 Hashtable TempHash;
195 foreach (InventoryFolder InvFolder in this.userProfile.Inventory.InventoryFolders.Values)
196 {
197 TempHash = new Hashtable();
198 TempHash["name"] = InvFolder.FolderName;
199 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
200 TempHash["version"] = (Int32)InvFolder.Version;
201 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
202 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
203 this.agentInventory.Add(TempHash);
204 }
205
206 Hashtable InitialOutfitHash = new Hashtable();
207 InitialOutfitHash["folder_name"] = "Nightclub Female";
208 InitialOutfitHash["gender"] = "female";
209 this.initialOutfit.Add(InitialOutfitHash);
210 }
211 catch (Exception e)
212 {
213 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(
214 OpenSim.Framework.Console.LogPriority.LOW,
215 "LoginResponse: Unable to set default values: " + e.Message
216 );
217 }
218
219 } // SetDefaultValues
220
221 protected virtual LLUUID GetAgentId()
222 {
223 // todo
224 LLUUID Agent;
225 int AgentRand = Util.RandomClass.Next(1, 9999);
226 Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
227 return Agent;
228 } // GetAgentId
229
230 private XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
231 {
232 // Overwrite any default values;
233 this.xmlRpcResponse = new XmlRpcResponse();
234
235 // Ensure Login Failed message/reason;
236 this.ErrorMessage = message;
237 this.ErrorReason = reason;
238
239 this.loginError["reason"] = this.ErrorReason;
240 this.loginError["message"] = this.ErrorMessage;
241 this.loginError["login"] = login;
242 this.xmlRpcResponse.Value = this.loginError;
243 return (this.xmlRpcResponse);
244 } // GenerateResponse
245
246 public XmlRpcResponse LoginFailedResponse()
247 {
248 return (this.GenerateFailureResponse("key", "You have entered an invalid name/password combination. Check Caps/lock.", "false"));
249 } // LoginFailedResponse
250
251 public XmlRpcResponse ConnectionFailedResponse()
252 {
253 return (this.LoginFailedResponse());
254 } // CreateErrorConnectingToGridResponse()
255
256 public XmlRpcResponse CreateAlreadyLoggedInResponse()
257 {
258 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"));
259 } // CreateAlreadyLoggedInResponse()
260
261 public XmlRpcResponse ToXmlRpcResponse()
262 {
263 try
264 {
265
266 Hashtable responseData = new Hashtable();
267
268 this.loginFlagsHash = new Hashtable();
269 this.loginFlagsHash["daylight_savings"] = this.DST;
270 this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
271 this.loginFlagsHash["gendered"] = this.Gendered;
272 this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
273 this.loginFlags.Add(this.loginFlagsHash);
274
275 responseData["first_name"] = this.Firstname;
276 responseData["last_name"] = this.Lastname;
277 responseData["agent_access"] = this.agentAccess;
278
279 this.globalTexturesHash = new Hashtable();
280 this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
281 this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
282 this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
283 this.globalTextures.Add(this.globalTexturesHash);
284 this.eventCategories.Add(this.eventCategoriesHash);
285
286 this.AddToUIConfig("allow_first_life", this.allowFirstLife);
287 this.uiConfig.Add(this.uiConfigHash);
288
289 // Create a agent and session LLUUID
290 this.agentID = this.GetAgentId();
291
292 responseData["sim_port"] = this.SimPort;
293 responseData["sim_ip"] = this.SimAddress;
294 responseData["agent_id"] = this.AgentID.ToStringHyphenated();
295 responseData["session_id"] = this.SessionID.ToStringHyphenated();
296 responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
297 responseData["circuit_code"] = this.CircuitCode;
298 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
299 responseData["login-flags"] = this.loginFlags;
300 responseData["global-textures"] = this.globalTextures;
301 responseData["seed_capability"] = this.seedCapability;
302
303 responseData["event_categories"] = this.eventCategories;
304 responseData["event_notifications"] = new ArrayList(); // todo
305 responseData["classified_categories"] = this.classifiedCategories;
306 responseData["ui-config"] = this.uiConfig;
307
308 responseData["inventory-skeleton"] = this.agentInventory;
309 responseData["inventory-skel-lib"] = new ArrayList(); // todo
310 responseData["inventory-root"] = this.inventoryRoot;
311 responseData["gestures"] = new ArrayList(); // todo
312 responseData["inventory-lib-owner"] = new ArrayList(); // todo
313 responseData["initial-outfit"] = this.initialOutfit;
314 responseData["start_location"] = this.startLocation;
315 responseData["seed_capability"] = this.seedCapability;
316 responseData["home"] = this.home;
317 responseData["look_at"] = this.lookAt;
318 responseData["message"] = this.welcomeMessage;
319 responseData["region_x"] = (Int32)this.RegionX * 256;
320 responseData["region_y"] = (Int32)this.RegionY * 256;
321
322 responseData["login"] = "true";
323 this.xmlRpcResponse.Value = responseData;
324
325 return (this.xmlRpcResponse);
326 }
327 catch (Exception e)
328 {
329 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(
330 OpenSim.Framework.Console.LogPriority.LOW,
331 "LoginResponse: Error creating XML-RPC Response: " + e.Message
332 );
333 return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
334
335 }
336
337 } // ToXmlRpcResponse
338
339 public void SetEventCategories(string category, string value)
340 {
341 this.eventCategoriesHash[category] = value;
342 } // SetEventCategories
343
344 public void AddToUIConfig(string itemName, string item)
345 {
346 this.uiConfigHash[itemName] = item;
347 } // SetUIConfig
348
349 public void AddClassifiedCategory(Int32 ID, string categoryName)
350 {
351 this.classifiedCategoriesHash["category_name"] = categoryName;
352 this.classifiedCategoriesHash["category_id"] = ID;
353 this.classifiedCategories.Add(this.classifiedCategoriesHash);
354 // this.classifiedCategoriesHash.Clear();
355 } // SetClassifiedCategory
356
357 public string Login
358 {
359 get
360 {
361 return this.login;
362 }
363 set
364 {
365 this.login = value;
366 }
367 } // Login
368
369 public string DST
370 {
371 get
372 {
373 return this.dst;
374 }
375 set
376 {
377 this.dst = value;
378 }
379 } // DST
380
381 public string StipendSinceLogin
382 {
383 get
384 {
385 return this.stipendSinceLogin;
386 }
387 set
388 {
389 this.stipendSinceLogin = value;
390 }
391 } // StipendSinceLogin
392
393 public string Gendered
394 {
395 get
396 {
397 return this.gendered;
398 }
399 set
400 {
401 this.gendered = value;
402 }
403 } // Gendered
404
405 public string EverLoggedIn
406 {
407 get
408 {
409 return this.everLoggedIn;
410 }
411 set
412 {
413 this.everLoggedIn = value;
414 }
415 } // EverLoggedIn
416
417 public string SimPort
418 {
419 get
420 {
421 return this.simPort;
422 }
423 set
424 {
425 this.simPort = value;
426 }
427 } // SimPort
428
429 public string SimAddress
430 {
431 get
432 {
433 return this.simAddress;
434 }
435 set
436 {
437 this.simAddress = value;
438 }
439 } // SimAddress
440
441 public LLUUID AgentID
442 {
443 get
444 {
445 return this.agentID;
446 }
447 set
448 {
449 this.agentID = value;
450 }
451 } // AgentID
452
453 public LLUUID SessionID
454 {
455 get
456 {
457 return this.sessionID;
458 }
459 set
460 {
461 this.sessionID = value;
462 }
463 } // SessionID
464
465 public LLUUID SecureSessionID
466 {
467 get
468 {
469 return this.secureSessionID;
470 }
471 set
472 {
473 this.secureSessionID = value;
474 }
475 } // SecureSessionID
476
477 public LLUUID BaseFolderID
478 {
479 get
480 {
481 return this.baseFolderID;
482 }
483 set
484 {
485 this.baseFolderID = value;
486 }
487 } // BaseFolderID
488
489 public LLUUID InventoryFolderID
490 {
491 get
492 {
493 return this.inventoryFolderID;
494 }
495 set
496 {
497 this.inventoryFolderID = value;
498 }
499 } // InventoryFolderID
500
501 public Int32 CircuitCode
502 {
503 get
504 {
505 return this.circuitCode;
506 }
507 set
508 {
509 this.circuitCode = value;
510 }
511 } // CircuitCode
512
513 public uint RegionX
514 {
515 get
516 {
517 return this.regionX;
518 }
519 set
520 {
521 this.regionX = value;
522 }
523 } // RegionX
524
525 public uint RegionY
526 {
527 get
528 {
529 return this.regionY;
530 }
531 set
532 {
533 this.regionY = value;
534 }
535 } // RegionY
536
537 public string SunTexture
538 {
539 get
540 {
541 return this.sunTexture;
542 }
543 set
544 {
545 this.sunTexture = value;
546 }
547 } // SunTexture
548
549 public string CloudTexture
550 {
551 get
552 {
553 return this.cloudTexture;
554 }
555 set
556 {
557 this.cloudTexture = value;
558 }
559 } // CloudTexture
560
561 public string MoonTexture
562 {
563 get
564 {
565 return this.moonTexture;
566 }
567 set
568 {
569 this.moonTexture = value;
570 }
571 } // MoonTexture
572
573 public string Firstname
574 {
575 get
576 {
577 return this.firstname;
578 }
579 set
580 {
581 this.firstname = value;
582 }
583 } // Firstname
584
585 public string Lastname
586 {
587 get
588 {
589 return this.lastname;
590 }
591 set
592 {
593 this.lastname = value;
594 }
595 } // Lastname
596
597 public string AgentAccess
598 {
599 get
600 {
601 return this.agentAccess;
602 }
603 set
604 {
605 this.agentAccess = value;
606 }
607 }
608
609 public string StartLocation
610 {
611 get
612 {
613 return this.startLocation;
614 }
615 set
616 {
617 this.startLocation = value;
618 }
619 } // StartLocation
620
621 public string LookAt
622 {
623 get
624 {
625 return this.lookAt;
626 }
627 set
628 {
629 this.lookAt = value;
630 }
631 }
632
633 public string SeedCapability
634 {
635 get
636 {
637 return this.seedCapability;
638 }
639 set
640 {
641 this.seedCapability = value;
642 }
643 } // SeedCapability
644
645 public string ErrorReason
646 {
647 get
648 {
649 return this.errorReason;
650 }
651 set
652 {
653 this.errorReason = value;
654 }
655 } // ErrorReason
656
657 public string ErrorMessage
658 {
659 get
660 {
661 return this.errorMessage;
662 }
663 set
664 {
665 this.errorMessage = value;
666 }
667 } // ErrorMessage
668
669 } // LoginResponse
670} // namespace OpenSim.UserServer \ No newline at end of file