aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/UserManager
diff options
context:
space:
mode:
authorlbsa712007-09-24 07:30:30 +0000
committerlbsa712007-09-24 07:30:30 +0000
commit1302ef44e3c632159378bc4042c753bcf36e9c63 (patch)
tree6b6295ac233ecb05afe6432a903ec616e4fa079a /OpenSim/Framework/UserManager
parent* Trying to streamline CommunicationsManager (diff)
downloadopensim-SC_OLD-1302ef44e3c632159378bc4042c753bcf36e9c63.zip
opensim-SC_OLD-1302ef44e3c632159378bc4042c753bcf36e9c63.tar.gz
opensim-SC_OLD-1302ef44e3c632159378bc4042c753bcf36e9c63.tar.bz2
opensim-SC_OLD-1302ef44e3c632159378bc4042c753bcf36e9c63.tar.xz
* Started major restructusing of comms to prepare for better grid and region functionality
* Working towards one shared set of services * Killed off two projects with very little functionality
Diffstat (limited to 'OpenSim/Framework/UserManager')
-rw-r--r--OpenSim/Framework/UserManager/CAPSService.cs38
-rw-r--r--OpenSim/Framework/UserManager/LoginResponse.cs667
-rw-r--r--OpenSim/Framework/UserManager/LoginService.cs287
-rw-r--r--OpenSim/Framework/UserManager/UserManagerBase.cs377
4 files changed, 0 insertions, 1369 deletions
diff --git a/OpenSim/Framework/UserManager/CAPSService.cs b/OpenSim/Framework/UserManager/CAPSService.cs
deleted file mode 100644
index a8eac26..0000000
--- a/OpenSim/Framework/UserManager/CAPSService.cs
+++ /dev/null
@@ -1,38 +0,0 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Reflection;
5using System.Security.Cryptography;
6using libsecondlife;
7using Nwc.XmlRpc;
8using OpenSim.Framework.Console;
9using OpenSim.Framework.Data;
10using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Inventory;
12using OpenSim.Framework.Utilities;
13using OpenSim.Framework.Servers;
14
15namespace OpenSim.Framework.UserManagement
16{
17 public class CAPSService
18 {
19 private BaseHttpServer m_server;
20
21 public CAPSService(BaseHttpServer httpServer)
22 {
23 m_server = httpServer;
24 this.AddCapsSeedHandler("/CapsSeed/", CapsRequest);
25 }
26
27 private void AddCapsSeedHandler(string path, RestMethod restMethod)
28 {
29 m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod));
30 }
31
32 public string CapsRequest(string request, string path, string param)
33 {
34 System.Console.WriteLine("new caps request " + request +" from path "+ path);
35 return "";
36 }
37 }
38}
diff --git a/OpenSim/Framework/UserManager/LoginResponse.cs b/OpenSim/Framework/UserManager/LoginResponse.cs
deleted file mode 100644
index b5a4184..0000000
--- a/OpenSim/Framework/UserManager/LoginResponse.cs
+++ /dev/null
@@ -1,667 +0,0 @@
1using System;
2using System.Collections;
3using libsecondlife;
4using Nwc.XmlRpc;
5using OpenSim.Framework.Console;
6
7namespace OpenSim.Framework.UserManagement
8{
9
10 /// <summary>
11 /// A temp class to handle login response.
12 /// Should make use of UserProfileManager where possible.
13 /// </summary>
14
15 public class LoginResponse
16 {
17 private Hashtable loginFlagsHash;
18 private Hashtable globalTexturesHash;
19 private Hashtable loginError;
20 private Hashtable uiConfigHash;
21
22 private ArrayList loginFlags;
23 private ArrayList globalTextures;
24 private ArrayList eventCategories;
25 private ArrayList uiConfig;
26 private ArrayList classifiedCategories;
27 private ArrayList inventoryRoot;
28 private ArrayList initialOutfit;
29 private ArrayList agentInventory;
30 private ArrayList inventoryLibraryOwner;
31 private ArrayList inventoryLibrary;
32
33 private UserInfo userProfile;
34
35 private LLUUID agentID;
36 private LLUUID sessionID;
37 private LLUUID secureSessionID;
38
39 // Login Flags
40 private string dst;
41 private string stipendSinceLogin;
42 private string gendered;
43 private string everLoggedIn;
44 private string login;
45 private int simPort;
46 private string simAddress;
47 private string agentAccess;
48 private Int32 circuitCode;
49 private uint regionX;
50 private uint regionY;
51
52 // Login
53 private string firstname;
54 private string lastname;
55
56 // Global Textures
57 private string sunTexture;
58 private string cloudTexture;
59 private string moonTexture;
60
61 // Error Flags
62 private string errorReason;
63 private string errorMessage;
64
65 // Response
66 private XmlRpcResponse xmlRpcResponse;
67 private XmlRpcResponse defaultXmlRpcResponse;
68
69 private string welcomeMessage;
70 private string startLocation;
71 private string allowFirstLife;
72 private string home;
73 private string seedCapability;
74 private string lookAt;
75
76 public LoginResponse()
77 {
78 this.loginFlags = new ArrayList();
79 this.globalTextures = new ArrayList();
80 this.eventCategories = new ArrayList();
81 this.uiConfig = new ArrayList();
82 this.classifiedCategories = new ArrayList();
83
84 this.loginError = new Hashtable();
85 this.uiConfigHash = new Hashtable();
86
87 this.defaultXmlRpcResponse = new XmlRpcResponse();
88 this.userProfile = new UserInfo();
89 this.inventoryRoot = new ArrayList();
90 this.initialOutfit = new ArrayList();
91 this.agentInventory = new ArrayList();
92 this.inventoryLibrary = new ArrayList();
93 this.inventoryLibraryOwner = new ArrayList();
94
95 this.xmlRpcResponse = new XmlRpcResponse();
96 this.defaultXmlRpcResponse = new XmlRpcResponse();
97
98 this.SetDefaultValues();
99 } // LoginServer
100
101 public void SetDefaultValues()
102 {
103 this.DST = "N";
104 this.StipendSinceLogin = "N";
105 this.Gendered = "Y";
106 this.EverLoggedIn = "Y";
107 this.login = "false";
108 this.firstname = "Test";
109 this.lastname = "User";
110 this.agentAccess = "M";
111 this.startLocation = "last";
112 this.allowFirstLife = "Y";
113
114 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
115 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
116 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
117
118 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
119 this.ErrorReason = "key";
120 this.welcomeMessage = "Welcome to OpenSim!";
121 this.seedCapability = "";
122 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() + "]}";
123 this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
124 this.RegionX = (uint)255232;
125 this.RegionY = (uint)254976;
126
127 // Classifieds;
128 this.AddClassifiedCategory((Int32)1, "Shopping");
129 this.AddClassifiedCategory((Int32)2, "Land Rental");
130 this.AddClassifiedCategory((Int32)3, "Property Rental");
131 this.AddClassifiedCategory((Int32)4, "Special Attraction");
132 this.AddClassifiedCategory((Int32)5, "New Products");
133 this.AddClassifiedCategory((Int32)6, "Employment");
134 this.AddClassifiedCategory((Int32)7, "Wanted");
135 this.AddClassifiedCategory((Int32)8, "Service");
136 this.AddClassifiedCategory((Int32)9, "Personal");
137
138
139 this.SessionID = LLUUID.Random();
140 this.SecureSessionID = LLUUID.Random();
141 this.AgentID = LLUUID.Random();
142
143 Hashtable InitialOutfitHash = new Hashtable();
144 InitialOutfitHash["folder_name"] = "Nightclub Female";
145 InitialOutfitHash["gender"] = "female";
146 this.initialOutfit.Add(InitialOutfitHash);
147
148
149 } // SetDefaultValues
150
151 #region Login Failure Methods
152 public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
153 {
154 // Overwrite any default values;
155 this.xmlRpcResponse = new XmlRpcResponse();
156
157 // Ensure Login Failed message/reason;
158 this.ErrorMessage = message;
159 this.ErrorReason = reason;
160
161 this.loginError["reason"] = this.ErrorReason;
162 this.loginError["message"] = this.ErrorMessage;
163 this.loginError["login"] = login;
164 this.xmlRpcResponse.Value = this.loginError;
165 return (this.xmlRpcResponse);
166 } // GenerateResponse
167
168 public XmlRpcResponse CreateFailedResponse()
169 {
170 return (this.CreateLoginFailedResponse());
171 } // CreateErrorConnectingToGridResponse()
172
173 public XmlRpcResponse CreateLoginFailedResponse()
174 {
175 return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"));
176 } // LoginFailedResponse
177
178 public XmlRpcResponse CreateAlreadyLoggedInResponse()
179 {
180 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"));
181 } // CreateAlreadyLoggedInResponse()
182
183 public XmlRpcResponse CreateDeadRegionResponse()
184 {
185 return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false"));
186 }
187
188 public XmlRpcResponse CreateGridErrorResponse()
189 {
190 return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false"));
191 }
192
193 #endregion
194
195 public XmlRpcResponse ToXmlRpcResponse()
196 {
197 try
198 {
199
200 Hashtable responseData = new Hashtable();
201
202 this.loginFlagsHash = new Hashtable();
203 this.loginFlagsHash["daylight_savings"] = this.DST;
204 this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
205 this.loginFlagsHash["gendered"] = this.Gendered;
206 this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
207 this.loginFlags.Add(this.loginFlagsHash);
208
209 responseData["first_name"] = this.Firstname;
210 responseData["last_name"] = this.Lastname;
211 responseData["agent_access"] = this.agentAccess;
212
213 this.globalTexturesHash = new Hashtable();
214 this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
215 this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
216 this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
217 this.globalTextures.Add(this.globalTexturesHash);
218 // this.eventCategories.Add(this.eventCategoriesHash);
219
220 this.AddToUIConfig("allow_first_life", this.allowFirstLife);
221 this.uiConfig.Add(this.uiConfigHash);
222
223 responseData["sim_port"] =(Int32) this.SimPort;
224 responseData["sim_ip"] = this.SimAddress;
225
226 responseData["agent_id"] = this.AgentID.ToStringHyphenated();
227 responseData["session_id"] = this.SessionID.ToStringHyphenated();
228 responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
229 responseData["circuit_code"] = this.CircuitCode;
230 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
231 responseData["login-flags"] = this.loginFlags;
232 responseData["global-textures"] = this.globalTextures;
233 responseData["seed_capability"] = this.seedCapability;
234
235 responseData["event_categories"] = this.eventCategories;
236 responseData["event_notifications"] = new ArrayList(); // todo
237 responseData["classified_categories"] = this.classifiedCategories;
238 responseData["ui-config"] = this.uiConfig;
239
240 responseData["inventory-skeleton"] = this.agentInventory;
241 responseData["inventory-skel-lib"] = this.inventoryLibrary;
242 responseData["inventory-root"] = this.inventoryRoot;
243 responseData["gestures"] = new ArrayList(); // todo
244 responseData["inventory-lib-owner"] = this.inventoryLibraryOwner;
245 responseData["initial-outfit"] = this.initialOutfit;
246 responseData["start_location"] = this.startLocation;
247 responseData["seed_capability"] = this.seedCapability;
248 responseData["home"] = this.home;
249 responseData["look_at"] = this.lookAt;
250 responseData["message"] = this.welcomeMessage;
251 responseData["region_x"] = (Int32)this.RegionX * 256;
252 responseData["region_y"] = (Int32)this.RegionY * 256;
253
254 //responseData["inventory-lib-root"] = new ArrayList(); // todo
255 //responseData["buddy-list"] = new ArrayList(); // todo
256
257 responseData["login"] = "true";
258 this.xmlRpcResponse.Value = responseData;
259
260 return (this.xmlRpcResponse);
261 }
262 catch (Exception e)
263 {
264 MainLog.Instance.Warn(
265 "CLIENT",
266 "LoginResponse: Error creating XML-RPC Response: " + e.Message
267 );
268 return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
269
270 }
271
272 } // ToXmlRpcResponse
273
274 public void SetEventCategories(string category, string value)
275 {
276 // this.eventCategoriesHash[category] = value;
277 //TODO
278 } // SetEventCategories
279
280 public void AddToUIConfig(string itemName, string item)
281 {
282 this.uiConfigHash[itemName] = item;
283 } // SetUIConfig
284
285 public void AddClassifiedCategory(Int32 ID, string categoryName)
286 {
287 Hashtable hash = new Hashtable();
288 hash["category_name"] = categoryName;
289 hash["category_id"] = ID;
290 this.classifiedCategories.Add(hash);
291 // this.classifiedCategoriesHash.Clear();
292 } // SetClassifiedCategory
293
294 #region Properties
295 public string Login
296 {
297 get
298 {
299 return this.login;
300 }
301 set
302 {
303 this.login = value;
304 }
305 } // Login
306
307 public string DST
308 {
309 get
310 {
311 return this.dst;
312 }
313 set
314 {
315 this.dst = value;
316 }
317 } // DST
318
319 public string StipendSinceLogin
320 {
321 get
322 {
323 return this.stipendSinceLogin;
324 }
325 set
326 {
327 this.stipendSinceLogin = value;
328 }
329 } // StipendSinceLogin
330
331 public string Gendered
332 {
333 get
334 {
335 return this.gendered;
336 }
337 set
338 {
339 this.gendered = value;
340 }
341 } // Gendered
342
343 public string EverLoggedIn
344 {
345 get
346 {
347 return this.everLoggedIn;
348 }
349 set
350 {
351 this.everLoggedIn = value;
352 }
353 } // EverLoggedIn
354
355 public int SimPort
356 {
357 get
358 {
359 return this.simPort;
360 }
361 set
362 {
363 this.simPort = value;
364 }
365 } // SimPort
366
367 public string SimAddress
368 {
369 get
370 {
371 return this.simAddress;
372 }
373 set
374 {
375 this.simAddress = value;
376 }
377 } // SimAddress
378
379 public LLUUID AgentID
380 {
381 get
382 {
383 return this.agentID;
384 }
385 set
386 {
387 this.agentID = value;
388 }
389 } // AgentID
390
391 public LLUUID SessionID
392 {
393 get
394 {
395 return this.sessionID;
396 }
397 set
398 {
399 this.sessionID = value;
400 }
401 } // SessionID
402
403 public LLUUID SecureSessionID
404 {
405 get
406 {
407 return this.secureSessionID;
408 }
409 set
410 {
411 this.secureSessionID = value;
412 }
413 } // SecureSessionID
414
415 public Int32 CircuitCode
416 {
417 get
418 {
419 return this.circuitCode;
420 }
421 set
422 {
423 this.circuitCode = value;
424 }
425 } // CircuitCode
426
427 public uint RegionX
428 {
429 get
430 {
431 return this.regionX;
432 }
433 set
434 {
435 this.regionX = value;
436 }
437 } // RegionX
438
439 public uint RegionY
440 {
441 get
442 {
443 return this.regionY;
444 }
445 set
446 {
447 this.regionY = value;
448 }
449 } // RegionY
450
451 public string SunTexture
452 {
453 get
454 {
455 return this.sunTexture;
456 }
457 set
458 {
459 this.sunTexture = value;
460 }
461 } // SunTexture
462
463 public string CloudTexture
464 {
465 get
466 {
467 return this.cloudTexture;
468 }
469 set
470 {
471 this.cloudTexture = value;
472 }
473 } // CloudTexture
474
475 public string MoonTexture
476 {
477 get
478 {
479 return this.moonTexture;
480 }
481 set
482 {
483 this.moonTexture = value;
484 }
485 } // MoonTexture
486
487 public string Firstname
488 {
489 get
490 {
491 return this.firstname;
492 }
493 set
494 {
495 this.firstname = value;
496 }
497 } // Firstname
498
499 public string Lastname
500 {
501 get
502 {
503 return this.lastname;
504 }
505 set
506 {
507 this.lastname = value;
508 }
509 } // Lastname
510
511 public string AgentAccess
512 {
513 get
514 {
515 return this.agentAccess;
516 }
517 set
518 {
519 this.agentAccess = value;
520 }
521 }
522
523 public string StartLocation
524 {
525 get
526 {
527 return this.startLocation;
528 }
529 set
530 {
531 this.startLocation = value;
532 }
533 } // StartLocation
534
535 public string LookAt
536 {
537 get
538 {
539 return this.lookAt;
540 }
541 set
542 {
543 this.lookAt = value;
544 }
545 }
546
547 public string SeedCapability
548 {
549 get
550 {
551 return this.seedCapability;
552 }
553 set
554 {
555 this.seedCapability = value;
556 }
557 } // SeedCapability
558
559 public string ErrorReason
560 {
561 get
562 {
563 return this.errorReason;
564 }
565 set
566 {
567 this.errorReason = value;
568 }
569 } // ErrorReason
570
571 public string ErrorMessage
572 {
573 get
574 {
575 return this.errorMessage;
576 }
577 set
578 {
579 this.errorMessage = value;
580 }
581 } // ErrorMessage
582
583 public ArrayList InventoryRoot
584 {
585 get
586 {
587 return this.inventoryRoot;
588 }
589 set
590 {
591 this.inventoryRoot = value;
592 }
593 }
594
595 public ArrayList InventorySkeleton
596 {
597 get
598 {
599 return this.agentInventory;
600 }
601 set
602 {
603 this.agentInventory = value;
604 }
605 }
606
607 public ArrayList InventoryLibrary
608 {
609 get
610 {
611 return this.inventoryLibrary;
612 }
613 set
614 {
615 this.inventoryLibrary = value;
616 }
617 }
618
619 public ArrayList InventoryLibraryOwner
620 {
621 get
622 {
623 return this.inventoryLibraryOwner;
624 }
625 set
626 {
627 this.inventoryLibraryOwner = value;
628 }
629 }
630
631 public string Home
632 {
633 get
634 {
635 return this.home;
636 }
637 set
638 {
639 this.home = value;
640 }
641 }
642
643 public string Message
644 {
645 get
646 {
647 return this.welcomeMessage;
648 }
649 set
650 {
651 this.welcomeMessage = value;
652 }
653 }
654 #endregion
655
656
657 public class UserInfo
658 {
659 public string firstname;
660 public string lastname;
661 public ulong homeregionhandle;
662 public LLVector3 homepos;
663 public LLVector3 homelookat;
664 }
665 }
666}
667
diff --git a/OpenSim/Framework/UserManager/LoginService.cs b/OpenSim/Framework/UserManager/LoginService.cs
deleted file mode 100644
index 8e7cf80..0000000
--- a/OpenSim/Framework/UserManager/LoginService.cs
+++ /dev/null
@@ -1,287 +0,0 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Reflection;
5using System.Security.Cryptography;
6using libsecondlife;
7using Nwc.XmlRpc;
8using OpenSim.Framework.Console;
9using OpenSim.Framework.Data;
10using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Inventory;
12using OpenSim.Framework.Utilities;
13
14using OpenSim.Framework.Configuration;
15using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder;
16
17namespace OpenSim.Framework.UserManagement
18{
19 public class LoginService
20 {
21 protected string m_welcomeMessage = "Welcome to OpenSim";
22 protected UserManagerBase m_userManager = null;
23
24 public LoginService(UserManagerBase userManager, string welcomeMess)
25 {
26 m_userManager = userManager;
27 if (welcomeMess != "")
28 {
29 m_welcomeMessage = welcomeMess;
30 }
31 }
32
33 /// <summary>
34 /// Main user login function
35 /// </summary>
36 /// <param name="request">The XMLRPC request</param>
37 /// <returns>The response to send</returns>
38 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
39 {
40
41 System.Console.WriteLine("Attempting login now...");
42 XmlRpcResponse response = new XmlRpcResponse();
43 Hashtable requestData = (Hashtable)request.Params[0];
44
45 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
46 bool GoodLogin = false;
47
48 UserProfileData userProfile;
49 LoginResponse logResponse = new LoginResponse();
50
51 if (GoodXML)
52 {
53 string firstname = (string)requestData["first"];
54 string lastname = (string)requestData["last"];
55 string passwd = (string)requestData["passwd"];
56
57 userProfile = GetTheUser(firstname, lastname);
58 if (userProfile == null)
59 return logResponse.CreateLoginFailedResponse();
60
61 GoodLogin = AuthenticateUser(userProfile, passwd);
62 }
63 else
64 {
65 return logResponse.CreateGridErrorResponse();
66 }
67
68 if (!GoodLogin)
69 {
70 return logResponse.CreateLoginFailedResponse();
71 }
72 else
73 {
74 // If we already have a session...
75 if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline)
76 {
77 // Reject the login
78 return logResponse.CreateAlreadyLoggedInResponse();
79 }
80 // Otherwise...
81 // Create a new agent session
82 CreateAgent(userProfile, request);
83
84 try
85 {
86 LLUUID agentID = userProfile.UUID;
87
88 // Inventory Library Section
89 InventoryData inventData = this.CreateInventoryData(agentID);
90 ArrayList AgentInventoryArray = inventData.InventoryArray;
91
92 Hashtable InventoryRootHash = new Hashtable();
93 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated();
94 ArrayList InventoryRoot = new ArrayList();
95 InventoryRoot.Add(InventoryRootHash);
96 userProfile.rootInventoryFolderID = inventData.RootFolderID;
97
98 // Circuit Code
99 uint circode = (uint)(Util.RandomClass.Next());
100
101 logResponse.Lastname = userProfile.surname;
102 logResponse.Firstname = userProfile.username;
103 logResponse.AgentID = agentID.ToStringHyphenated();
104 logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated();
105 logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated();
106 logResponse.InventoryRoot = InventoryRoot;
107 logResponse.InventorySkeleton = AgentInventoryArray;
108 logResponse.InventoryLibrary = this.GetInventoryLibrary();
109 logResponse.InventoryLibraryOwner = this.GetLibraryOwner();
110 logResponse.CircuitCode = (Int32)circode;
111 //logResponse.RegionX = 0; //overwritten
112 //logResponse.RegionY = 0; //overwritten
113 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
114 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
115 //logResponse.SimAddress = "127.0.0.1"; //overwritten
116 //logResponse.SimPort = 0; //overwritten
117 logResponse.Message = this.GetMessage();
118
119 try
120 {
121 this.CustomiseResponse(logResponse, userProfile);
122 }
123 catch (Exception e)
124 {
125 System.Console.WriteLine(e.ToString());
126 return logResponse.CreateDeadRegionResponse();
127 //return logResponse.ToXmlRpcResponse();
128 }
129 CommitAgent(ref userProfile);
130 return logResponse.ToXmlRpcResponse();
131
132 }
133
134 catch (Exception E)
135 {
136 System.Console.WriteLine(E.ToString());
137 }
138 //}
139 }
140 return response;
141
142 }
143
144 /// <summary>
145 /// Customises the login response and fills in missing values.
146 /// </summary>
147 /// <param name="response">The existing response</param>
148 /// <param name="theUser">The user profile</param>
149 public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser)
150 {
151 }
152
153 /// <summary>
154 /// Saves a target agent to the database
155 /// </summary>
156 /// <param name="profile">The users profile</param>
157 /// <returns>Successful?</returns>
158 public bool CommitAgent(ref UserProfileData profile)
159 {
160 // Saves the agent to database
161 return true;
162 }
163
164
165 /// <summary>
166 /// Checks a user against it's password hash
167 /// </summary>
168 /// <param name="profile">The users profile</param>
169 /// <param name="password">The supplied password</param>
170 /// <returns>Authenticated?</returns>
171 public virtual bool AuthenticateUser(UserProfileData profile, string password)
172 {
173
174 MainLog.Instance.Verbose(
175 "Authenticating " + profile.username + " " + profile.surname);
176
177 password = password.Remove(0, 3); //remove $1$
178
179 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
180
181 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
182 }
183
184 /// <summary>
185 ///
186 /// </summary>
187 /// <param name="profile"></param>
188 /// <param name="request"></param>
189 public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
190 {
191 this.m_userManager.CreateAgent(profile, request);
192 }
193
194 /// <summary>
195 ///
196 /// </summary>
197 /// <param name="firstname"></param>
198 /// <param name="lastname"></param>
199 /// <returns></returns>
200 public virtual UserProfileData GetTheUser(string firstname, string lastname)
201 {
202 return this.m_userManager.GetUserProfile(firstname, lastname);
203 }
204
205 /// <summary>
206 ///
207 /// </summary>
208 /// <returns></returns>
209 public virtual string GetMessage()
210 {
211 return m_welcomeMessage;
212 }
213
214 /// <summary>
215 ///
216 /// </summary>
217 /// <returns></returns>
218 protected virtual ArrayList GetInventoryLibrary()
219 {
220 //return new ArrayList();
221 Hashtable TempHash = new Hashtable();
222 TempHash["name"] = "OpenSim Library";
223 TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated();
224 TempHash["version"] = 1;
225 TempHash["type_default"] = -1;
226 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
227 ArrayList temp = new ArrayList();
228 temp.Add(TempHash);
229
230 TempHash = new Hashtable();
231 TempHash["name"] = "Texture Library";
232 TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000";
233 TempHash["version"] = 1;
234 TempHash["type_default"] = -1;
235 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001";
236 temp.Add(TempHash);
237 return temp;
238 }
239
240 /// <summary>
241 ///
242 /// </summary>
243 /// <returns></returns>
244 protected virtual ArrayList GetLibraryOwner()
245 {
246 //for now create random inventory library owner
247 Hashtable TempHash = new Hashtable();
248 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000";
249 ArrayList inventoryLibOwner = new ArrayList();
250 inventoryLibOwner.Add(TempHash);
251 return inventoryLibOwner;
252 }
253
254 protected virtual InventoryData CreateInventoryData(LLUUID userID)
255 {
256 AgentInventory userInventory = new AgentInventory();
257 userInventory.CreateRootFolder(userID, false);
258
259 ArrayList AgentInventoryArray = new ArrayList();
260 Hashtable TempHash;
261 foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
262 {
263 TempHash = new Hashtable();
264 TempHash["name"] = InvFolder.FolderName;
265 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
266 TempHash["version"] = (Int32)InvFolder.Version;
267 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
268 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
269 AgentInventoryArray.Add(TempHash);
270 }
271
272 return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
273 }
274
275 public class InventoryData
276 {
277 public ArrayList InventoryArray = null;
278 public LLUUID RootFolderID = LLUUID.Zero;
279
280 public InventoryData(ArrayList invList, LLUUID rootID)
281 {
282 InventoryArray = invList;
283 RootFolderID = rootID;
284 }
285 }
286 }
287}
diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs
deleted file mode 100644
index 4a2870b..0000000
--- a/OpenSim/Framework/UserManager/UserManagerBase.cs
+++ /dev/null
@@ -1,377 +0,0 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.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 System;
30using System.Collections;
31using System.Collections.Generic;
32using System.Reflection;
33using System.Security.Cryptography;
34using libsecondlife;
35using Nwc.XmlRpc;
36using OpenSim.Framework.Configuration;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Data;
39using OpenSim.Framework.Utilities;
40
41namespace OpenSim.Framework.UserManagement
42{
43 public abstract class UserManagerBase
44 {
45 public UserConfig _config;
46 Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
47
48 /// <summary>
49 /// Adds a new user server plugin - user servers will be requested in the order they were loaded.
50 /// </summary>
51 /// <param name="FileName">The filename to the user server plugin DLL</param>
52 public void AddPlugin(string FileName)
53 {
54 if (!String.IsNullOrEmpty(FileName))
55 {
56 MainLog.Instance.Verbose("Userstorage: Attempting to load " + FileName);
57 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
58
59 MainLog.Instance.Verbose("Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
60 foreach (Type pluginType in pluginAssembly.GetTypes())
61 {
62 if (!pluginType.IsAbstract)
63 {
64 Type typeInterface = pluginType.GetInterface("IUserData", true);
65
66 if (typeInterface != null)
67 {
68 IUserData plug =
69 (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
70 AddPlugin(plug);
71 }
72 }
73 }
74 }
75 }
76
77 public void AddPlugin(IUserData plug)
78 {
79 plug.Initialise();
80 this._plugins.Add(plug.getName(), plug);
81 MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface");
82 }
83
84 #region Get UserProfile
85 /// <summary>
86 /// Loads a user profile from a database by UUID
87 /// </summary>
88 /// <param name="uuid">The target UUID</param>
89 /// <returns>A user profile</returns>
90 public UserProfileData GetUserProfile(LLUUID uuid)
91 {
92 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
93 {
94 try
95 {
96 UserProfileData profile = plugin.Value.GetUserByUUID(uuid);
97 profile.currentAgent = getUserAgent(profile.UUID);
98 return profile;
99 }
100 catch (Exception e)
101 {
102 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
103 }
104 }
105
106 return null;
107 }
108
109
110 /// <summary>
111 /// Loads a user profile by name
112 /// </summary>
113 /// <param name="name">The target name</param>
114 /// <returns>A user profile</returns>
115 public UserProfileData GetUserProfile(string name)
116 {
117 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
118 {
119 try
120 {
121 UserProfileData profile = plugin.Value.GetUserByName(name);
122 profile.currentAgent = getUserAgent(profile.UUID);
123 return profile;
124 }
125 catch (Exception e)
126 {
127 System.Console.WriteLine("EEK!");
128 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
129 }
130 }
131
132 return null;
133 }
134
135 /// <summary>
136 /// Loads a user profile by name
137 /// </summary>
138 /// <param name="fname">First name</param>
139 /// <param name="lname">Last name</param>
140 /// <returns>A user profile</returns>
141 public UserProfileData GetUserProfile(string fname, string lname)
142 {
143 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
144 {
145 try
146 {
147 UserProfileData profile = plugin.Value.GetUserByName(fname,lname);
148
149 profile.currentAgent = getUserAgent(profile.UUID);
150
151 return profile;
152 }
153 catch (Exception e)
154 {
155 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
156 }
157 }
158
159 return null;
160 }
161
162 /// <summary>
163 /// Set's user profile from object
164 /// </summary>
165 /// <param name="fname">First name</param>
166 /// <param name="lname">Last name</param>
167 /// <returns>A user profile</returns>
168 public bool setUserProfile(UserProfileData data)
169 {
170 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
171 {
172 try {
173 plugin.Value.UpdateUserProfile(data);
174 return true;
175 } catch (Exception e) {
176 MainLog.Instance.Verbose( "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")");
177 }
178 }
179
180 return false;
181 }
182
183 #endregion
184
185 #region Get UserAgent
186 /// <summary>
187 /// Loads a user agent by uuid (not called directly)
188 /// </summary>
189 /// <param name="uuid">The agents UUID</param>
190 /// <returns>Agent profiles</returns>
191 public UserAgentData getUserAgent(LLUUID uuid)
192 {
193 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
194 {
195 try
196 {
197 return plugin.Value.GetAgentByUUID(uuid);
198 }
199 catch (Exception e)
200 {
201 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
202 }
203 }
204
205 return null;
206 }
207
208 /// <summary>
209 /// Loads a user agent by name (not called directly)
210 /// </summary>
211 /// <param name="name">The agents name</param>
212 /// <returns>A user agent</returns>
213 public UserAgentData getUserAgent(string name)
214 {
215 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
216 {
217 try
218 {
219 return plugin.Value.GetAgentByName(name);
220 }
221 catch (Exception e)
222 {
223 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
224 }
225 }
226
227 return null;
228 }
229
230 // TODO: document
231 public void clearUserAgent(LLUUID agentID)
232 {
233 UserProfileData profile = GetUserProfile(agentID);
234 profile.currentAgent = null;
235 setUserProfile(profile);
236 }
237
238
239 /// <summary>
240 /// Loads a user agent by name (not called directly)
241 /// </summary>
242 /// <param name="fname">The agents firstname</param>
243 /// <param name="lname">The agents lastname</param>
244 /// <returns>A user agent</returns>
245 public UserAgentData getUserAgent(string fname, string lname)
246 {
247 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
248 {
249 try
250 {
251 return plugin.Value.GetAgentByName(fname,lname);
252 }
253 catch (Exception e)
254 {
255 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
256 }
257 }
258
259 return null;
260 }
261
262 #endregion
263
264 #region CreateAgent
265 /// <summary>
266 /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
267 /// </summary>
268 /// <param name="profile">The users profile</param>
269 /// <param name="request">The users loginrequest</param>
270 public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
271 {
272 Hashtable requestData = (Hashtable)request.Params[0];
273
274 UserAgentData agent = new UserAgentData();
275
276 // User connection
277 agent.agentOnline = true;
278
279 // Generate sessions
280 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
281 byte[] randDataS = new byte[16];
282 byte[] randDataSS = new byte[16];
283 rand.GetBytes(randDataS);
284 rand.GetBytes(randDataSS);
285
286 agent.secureSessionID = new LLUUID(randDataSS, 0);
287 agent.sessionID = new LLUUID(randDataS, 0);
288
289 // Profile UUID
290 agent.UUID = profile.UUID;
291
292 // Current position (from Home)
293 agent.currentHandle = profile.homeRegion;
294 agent.currentPos = profile.homeLocation;
295
296 // If user specified additional start, use that
297 if (requestData.ContainsKey("start"))
298 {
299 string startLoc = ((string)requestData["start"]).Trim();
300 if (!(startLoc == "last" || startLoc == "home"))
301 {
302 // Format: uri:Ahern&162&213&34
303 try
304 {
305 string[] parts = startLoc.Remove(0, 4).Split('&');
306 string region = parts[0];
307
308 ////////////////////////////////////////////////////
309 //SimProfile SimInfo = new SimProfile();
310 //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
311 }
312 catch (Exception)
313 {
314
315 }
316 }
317 }
318
319 // What time did the user login?
320 agent.loginTime = Util.UnixTimeSinceEpoch();
321 agent.logoutTime = 0;
322
323 // Current location
324 agent.regionID = new LLUUID(); // Fill in later
325 agent.currentRegion = new LLUUID(); // Fill in later
326
327 profile.currentAgent = agent;
328 }
329
330 /// <summary>
331 /// Saves a target agent to the database
332 /// </summary>
333 /// <param name="profile">The users profile</param>
334 /// <returns>Successful?</returns>
335 public bool CommitAgent(ref UserProfileData profile)
336 {
337 // Saves the agent to database
338 return true;
339 }
340
341 #endregion
342
343 /// <summary>
344 ///
345 /// </summary>
346 /// <param name="user"></param>
347 public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
348 {
349 UserProfileData user = new UserProfileData();
350 user.homeLocation = new LLVector3(128, 128, 100);
351 user.UUID = LLUUID.Random();
352 user.username = firstName;
353 user.surname = lastName;
354 user.passwordHash = pass;
355 user.passwordSalt = "";
356 user.created = Util.UnixTimeSinceEpoch();
357 user.homeLookAt = new LLVector3(100, 100, 100);
358 user.homeRegionX = regX;
359 user.homeRegionY = regY;
360
361 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
362 {
363 try
364 {
365 plugin.Value.AddNewUserProfile(user);
366
367 }
368 catch (Exception e)
369 {
370 MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")");
371 }
372 }
373 }
374
375 // Rest and XML-RPC methods. (have moved them to a sub class in the user server)
376 }
377}