diff options
author | MW | 2007-08-13 15:55:36 +0000 |
---|---|---|
committer | MW | 2007-08-13 15:55:36 +0000 |
commit | 04b1767886af28fa1793c46a1cbe4b3f49eefca6 (patch) | |
tree | f7c1fc2fc19a5dce8e4e78537ff6a87c75a7dda2 | |
parent | Added the SetPartText access method to SceneObjectGroup to set the text of me... (diff) | |
download | opensim-SC-04b1767886af28fa1793c46a1cbe4b3f49eefca6.zip opensim-SC-04b1767886af28fa1793c46a1cbe4b3f49eefca6.tar.gz opensim-SC-04b1767886af28fa1793c46a1cbe4b3f49eefca6.tar.bz2 opensim-SC-04b1767886af28fa1793c46a1cbe4b3f49eefca6.tar.xz |
Separated Login Service from usermanager, which helps to clean up the code a bit and also should help to integrate the inventory server (when it is wrote/finished).
-rw-r--r-- | OpenSim/Framework/UserManager/UserManagerBase.cs | 258 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/Main.cs | 5 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/UserManager.cs | 57 | ||||
-rw-r--r-- | OpenSim/Region/Communications/Local/CommunicationsLocal.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/Communications/Local/LocalUserServices.cs | 101 |
5 files changed, 31 insertions, 404 deletions
diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index 64c3be1..c1084e9 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs | |||
@@ -339,248 +339,6 @@ namespace OpenSim.Framework.UserManagement | |||
339 | #endregion | 339 | #endregion |
340 | 340 | ||
341 | /// <summary> | 341 | /// <summary> |
342 | /// Checks a user against it's password hash | ||
343 | /// </summary> | ||
344 | /// <param name="profile">The users profile</param> | ||
345 | /// <param name="password">The supplied password</param> | ||
346 | /// <returns>Authenticated?</returns> | ||
347 | public virtual bool AuthenticateUser(UserProfileData profile, string password) | ||
348 | { | ||
349 | MainLog.Instance.Verbose( | ||
350 | "Authenticating " + profile.username + " " + profile.surname); | ||
351 | |||
352 | password = password.Remove(0, 3); //remove $1$ | ||
353 | |||
354 | string s = Util.Md5Hash(password + ":" + profile.passwordSalt); | ||
355 | |||
356 | return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); | ||
357 | } | ||
358 | |||
359 | #region Xml Response | ||
360 | |||
361 | /// <summary> | ||
362 | /// | ||
363 | /// </summary> | ||
364 | /// <param name="firstname"></param> | ||
365 | /// <param name="lastname"></param> | ||
366 | /// <returns></returns> | ||
367 | public virtual UserProfileData GetTheUser(string firstname, string lastname) | ||
368 | { | ||
369 | return getUserProfile(firstname, lastname); | ||
370 | } | ||
371 | |||
372 | /// <summary> | ||
373 | /// | ||
374 | /// </summary> | ||
375 | /// <returns></returns> | ||
376 | public virtual string GetMessage() | ||
377 | { | ||
378 | return _config.DefaultStartupMsg; | ||
379 | } | ||
380 | |||
381 | /// <summary> | ||
382 | /// | ||
383 | /// </summary> | ||
384 | /// <returns></returns> | ||
385 | protected virtual ArrayList GetInventoryLibrary() | ||
386 | { | ||
387 | //return new ArrayList(); | ||
388 | Hashtable TempHash = new Hashtable(); | ||
389 | TempHash["name"] = "OpenSim Library"; | ||
390 | TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); | ||
391 | TempHash["version"] = "1"; | ||
392 | TempHash["type_default"] = "-1"; | ||
393 | TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | ||
394 | ArrayList temp = new ArrayList(); | ||
395 | temp.Add(TempHash); | ||
396 | |||
397 | TempHash = new Hashtable(); | ||
398 | TempHash["name"] = "Texture Library"; | ||
399 | TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; | ||
400 | TempHash["version"] = "1"; | ||
401 | TempHash["type_default"] = "-1"; | ||
402 | TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; | ||
403 | temp.Add(TempHash); | ||
404 | return temp; | ||
405 | } | ||
406 | |||
407 | /// <summary> | ||
408 | /// | ||
409 | /// </summary> | ||
410 | /// <returns></returns> | ||
411 | protected virtual ArrayList GetLibraryOwner() | ||
412 | { | ||
413 | //for now create random inventory library owner | ||
414 | Hashtable TempHash = new Hashtable(); | ||
415 | TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; | ||
416 | ArrayList inventoryLibOwner = new ArrayList(); | ||
417 | inventoryLibOwner.Add(TempHash); | ||
418 | return inventoryLibOwner; | ||
419 | } | ||
420 | |||
421 | protected virtual AgentInventory GetUsersInventory(LLUUID agentID) | ||
422 | { | ||
423 | AgentInventory userInventory = new AgentInventory(); | ||
424 | userInventory.CreateRootFolder(agentID, false); | ||
425 | |||
426 | return userInventory; | ||
427 | } | ||
428 | |||
429 | protected virtual ArrayList CreateInventoryArray(AgentInventory userInventory) | ||
430 | { | ||
431 | ArrayList AgentInventoryArray = new ArrayList(); | ||
432 | Hashtable TempHash; | ||
433 | foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) | ||
434 | { | ||
435 | TempHash = new Hashtable(); | ||
436 | TempHash["name"] = InvFolder.FolderName; | ||
437 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
438 | TempHash["version"] = (Int32)InvFolder.Version; | ||
439 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
440 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
441 | AgentInventoryArray.Add(TempHash); | ||
442 | } | ||
443 | return AgentInventoryArray; | ||
444 | } | ||
445 | |||
446 | /// <summary> | ||
447 | /// Customises the login response and fills in missing values. | ||
448 | /// </summary> | ||
449 | /// <param name="response">The existing response</param> | ||
450 | /// <param name="theUser">The user profile</param> | ||
451 | public abstract void CustomiseResponse( LoginResponse response, UserProfileData theUser); | ||
452 | |||
453 | /// <summary> | ||
454 | /// Main user login function | ||
455 | /// </summary> | ||
456 | /// <param name="request">The XMLRPC request</param> | ||
457 | /// <returns>The response to send</returns> | ||
458 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
459 | { | ||
460 | |||
461 | System.Console.WriteLine("Attempting login now..."); | ||
462 | XmlRpcResponse response = new XmlRpcResponse(); | ||
463 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
464 | |||
465 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); | ||
466 | bool GoodLogin = false; | ||
467 | string firstname = ""; | ||
468 | string lastname = ""; | ||
469 | string passwd = ""; | ||
470 | |||
471 | UserProfileData userProfile; | ||
472 | LoginResponse logResponse = new LoginResponse(); | ||
473 | |||
474 | if (GoodXML) | ||
475 | { | ||
476 | firstname = (string)requestData["first"]; | ||
477 | lastname = (string)requestData["last"]; | ||
478 | passwd = (string)requestData["passwd"]; | ||
479 | |||
480 | userProfile = GetTheUser(firstname, lastname); | ||
481 | if (userProfile == null) | ||
482 | return logResponse.CreateLoginFailedResponse(); | ||
483 | |||
484 | GoodLogin = AuthenticateUser(userProfile, passwd); | ||
485 | } | ||
486 | else | ||
487 | { | ||
488 | return logResponse.CreateGridErrorResponse(); | ||
489 | } | ||
490 | |||
491 | if (!GoodLogin) | ||
492 | { | ||
493 | return logResponse.CreateLoginFailedResponse(); | ||
494 | } | ||
495 | else | ||
496 | { | ||
497 | // If we already have a session... | ||
498 | if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) | ||
499 | { | ||
500 | // Reject the login | ||
501 | return logResponse.CreateAlreadyLoggedInResponse(); | ||
502 | } | ||
503 | // Otherwise... | ||
504 | // Create a new agent session | ||
505 | CreateAgent( userProfile, request); | ||
506 | |||
507 | try | ||
508 | { | ||
509 | LLUUID agentID = userProfile.UUID; | ||
510 | |||
511 | // Inventory Library Section | ||
512 | AgentInventory userInventory = this.GetUsersInventory(agentID); | ||
513 | ArrayList AgentInventoryArray = this.CreateInventoryArray(userInventory); | ||
514 | |||
515 | Hashtable InventoryRootHash = new Hashtable(); | ||
516 | InventoryRootHash["folder_id"] = userInventory.InventoryRoot.FolderID.ToStringHyphenated(); | ||
517 | ArrayList InventoryRoot = new ArrayList(); | ||
518 | InventoryRoot.Add(InventoryRootHash); | ||
519 | userProfile.rootInventoryFolderID = userInventory.InventoryRoot.FolderID; | ||
520 | |||
521 | // Circuit Code | ||
522 | uint circode = (uint)(Util.RandomClass.Next()); | ||
523 | |||
524 | logResponse.Lastname = userProfile.surname; | ||
525 | logResponse.Firstname = userProfile.username; | ||
526 | logResponse.AgentID = agentID.ToStringHyphenated(); | ||
527 | logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); | ||
528 | logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); | ||
529 | logResponse.InventoryRoot = InventoryRoot; | ||
530 | logResponse.InventorySkeleton = AgentInventoryArray; | ||
531 | logResponse.InventoryLibrary = this.GetInventoryLibrary(); | ||
532 | logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); | ||
533 | logResponse.CircuitCode = (Int32)circode; | ||
534 | //logResponse.RegionX = 0; //overwritten | ||
535 | //logResponse.RegionY = 0; //overwritten | ||
536 | logResponse.Home = "!!null temporary value {home}!!"; // Overwritten | ||
537 | //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; | ||
538 | //logResponse.SimAddress = "127.0.0.1"; //overwritten | ||
539 | //logResponse.SimPort = 0; //overwritten | ||
540 | logResponse.Message = this.GetMessage(); | ||
541 | |||
542 | try | ||
543 | { | ||
544 | this.CustomiseResponse( logResponse, userProfile); | ||
545 | } | ||
546 | catch (Exception e) | ||
547 | { | ||
548 | System.Console.WriteLine(e.ToString()); | ||
549 | return logResponse.CreateDeadRegionResponse(); | ||
550 | //return logResponse.ToXmlRpcResponse(); | ||
551 | } | ||
552 | CommitAgent(ref userProfile); | ||
553 | return logResponse.ToXmlRpcResponse(); | ||
554 | |||
555 | } | ||
556 | |||
557 | catch (Exception E) | ||
558 | { | ||
559 | System.Console.WriteLine(E.ToString()); | ||
560 | } | ||
561 | //} | ||
562 | } | ||
563 | return response; | ||
564 | |||
565 | } | ||
566 | |||
567 | #endregion | ||
568 | |||
569 | /// <summary> | ||
570 | /// Deletes an active agent session | ||
571 | /// </summary> | ||
572 | /// <param name="request">The request</param> | ||
573 | /// <param name="path">The path (eg /bork/narf/test)</param> | ||
574 | /// <param name="param">Parameters sent</param> | ||
575 | /// <returns>Success "OK" else error</returns> | ||
576 | public string RestDeleteUserSessionMethod(string request, string path, string param) | ||
577 | { | ||
578 | // TODO! Important! | ||
579 | |||
580 | return "OK"; | ||
581 | } | ||
582 | |||
583 | /// <summary> | ||
584 | /// | 342 | /// |
585 | /// </summary> | 343 | /// </summary> |
586 | /// <param name="user"></param> | 344 | /// <param name="user"></param> |
@@ -611,6 +369,22 @@ namespace OpenSim.Framework.UserManagement | |||
611 | } | 369 | } |
612 | } | 370 | } |
613 | 371 | ||
372 | // Rest and XML-RPC methods. (could move them to a sub class in the user server?) | ||
373 | |||
374 | /// <summary> | ||
375 | /// Deletes an active agent session | ||
376 | /// </summary> | ||
377 | /// <param name="request">The request</param> | ||
378 | /// <param name="path">The path (eg /bork/narf/test)</param> | ||
379 | /// <param name="param">Parameters sent</param> | ||
380 | /// <returns>Success "OK" else error</returns> | ||
381 | public string RestDeleteUserSessionMethod(string request, string path, string param) | ||
382 | { | ||
383 | // TODO! Important! | ||
384 | |||
385 | return "OK"; | ||
386 | } | ||
387 | |||
614 | /// <summary> | 388 | /// <summary> |
615 | /// Returns an error message that the user could not be found in the database | 389 | /// Returns an error message that the user could not be found in the database |
616 | /// </summary> | 390 | /// </summary> |
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 04f45b0..82bbd57 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs | |||
@@ -47,6 +47,7 @@ namespace OpenSim.Grid.UserServer | |||
47 | private UserConfig Cfg; | 47 | private UserConfig Cfg; |
48 | 48 | ||
49 | public UserManager m_userManager; | 49 | public UserManager m_userManager; |
50 | public UserLoginService m_loginService; | ||
50 | 51 | ||
51 | public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>(); | 52 | public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>(); |
52 | 53 | ||
@@ -92,10 +93,12 @@ namespace OpenSim.Grid.UserServer | |||
92 | m_userManager._config = Cfg; | 93 | m_userManager._config = Cfg; |
93 | m_userManager.AddPlugin(Cfg.DatabaseProvider); | 94 | m_userManager.AddPlugin(Cfg.DatabaseProvider); |
94 | 95 | ||
96 | m_loginService = new UserLoginService(m_userManager, Cfg, Cfg.DefaultStartupMsg); | ||
97 | |||
95 | MainLog.Instance.Verbose("Main.cs:Startup() - Starting HTTP process"); | 98 | MainLog.Instance.Verbose("Main.cs:Startup() - Starting HTTP process"); |
96 | BaseHttpServer httpServer = new BaseHttpServer(8002); | 99 | BaseHttpServer httpServer = new BaseHttpServer(8002); |
97 | 100 | ||
98 | httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod); | 101 | httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); |
99 | 102 | ||
100 | httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); | 103 | httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); |
101 | httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); | 104 | httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); |
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index c459b93..4203ba6 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs | |||
@@ -41,61 +41,6 @@ namespace OpenSim.Grid.UserServer | |||
41 | { | 41 | { |
42 | } | 42 | } |
43 | 43 | ||
44 | /// <summary> | 44 | |
45 | /// Customises the login response and fills in missing values. | ||
46 | /// </summary> | ||
47 | /// <param name="response">The existing response</param> | ||
48 | /// <param name="theUser">The user profile</param> | ||
49 | public override void CustomiseResponse( LoginResponse response, UserProfileData theUser) | ||
50 | { | ||
51 | // Load information from the gridserver | ||
52 | SimProfileData SimInfo = new SimProfileData(); | ||
53 | SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); | ||
54 | |||
55 | // Customise the response | ||
56 | // Home Location | ||
57 | response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " + | ||
58 | "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + | ||
59 | "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; | ||
60 | |||
61 | // Destination | ||
62 | Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY); | ||
63 | response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); | ||
64 | response.SimPort = (Int32)SimInfo.serverPort; | ||
65 | response.RegionX = SimInfo.regionLocX; | ||
66 | response.RegionY = SimInfo.regionLocY; | ||
67 | |||
68 | //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI | ||
69 | string capsPath = Util.GetRandomCapsPath(); | ||
70 | response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; | ||
71 | |||
72 | // Notify the target of an incoming user | ||
73 | Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI+ ")"); | ||
74 | |||
75 | // Prepare notification | ||
76 | Hashtable SimParams = new Hashtable(); | ||
77 | SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); | ||
78 | SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); | ||
79 | SimParams["firstname"] = theUser.username; | ||
80 | SimParams["lastname"] = theUser.surname; | ||
81 | SimParams["agent_id"] = theUser.UUID.ToString(); | ||
82 | SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); | ||
83 | SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); | ||
84 | SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); | ||
85 | SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); | ||
86 | SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); | ||
87 | SimParams["caps_path"] = capsPath; | ||
88 | ArrayList SendParams = new ArrayList(); | ||
89 | SendParams.Add(SimParams); | ||
90 | |||
91 | // Update agent with target sim | ||
92 | theUser.currentAgent.currentRegion = SimInfo.UUID; | ||
93 | theUser.currentAgent.currentHandle = SimInfo.regionHandle; | ||
94 | |||
95 | System.Console.WriteLine("Informing region --> " + SimInfo.httpServerURI); | ||
96 | // Send | ||
97 | XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); | ||
98 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 3000); | ||
99 | } | ||
100 | } | 45 | } |
101 | } | 46 | } |
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index a0bbf6d..3ad33f4 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs | |||
@@ -37,23 +37,25 @@ namespace OpenSim.Region.Communications.Local | |||
37 | { | 37 | { |
38 | public class CommunicationsLocal : CommunicationsManager | 38 | public class CommunicationsLocal : CommunicationsManager |
39 | { | 39 | { |
40 | public LocalBackEndServices SandBoxServices = new LocalBackEndServices(); | 40 | public LocalBackEndServices InstanceServices = new LocalBackEndServices(); |
41 | public LocalUserServices UserServices; | 41 | public LocalUserServices UserServices; |
42 | public LocalLoginService LoginServices; | ||
42 | 43 | ||
43 | public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool accountsAuthenticate, string welcomeMessage ) | 44 | public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool accountsAuthenticate, string welcomeMessage ) |
44 | : base(serversInfo, httpServer, assetCache) | 45 | : base(serversInfo, httpServer, assetCache) |
45 | { | 46 | { |
46 | UserServices = new LocalUserServices(this, serversInfo, accountsAuthenticate, welcomeMessage); | 47 | UserServices = new LocalUserServices(this, serversInfo); |
47 | UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll"); | 48 | UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll"); |
48 | UserServer = UserServices; | 49 | UserServer = UserServices; |
49 | GridServer = SandBoxServices; | 50 | GridServer = InstanceServices; |
50 | InterRegion = SandBoxServices; | 51 | InterRegion = InstanceServices; |
51 | httpServer.AddXmlRPCHandler("login_to_simulator", UserServices.XmlRpcLoginMethod); | 52 | LoginServices = new LocalLoginService(UserServices, welcomeMessage, this, serversInfo, accountsAuthenticate); |
53 | httpServer.AddXmlRPCHandler("login_to_simulator", LoginServices.XmlRpcLoginMethod); | ||
52 | } | 54 | } |
53 | 55 | ||
54 | internal void InformRegionOfLogin(ulong regionHandle, Login login) | 56 | internal void InformRegionOfLogin(ulong regionHandle, Login login) |
55 | { | 57 | { |
56 | this.SandBoxServices.AddNewSession(regionHandle, login); | 58 | this.InstanceServices.AddNewSession(regionHandle, login); |
57 | } | 59 | } |
58 | 60 | ||
59 | public void doCreate(string what) | 61 | public void doCreate(string what) |
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index 63f8c21..65732bd 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs | |||
@@ -15,20 +15,14 @@ namespace OpenSim.Region.Communications.Local | |||
15 | private NetworkServersInfo serversInfo; | 15 | private NetworkServersInfo serversInfo; |
16 | private uint defaultHomeX ; | 16 | private uint defaultHomeX ; |
17 | private uint defaultHomeY; | 17 | private uint defaultHomeY; |
18 | private bool authUsers = false; | ||
19 | private string welcomeMessage = "Welcome to OpenSim"; | ||
20 | 18 | ||
21 | public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate, string welcomeMess) | 19 | |
20 | public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversInfo) | ||
22 | { | 21 | { |
23 | m_Parent = parent; | 22 | m_Parent = parent; |
24 | this.serversInfo = serversInfo; | 23 | this.serversInfo = serversInfo; |
25 | defaultHomeX = this.serversInfo.DefaultHomeLocX; | 24 | defaultHomeX = this.serversInfo.DefaultHomeLocX; |
26 | defaultHomeY = this.serversInfo.DefaultHomeLocY; | 25 | defaultHomeY = this.serversInfo.DefaultHomeLocY; |
27 | this.authUsers = authenticate; | ||
28 | if (welcomeMess != "") | ||
29 | { | ||
30 | this.welcomeMessage = welcomeMess; | ||
31 | } | ||
32 | } | 26 | } |
33 | 27 | ||
34 | public UserProfileData GetUserProfile(string firstName, string lastName) | 28 | public UserProfileData GetUserProfile(string firstName, string lastName) |
@@ -46,97 +40,6 @@ namespace OpenSim.Region.Communications.Local | |||
46 | return this.getUserProfile(avatarID); | 40 | return this.getUserProfile(avatarID); |
47 | } | 41 | } |
48 | 42 | ||
49 | /// <summary> | ||
50 | /// | ||
51 | /// </summary> | ||
52 | /// <returns></returns> | ||
53 | public override string GetMessage() | ||
54 | { | ||
55 | return welcomeMessage; | ||
56 | } | ||
57 | |||
58 | public override UserProfileData GetTheUser(string firstname, string lastname) | ||
59 | { | ||
60 | UserProfileData profile = getUserProfile(firstname, lastname); | ||
61 | if (profile != null) | ||
62 | { | ||
63 | |||
64 | return profile; | ||
65 | } | ||
66 | |||
67 | if (!authUsers) | ||
68 | { | ||
69 | //no current user account so make one | ||
70 | Console.WriteLine("No User account found so creating a new one "); | ||
71 | this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); | ||
72 | |||
73 | profile = getUserProfile(firstname, lastname); | ||
74 | |||
75 | return profile; | ||
76 | } | ||
77 | return null; | ||
78 | } | ||
79 | |||
80 | public override bool AuthenticateUser(UserProfileData profile, string password) | ||
81 | { | ||
82 | if (!authUsers) | ||
83 | { | ||
84 | //for now we will accept any password in sandbox mode | ||
85 | Console.WriteLine("authorising user"); | ||
86 | return true; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | Console.WriteLine( "Authenticating " + profile.username + " " + profile.surname); | ||
91 | |||
92 | password = password.Remove(0, 3); //remove $1$ | ||
93 | |||
94 | string s = Util.Md5Hash(password + ":" + profile.passwordSalt); | ||
95 | |||
96 | return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) | ||
101 | { | ||
102 | ulong currentRegion = theUser.currentAgent.currentHandle; | ||
103 | RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion); | ||
104 | |||
105 | if (reg != null) | ||
106 | { | ||
107 | response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + | ||
108 | "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + | ||
109 | "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; | ||
110 | string capsPath = Util.GetRandomCapsPath(); | ||
111 | response.SimAddress = reg.ExternalEndPoint.Address.ToString(); | ||
112 | response.SimPort = (Int32)reg.ExternalEndPoint.Port; | ||
113 | response.RegionX = reg.RegionLocX ; | ||
114 | response.RegionY = reg.RegionLocY ; | ||
115 | |||
116 | //following port needs changing as we don't want a http listener for every region (or do we?) | ||
117 | response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; | ||
118 | theUser.currentAgent.currentRegion = reg.SimUUID; | ||
119 | theUser.currentAgent.currentHandle = reg.RegionHandle; | ||
120 | |||
121 | Login _login = new Login(); | ||
122 | //copy data to login object | ||
123 | _login.First = response.Firstname; | ||
124 | _login.Last = response.Lastname; | ||
125 | _login.Agent = response.AgentID; | ||
126 | _login.Session = response.SessionID; | ||
127 | _login.SecureSession = response.SecureSessionID; | ||
128 | _login.CircuitCode = (uint)response.CircuitCode; | ||
129 | _login.CapsPath = capsPath; | ||
130 | |||
131 | m_Parent.InformRegionOfLogin(currentRegion, _login); | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | Console.WriteLine("not found region " + currentRegion); | ||
136 | } | ||
137 | |||
138 | } | ||
139 | |||
140 | public UserProfileData SetupMasterUser(string firstName, string lastName) | 43 | public UserProfileData SetupMasterUser(string firstName, string lastName) |
141 | { | 44 | { |
142 | return SetupMasterUser(firstName, lastName, ""); | 45 | return SetupMasterUser(firstName, lastName, ""); |