aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Servers/LoginResponse.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-07-11 08:02:47 +0000
committerAdam Frisby2007-07-11 08:02:47 +0000
commit5c7ffdde0b9642a42e8f5987e06eb01220ff7776 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /Common/OpenSim.Servers/LoginResponse.cs
parentWho would have known that the only way of specifying utf-8 without preamble, ... (diff)
downloadopensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.zip
opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.gz
opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.bz2
opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.xz
* Wiping trunk in prep for Sugilite
Diffstat (limited to '')
-rw-r--r--Common/OpenSim.Servers/LoginResponse.cs669
1 files changed, 0 insertions, 669 deletions
diff --git a/Common/OpenSim.Servers/LoginResponse.cs b/Common/OpenSim.Servers/LoginResponse.cs
deleted file mode 100644
index 9e37409..0000000
--- a/Common/OpenSim.Servers/LoginResponse.cs
+++ /dev/null
@@ -1,669 +0,0 @@
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
29using Nwc.XmlRpc;
30using System;
31using System.IO;
32using System.Net;
33using System.Net.Sockets;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Threading;
37using System.Collections;
38using System.Security.Cryptography;
39using System.Xml;
40using libsecondlife;
41using OpenSim;
42using OpenSim.Framework.User;
43using OpenSim.Framework.Inventory;
44using OpenSim.Framework.Utilities;
45using OpenSim.Framework.Interfaces;
46
47// ?
48using OpenSim.Framework.Grid;
49
50namespace OpenSim.UserServer
51{
52 /// <summary>
53 /// A temp class to handle login response.
54 /// Should make use of UserProfileManager where possible.
55 /// </summary>
56
57 public class LoginResponse
58 {
59 private Hashtable loginFlagsHash;
60 private Hashtable globalTexturesHash;
61 private Hashtable loginError;
62 private Hashtable eventCategoriesHash;
63 private Hashtable uiConfigHash;
64 private Hashtable classifiedCategoriesHash;
65
66 private ArrayList loginFlags;
67 private ArrayList globalTextures;
68 private ArrayList eventCategories;
69 private ArrayList uiConfig;
70 private ArrayList classifiedCategories;
71 private ArrayList inventoryRoot;
72 private ArrayList initialOutfit;
73 private ArrayList agentInventory;
74
75 private UserProfile userProfile;
76
77 private LLUUID agentID;
78 private LLUUID sessionID;
79 private LLUUID secureSessionID;
80 private LLUUID baseFolderID;
81 private LLUUID inventoryFolderID;
82
83 // Login Flags
84 private string dst;
85 private string stipendSinceLogin;
86 private string gendered;
87 private string everLoggedIn;
88 private string login;
89 private string simPort;
90 private string simAddress;
91 private string agentAccess;
92 private Int32 circuitCode;
93 private uint regionX;
94 private uint regionY;
95
96 // Login
97 private string firstname;
98 private string lastname;
99
100 // Global Textures
101 private string sunTexture;
102 private string cloudTexture;
103 private string moonTexture;
104
105 // Error Flags
106 private string errorReason;
107 private string errorMessage;
108
109 // Response
110 private XmlRpcResponse xmlRpcResponse;
111 private XmlRpcResponse defaultXmlRpcResponse;
112
113 private string welcomeMessage;
114 private string startLocation;
115 private string allowFirstLife;
116 private string home;
117 private string seedCapability;
118 private string lookAt;
119
120 public LoginResponse()
121 {
122 this.loginFlags = new ArrayList();
123 this.globalTextures = new ArrayList();
124 this.eventCategories = new ArrayList();
125 this.uiConfig = new ArrayList();
126 this.classifiedCategories = new ArrayList();
127
128 this.loginError = new Hashtable();
129 this.eventCategoriesHash = new Hashtable();
130 this.classifiedCategoriesHash = new Hashtable();
131 this.uiConfigHash = new Hashtable();
132
133 this.defaultXmlRpcResponse = new XmlRpcResponse();
134 this.userProfile = new UserProfile();
135 this.inventoryRoot = new ArrayList();
136 this.initialOutfit = new ArrayList();
137 this.agentInventory = new ArrayList();
138
139 this.xmlRpcResponse = new XmlRpcResponse();
140 this.defaultXmlRpcResponse = new XmlRpcResponse();
141
142 this.SetDefaultValues();
143 } // LoginServer
144
145 public void SetDefaultValues()
146 {
147 try
148 {
149 this.DST = "N";
150 this.StipendSinceLogin = "N";
151 this.Gendered = "Y";
152 this.EverLoggedIn = "Y";
153 this.login = "false";
154 this.firstname = "Test";
155 this.lastname = "User";
156 this.agentAccess = "M";
157 this.startLocation = "last";
158 this.allowFirstLife = "Y";
159
160 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
161 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
162 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
163
164 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
165 this.ErrorReason = "key";
166 this.welcomeMessage = "Welcome to OpenSim!";
167 this.seedCapability = "";
168 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() + "]}";
169 this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
170 this.RegionX = (uint)255232;
171 this.RegionY = (uint)254976;
172
173 // Classifieds;
174 this.AddClassifiedCategory((Int32)1, "Shopping");
175 this.AddClassifiedCategory((Int32)2, "Land Rental");
176 this.AddClassifiedCategory((Int32)3, "Property Rental");
177 this.AddClassifiedCategory((Int32)4, "Special Attraction");
178 this.AddClassifiedCategory((Int32)5, "New Products");
179 this.AddClassifiedCategory((Int32)6, "Employment");
180 this.AddClassifiedCategory((Int32)7, "Wanted");
181 this.AddClassifiedCategory((Int32)8, "Service");
182 this.AddClassifiedCategory((Int32)9, "Personal");
183
184 int SessionRand = Util.RandomClass.Next(1, 999);
185 this.SessionID = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
186 this.SecureSessionID = LLUUID.Random();
187
188 this.userProfile.Inventory.CreateRootFolder(this.userProfile.UUID, true);
189 this.baseFolderID = this.userProfile.Inventory.GetFolderID("Textures");
190 this.inventoryFolderID = this.userProfile.Inventory.GetFolderID("My Inventory-");
191 Hashtable InventoryRootHash = new Hashtable();
192 InventoryRootHash["folder_id"] = this.userProfile.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
193 this.inventoryRoot.Add(InventoryRootHash);
194
195 Hashtable TempHash;
196 foreach (InventoryFolder InvFolder in this.userProfile.Inventory.InventoryFolders.Values)
197 {
198 TempHash = new Hashtable();
199 TempHash["name"] = InvFolder.FolderName;
200 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
201 TempHash["version"] = (Int32)InvFolder.Version;
202 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
203 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
204 this.agentInventory.Add(TempHash);
205 }
206
207 Hashtable InitialOutfitHash = new Hashtable();
208 InitialOutfitHash["folder_name"] = "Nightclub Female";
209 InitialOutfitHash["gender"] = "female";
210 this.initialOutfit.Add(InitialOutfitHash);
211 }
212 catch (Exception e)
213 {
214 OpenSim.Framework.Console.MainConsole.Instance.Warn(
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.Error(
330 "LoginResponse: Error creating XML-RPC Response: " + e.Message
331 );
332 return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
333
334 }
335
336 } // ToXmlRpcResponse
337
338 public void SetEventCategories(string category, string value)
339 {
340 this.eventCategoriesHash[category] = value;
341 } // SetEventCategories
342
343 public void AddToUIConfig(string itemName, string item)
344 {
345 this.uiConfigHash[itemName] = item;
346 } // SetUIConfig
347
348 public void AddClassifiedCategory(Int32 ID, string categoryName)
349 {
350 this.classifiedCategoriesHash["category_name"] = categoryName;
351 this.classifiedCategoriesHash["category_id"] = ID;
352 this.classifiedCategories.Add(this.classifiedCategoriesHash);
353 // this.classifiedCategoriesHash.Clear();
354 } // SetClassifiedCategory
355
356 public string Login
357 {
358 get
359 {
360 return this.login;
361 }
362 set
363 {
364 this.login = value;
365 }
366 } // Login
367
368 public string DST
369 {
370 get
371 {
372 return this.dst;
373 }
374 set
375 {
376 this.dst = value;
377 }
378 } // DST
379
380 public string StipendSinceLogin
381 {
382 get
383 {
384 return this.stipendSinceLogin;
385 }
386 set
387 {
388 this.stipendSinceLogin = value;
389 }
390 } // StipendSinceLogin
391
392 public string Gendered
393 {
394 get
395 {
396 return this.gendered;
397 }
398 set
399 {
400 this.gendered = value;
401 }
402 } // Gendered
403
404 public string EverLoggedIn
405 {
406 get
407 {
408 return this.everLoggedIn;
409 }
410 set
411 {
412 this.everLoggedIn = value;
413 }
414 } // EverLoggedIn
415
416 public string SimPort
417 {
418 get
419 {
420 return this.simPort;
421 }
422 set
423 {
424 this.simPort = value;
425 }
426 } // SimPort
427
428 public string SimAddress
429 {
430 get
431 {
432 return this.simAddress;
433 }
434 set
435 {
436 this.simAddress = value;
437 }
438 } // SimAddress
439
440 public LLUUID AgentID
441 {
442 get
443 {
444 return this.agentID;
445 }
446 set
447 {
448 this.agentID = value;
449 }
450 } // AgentID
451
452 public LLUUID SessionID
453 {
454 get
455 {
456 return this.sessionID;
457 }
458 set
459 {
460 this.sessionID = value;
461 }
462 } // SessionID
463
464 public LLUUID SecureSessionID
465 {
466 get
467 {
468 return this.secureSessionID;
469 }
470 set
471 {
472 this.secureSessionID = value;
473 }
474 } // SecureSessionID
475
476 public LLUUID BaseFolderID
477 {
478 get
479 {
480 return this.baseFolderID;
481 }
482 set
483 {
484 this.baseFolderID = value;
485 }
486 } // BaseFolderID
487
488 public LLUUID InventoryFolderID
489 {
490 get
491 {
492 return this.inventoryFolderID;
493 }
494 set
495 {
496 this.inventoryFolderID = value;
497 }
498 } // InventoryFolderID
499
500 public Int32 CircuitCode
501 {
502 get
503 {
504 return this.circuitCode;
505 }
506 set
507 {
508 this.circuitCode = value;
509 }
510 } // CircuitCode
511
512 public uint RegionX
513 {
514 get
515 {
516 return this.regionX;
517 }
518 set
519 {
520 this.regionX = value;
521 }
522 } // RegionX
523
524 public uint RegionY
525 {
526 get
527 {
528 return this.regionY;
529 }
530 set
531 {
532 this.regionY = value;
533 }
534 } // RegionY
535
536 public string SunTexture
537 {
538 get
539 {
540 return this.sunTexture;
541 }
542 set
543 {
544 this.sunTexture = value;
545 }
546 } // SunTexture
547
548 public string CloudTexture
549 {
550 get
551 {
552 return this.cloudTexture;
553 }
554 set
555 {
556 this.cloudTexture = value;
557 }
558 } // CloudTexture
559
560 public string MoonTexture
561 {
562 get
563 {
564 return this.moonTexture;
565 }
566 set
567 {
568 this.moonTexture = value;
569 }
570 } // MoonTexture
571
572 public string Firstname
573 {
574 get
575 {
576 return this.firstname;
577 }
578 set
579 {
580 this.firstname = value;
581 }
582 } // Firstname
583
584 public string Lastname
585 {
586 get
587 {
588 return this.lastname;
589 }
590 set
591 {
592 this.lastname = value;
593 }
594 } // Lastname
595
596 public string AgentAccess
597 {
598 get
599 {
600 return this.agentAccess;
601 }
602 set
603 {
604 this.agentAccess = value;
605 }
606 }
607
608 public string StartLocation
609 {
610 get
611 {
612 return this.startLocation;
613 }
614 set
615 {
616 this.startLocation = value;
617 }
618 } // StartLocation
619
620 public string LookAt
621 {
622 get
623 {
624 return this.lookAt;
625 }
626 set
627 {
628 this.lookAt = value;
629 }
630 }
631
632 public string SeedCapability
633 {
634 get
635 {
636 return this.seedCapability;
637 }
638 set
639 {
640 this.seedCapability = value;
641 }
642 } // SeedCapability
643
644 public string ErrorReason
645 {
646 get
647 {
648 return this.errorReason;
649 }
650 set
651 {
652 this.errorReason = value;
653 }
654 } // ErrorReason
655
656 public string ErrorMessage
657 {
658 get
659 {
660 return this.errorMessage;
661 }
662 set
663 {
664 this.errorMessage = value;
665 }
666 } // ErrorMessage
667
668 } // LoginResponse
669} // namespace OpenSim.UserServer \ No newline at end of file