aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/LLLoginService/LLLoginService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/LLLoginService/LLLoginService.cs')
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs166
1 files changed, 124 insertions, 42 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 59fb559..0b38738 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -50,12 +50,15 @@ namespace OpenSim.Services.LLLoginService
50 public class LLLoginService : ILoginService 50 public class LLLoginService : ILoginService
51 { 51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private static readonly string LogHeader = "[LLOGIN SERVICE]";
54
53 private static bool Initialized = false; 55 private static bool Initialized = false;
54 56
55 protected IUserAccountService m_UserAccountService; 57 protected IUserAccountService m_UserAccountService;
56 protected IGridUserService m_GridUserService; 58 protected IGridUserService m_GridUserService;
57 protected IAuthenticationService m_AuthenticationService; 59 protected IAuthenticationService m_AuthenticationService;
58 protected IInventoryService m_InventoryService; 60 protected IInventoryService m_InventoryService;
61 protected IInventoryService m_HGInventoryService;
59 protected IGridService m_GridService; 62 protected IGridService m_GridService;
60 protected IPresenceService m_PresenceService; 63 protected IPresenceService m_PresenceService;
61 protected ISimulationService m_LocalSimulationService; 64 protected ISimulationService m_LocalSimulationService;
@@ -74,14 +77,15 @@ namespace OpenSim.Services.LLLoginService
74 protected string m_GatekeeperURL; 77 protected string m_GatekeeperURL;
75 protected bool m_AllowRemoteSetLoginLevel; 78 protected bool m_AllowRemoteSetLoginLevel;
76 protected string m_MapTileURL; 79 protected string m_MapTileURL;
77 protected string m_ProfileURL;
78 protected string m_OpenIDURL;
79 protected string m_SearchURL; 80 protected string m_SearchURL;
80 protected string m_Currency; 81 protected string m_Currency;
81 82 protected string m_ClassifiedFee;
83 protected int m_MaxAgentGroups;
84 protected string m_DestinationGuide;
85 protected string m_AvatarPicker;
82 protected string m_AllowedClients; 86 protected string m_AllowedClients;
83 protected string m_DeniedClients; 87 protected string m_DeniedClients;
84 88 protected string m_MessageUrl;
85 protected string m_DSTZone; 89 protected string m_DSTZone;
86 90
87 IConfig m_LoginServerConfig; 91 IConfig m_LoginServerConfig;
@@ -110,18 +114,29 @@ namespace OpenSim.Services.LLLoginService
110 m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true); 114 m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true);
111 m_AllowRemoteSetLoginLevel = m_LoginServerConfig.GetBoolean("AllowRemoteSetLoginLevel", false); 115 m_AllowRemoteSetLoginLevel = m_LoginServerConfig.GetBoolean("AllowRemoteSetLoginLevel", false);
112 m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0); 116 m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0);
113 m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty); 117 m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
118 new string[] { "Startup", "Hypergrid", "LoginService" }, String.Empty);
114 m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); 119 m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty);
115 m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty);
116 m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty);
117 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty); 120 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty);
118 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty); 121 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty);
122 m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty);
123 m_DestinationGuide = m_LoginServerConfig.GetString ("DestinationGuide", string.Empty);
124 m_AvatarPicker = m_LoginServerConfig.GetString ("AvatarPicker", string.Empty);
119 125
120 m_AllowedClients = m_LoginServerConfig.GetString("AllowedClients", string.Empty); 126 string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "LoginService" };
121 m_DeniedClients = m_LoginServerConfig.GetString("DeniedClients", string.Empty); 127 m_AllowedClients = Util.GetConfigVarFromSections<string>(
128 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
129 m_DeniedClients = Util.GetConfigVarFromSections<string>(
130 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
122 131
132 m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty);
123 m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time"); 133 m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time");
124 134
135 IConfig groupConfig = config.Configs["Groups"];
136 if (groupConfig != null)
137 m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42);
138
139
125 // Clean up some of these vars 140 // Clean up some of these vars
126 if (m_MapTileURL != String.Empty) 141 if (m_MapTileURL != String.Empty)
127 { 142 {
@@ -156,6 +171,15 @@ namespace OpenSim.Services.LLLoginService
156 if (agentService != string.Empty) 171 if (agentService != string.Empty)
157 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(agentService, args); 172 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(agentService, args);
158 173
174 // Get the Hypergrid inventory service (exists only if Hypergrid is enabled)
175 string hgInvServicePlugin = m_LoginServerConfig.GetString("HGInventoryServicePlugin", String.Empty);
176 if (hgInvServicePlugin != string.Empty)
177 {
178 string hgInvServiceArg = m_LoginServerConfig.GetString("HGInventoryServiceConstructorArg", String.Empty);
179 Object[] args2 = new Object[] { config, hgInvServiceArg };
180 m_HGInventoryService = ServerUtils.LoadPlugin<IInventoryService>(hgInvServicePlugin, args2);
181 }
182
159 // 183 //
160 // deal with the services given as argument 184 // deal with the services given as argument
161 // 185 //
@@ -241,6 +265,7 @@ namespace OpenSim.Services.LLLoginService
241 { 265 {
242 bool success = false; 266 bool success = false;
243 UUID session = UUID.Random(); 267 UUID session = UUID.Random();
268 string processedMessage;
244 269
245 m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}", 270 m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}",
246 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0); 271 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0);
@@ -341,6 +366,13 @@ namespace OpenSim.Services.LLLoginService
341 return LLFailedLoginResponse.InventoryProblem; 366 return LLFailedLoginResponse.InventoryProblem;
342 } 367 }
343 368
369 if (m_HGInventoryService != null)
370 {
371 // Give the Suitcase service a chance to create the suitcase folder.
372 // (If we're not using the Suitcase inventory service then this won't do anything.)
373 m_HGInventoryService.GetRootFolder(account.PrincipalID);
374 }
375
344 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); 376 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
345 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))) 377 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
346 { 378 {
@@ -375,13 +407,33 @@ namespace OpenSim.Services.LLLoginService
375 // 407 //
376 GridRegion home = null; 408 GridRegion home = null;
377 GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString()); 409 GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString());
378 if (guinfo != null && (guinfo.HomeRegionID != UUID.Zero) && m_GridService != null) 410
411 // We are only going to complain about no home if the user actually tries to login there, to avoid
412 // spamming the console.
413 if (guinfo != null)
379 { 414 {
380 home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID); 415 if (guinfo.HomeRegionID == UUID.Zero && startLocation == "home")
416 {
417 m_log.WarnFormat(
418 "[LLOGIN SERVICE]: User {0} tried to login to a 'home' start location but they have none set",
419 account.Name);
420 }
421 else if (m_GridService != null)
422 {
423 home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID);
424
425 if (home == null && startLocation == "home")
426 {
427 m_log.WarnFormat(
428 "[LLOGIN SERVICE]: User {0} tried to login to a 'home' start location with ID {1} but this was not found.",
429 account.Name, guinfo.HomeRegionID);
430 }
431 }
381 } 432 }
382 if (guinfo == null) 433 else
383 { 434 {
384 // something went wrong, make something up, so that we don't have to test this anywhere else 435 // something went wrong, make something up, so that we don't have to test this anywhere else
436 m_log.DebugFormat("{0} Failed to fetch GridUserInfo. Creating empty GridUserInfo as home", LogHeader);
385 guinfo = new GridUserInfo(); 437 guinfo = new GridUserInfo();
386 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30); 438 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30);
387 } 439 }
@@ -448,16 +500,28 @@ namespace OpenSim.Services.LLLoginService
448 // 500 //
449 // Finally, fill out the response and return it 501 // Finally, fill out the response and return it
450 // 502 //
503 if (m_MessageUrl != String.Empty)
504 {
505 WebClient client = new WebClient();
506 processedMessage = client.DownloadString(m_MessageUrl);
507 }
508 else
509 {
510 processedMessage = m_WelcomeMessage;
511 }
512 processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName);
513
451 LLLoginResponse response 514 LLLoginResponse response
452 = new LLLoginResponse( 515 = new LLLoginResponse(
453 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, 516 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
454 where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, 517 where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP,
455 m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone); 518 m_MapTileURL, m_SearchURL, m_Currency, m_DSTZone,
519 m_DestinationGuide, m_AvatarPicker, m_ClassifiedFee, m_MaxAgentGroups);
456 520
457 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName); 521 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName);
458 522
459 return response; 523 return response;
460 } 524 }
461 catch (Exception e) 525 catch (Exception e)
462 { 526 {
463 m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2} {3}", firstName, lastName, e.ToString(), e.StackTrace); 527 m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2} {3}", firstName, lastName, e.ToString(), e.StackTrace);
@@ -498,10 +562,6 @@ namespace OpenSim.Services.LLLoginService
498 562
499 if (home == null) 563 if (home == null)
500 { 564 {
501 m_log.WarnFormat(
502 "[LLOGIN SERVICE]: User {0} {1} tried to login to a 'home' start location but they have none set",
503 account.FirstName, account.LastName);
504
505 tryDefaults = true; 565 tryDefaults = true;
506 } 566 }
507 else 567 else
@@ -576,7 +636,7 @@ namespace OpenSim.Services.LLLoginService
576 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 636 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34
577 where = "url"; 637 where = "url";
578 GridRegion region = null; 638 GridRegion region = null;
579 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); 639 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+[.]?\d*)&(?<y>\d+[.]?\d*)&(?<z>\d+[.]?\d*)$");
580 Match uriMatch = reURI.Match(startLocation); 640 Match uriMatch = reURI.Match(startLocation);
581 if (uriMatch == null) 641 if (uriMatch == null)
582 { 642 {
@@ -645,8 +705,7 @@ namespace OpenSim.Services.LLLoginService
645 if (parts.Length > 1) 705 if (parts.Length > 1)
646 UInt32.TryParse(parts[1], out port); 706 UInt32.TryParse(parts[1], out port);
647 707
648// GridRegion region = FindForeignRegion(domainName, port, regionName, out gatekeeper); 708 region = FindForeignRegion(domainName, port, regionName, account, out gatekeeper);
649 region = FindForeignRegion(domainName, port, regionName, out gatekeeper);
650 return region; 709 return region;
651 } 710 }
652 } 711 }
@@ -673,7 +732,7 @@ namespace OpenSim.Services.LLLoginService
673 private GridRegion FindAlternativeRegion(UUID scopeID) 732 private GridRegion FindAlternativeRegion(UUID scopeID)
674 { 733 {
675 List<GridRegion> hyperlinks = null; 734 List<GridRegion> hyperlinks = null;
676 List<GridRegion> regions = m_GridService.GetFallbackRegions(scopeID, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); 735 List<GridRegion> regions = m_GridService.GetFallbackRegions(scopeID, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
677 if (regions != null && regions.Count > 0) 736 if (regions != null && regions.Count > 0)
678 { 737 {
679 hyperlinks = m_GridService.GetHyperlinks(scopeID); 738 hyperlinks = m_GridService.GetHyperlinks(scopeID);
@@ -695,7 +754,7 @@ namespace OpenSim.Services.LLLoginService
695 return null; 754 return null;
696 } 755 }
697 756
698 private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper) 757 private GridRegion FindForeignRegion(string domainName, uint port, string regionName, UserAccount account, out GridRegion gatekeeper)
699 { 758 {
700 m_log.Debug("[LLLOGIN SERVICE]: attempting to findforeignregion " + domainName + ":" + port.ToString() + ":" + regionName); 759 m_log.Debug("[LLLOGIN SERVICE]: attempting to findforeignregion " + domainName + ":" + port.ToString() + ":" + regionName);
701 gatekeeper = new GridRegion(); 760 gatekeeper = new GridRegion();
@@ -707,9 +766,14 @@ namespace OpenSim.Services.LLLoginService
707 UUID regionID; 766 UUID regionID;
708 ulong handle; 767 ulong handle;
709 string imageURL = string.Empty, reason = string.Empty; 768 string imageURL = string.Empty, reason = string.Empty;
769 string message;
710 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason)) 770 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason))
711 { 771 {
712 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID); 772 string homeURI = null;
773 if (account.ServiceURLs != null && account.ServiceURLs.ContainsKey("HomeURI"))
774 homeURI = (string)account.ServiceURLs["HomeURI"];
775
776 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID, account.PrincipalID, homeURI, out message);
713 return destination; 777 return destination;
714 } 778 }
715 779
@@ -858,13 +922,6 @@ namespace OpenSim.Services.LLLoginService
858 SetServiceURLs(aCircuit, account); 922 SetServiceURLs(aCircuit, account);
859 923
860 return aCircuit; 924 return aCircuit;
861
862 //m_UserAgentService.LoginAgentToGrid(aCircuit, GatekeeperServiceConnector, region, out reason);
863 //if (simConnector.CreateAgent(region, aCircuit, 0, out reason))
864 // return aCircuit;
865
866 //return null;
867
868 } 925 }
869 926
870 private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account) 927 private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account)
@@ -899,7 +956,7 @@ namespace OpenSim.Services.LLLoginService
899 if (!keyValue.EndsWith("/")) 956 if (!keyValue.EndsWith("/"))
900 keyValue = keyValue + "/"; 957 keyValue = keyValue + "/";
901 958
902 if (!account.ServiceURLs.ContainsKey(keyName) || (account.ServiceURLs.ContainsKey(keyName) && account.ServiceURLs[keyName] != keyValue)) 959 if (!account.ServiceURLs.ContainsKey(keyName) || (account.ServiceURLs.ContainsKey(keyName) && (string)account.ServiceURLs[keyName] != keyValue))
903 { 960 {
904 account.ServiceURLs[keyName] = keyValue; 961 account.ServiceURLs[keyName] = keyValue;
905 newUrls = true; 962 newUrls = true;
@@ -909,6 +966,13 @@ namespace OpenSim.Services.LLLoginService
909 m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]); 966 m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
910 } 967 }
911 968
969 if (!account.ServiceURLs.ContainsKey("GatekeeperURI") && !string.IsNullOrEmpty(m_GatekeeperURL))
970 {
971 m_log.DebugFormat("[LLLOGIN SERVICE]: adding gatekeeper uri {0}", m_GatekeeperURL);
972 account.ServiceURLs["GatekeeperURI"] = m_GatekeeperURL;
973 newUrls = true;
974 }
975
912 // The grid operator decided to override the defaults in the 976 // The grid operator decided to override the defaults in the
913 // [LoginService] configuration. Let's store the correct ones. 977 // [LoginService] configuration. Let's store the correct ones.
914 if (newUrls) 978 if (newUrls)
@@ -919,13 +983,20 @@ namespace OpenSim.Services.LLLoginService
919 983
920 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, TeleportFlags flags, out string reason) 984 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, TeleportFlags flags, out string reason)
921 { 985 {
922 return simConnector.CreateAgent(region, aCircuit, (uint)flags, out reason); 986 EntityTransferContext ctx = new EntityTransferContext();
987
988 if (!simConnector.QueryAccess(
989 region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
990 return false;
991
992 return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, out reason);
923 } 993 }
924 994
925 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) 995 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason)
926 { 996 {
927 m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName); 997 m_log.Debug("[LLOGIN SERVICE]: Launching agent at " + destination.RegionName);
928 if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, clientIP, out reason)) 998
999 if (m_UserAgentService.LoginAgentToGrid(null, aCircuit, gatekeeper, destination, true, out reason))
929 return true; 1000 return true;
930 return false; 1001 return false;
931 } 1002 }
@@ -961,14 +1032,25 @@ namespace OpenSim.Services.LLLoginService
961 // or fixing critical issues 1032 // or fixing critical issues
962 // 1033 //
963 if (cmd.Length > 2) 1034 if (cmd.Length > 2)
964 Int32.TryParse(cmd[2], out m_MinLoginLevel); 1035 {
1036 if (Int32.TryParse(cmd[2], out m_MinLoginLevel))
1037 MainConsole.Instance.OutputFormat("Set minimum login level to {0}", m_MinLoginLevel);
1038 else
1039 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid login level", cmd[2]);
1040 }
965 break; 1041 break;
966 case "reset": 1042
1043 case "reset":
967 m_MinLoginLevel = 0; 1044 m_MinLoginLevel = 0;
1045 MainConsole.Instance.OutputFormat("Reset min login level to {0}", m_MinLoginLevel);
968 break; 1046 break;
1047
969 case "text": 1048 case "text":
970 if (cmd.Length > 2) 1049 if (cmd.Length > 2)
1050 {
971 m_WelcomeMessage = cmd[2]; 1051 m_WelcomeMessage = cmd[2];
1052 MainConsole.Instance.OutputFormat("Login welcome message set to '{0}'", m_WelcomeMessage);
1053 }
972 break; 1054 break;
973 } 1055 }
974 } 1056 }