diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/LLLoginService/LLLoginService.cs | 162 |
1 files changed, 160 insertions, 2 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 2c31ed5..4501da2 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -1,6 +1,7 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Reflection; | 3 | using System.Reflection; |
4 | using System.Text.RegularExpressions; | ||
4 | 5 | ||
5 | using log4net; | 6 | using log4net; |
6 | using Nini.Config; | 7 | using Nini.Config; |
@@ -9,17 +10,24 @@ using OpenMetaverse; | |||
9 | using OpenSim.Framework; | 10 | using OpenSim.Framework; |
10 | using OpenSim.Server.Base; | 11 | using OpenSim.Server.Base; |
11 | using OpenSim.Services.Interfaces; | 12 | using OpenSim.Services.Interfaces; |
13 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
12 | 14 | ||
13 | namespace OpenSim.Services.LLLoginService | 15 | namespace OpenSim.Services.LLLoginService |
14 | { | 16 | { |
15 | public class LLLoginService : ILoginService | 17 | public class LLLoginService : ILoginService |
16 | { | 18 | { |
19 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
20 | |||
17 | private IUserAccountService m_UserAccountService; | 21 | private IUserAccountService m_UserAccountService; |
18 | private IAuthenticationService m_AuthenticationService; | 22 | private IAuthenticationService m_AuthenticationService; |
19 | private IInventoryService m_InventoryService; | 23 | private IInventoryService m_InventoryService; |
20 | private IGridService m_GridService; | 24 | private IGridService m_GridService; |
21 | private IPresenceService m_PresenceService; | 25 | private IPresenceService m_PresenceService; |
22 | 26 | ||
27 | private string m_DefaultRegionName; | ||
28 | private string m_LocalSimulationDll; | ||
29 | private string m_RemoteSimulationDll; | ||
30 | |||
23 | public LLLoginService(IConfigSource config) | 31 | public LLLoginService(IConfigSource config) |
24 | { | 32 | { |
25 | IConfig serverConfig = config.Configs["LoginService"]; | 33 | IConfig serverConfig = config.Configs["LoginService"]; |
@@ -32,6 +40,10 @@ namespace OpenSim.Services.LLLoginService | |||
32 | string gridService = serverConfig.GetString("GridService", String.Empty); | 40 | string gridService = serverConfig.GetString("GridService", String.Empty); |
33 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); | 41 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); |
34 | 42 | ||
43 | m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty); | ||
44 | m_LocalSimulationDll = serverConfig.GetString("LocalSimulationService", String.Empty); | ||
45 | m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty); | ||
46 | |||
35 | // These 3 are required; the other 2 aren't | 47 | // These 3 are required; the other 2 aren't |
36 | if (accountService == string.Empty || authService == string.Empty || | 48 | if (accountService == string.Empty || authService == string.Empty || |
37 | invService == string.Empty) | 49 | invService == string.Empty) |
@@ -57,8 +69,8 @@ namespace OpenSim.Services.LLLoginService | |||
57 | 69 | ||
58 | // Authenticate this user | 70 | // Authenticate this user |
59 | string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); | 71 | string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); |
60 | UUID session = UUID.Zero; | 72 | UUID secureSession = UUID.Zero; |
61 | if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out session))) | 73 | if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) |
62 | return LLFailedLoginResponse.UserProblem; | 74 | return LLFailedLoginResponse.UserProblem; |
63 | 75 | ||
64 | // Get the user's inventory | 76 | // Get the user's inventory |
@@ -66,9 +78,155 @@ namespace OpenSim.Services.LLLoginService | |||
66 | if ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)) | 78 | if ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)) |
67 | return LLFailedLoginResponse.InventoryProblem; | 79 | return LLFailedLoginResponse.InventoryProblem; |
68 | 80 | ||
81 | // Login the presence | ||
82 | UUID session = UUID.Random(); | ||
83 | if (m_PresenceService != null) | ||
84 | { | ||
85 | bool success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); | ||
86 | if (!success) | ||
87 | return LLFailedLoginResponse.GridProblem; | ||
88 | } | ||
89 | |||
69 | // lots of things missing... need to do the simulation service | 90 | // lots of things missing... need to do the simulation service |
91 | string where = string.Empty; | ||
92 | Vector3 position = Vector3.Zero; | ||
93 | Vector3 lookAt = Vector3.Zero; | ||
94 | GridRegion destination = FindDestination(account, session, startLocation, out where, out position, out lookAt); | ||
95 | if (destination == null) | ||
96 | return LLFailedLoginResponse.GridProblem; | ||
97 | |||
98 | ISimulationService sim = null; | ||
99 | Object[] args = new Object[] { destination }; | ||
100 | // HG standalones have both a localSimulatonDll and a remoteSimulationDll | ||
101 | // non-HG standalones have just a localSimulationDll | ||
102 | // independent login servers have just a remoteSimulationDll | ||
103 | if (!startLocation.Contains("@") && (m_LocalSimulationDll != string.Empty)) | ||
104 | sim = ServerUtils.LoadPlugin<ISimulationService>(m_LocalSimulationDll, args); | ||
105 | else | ||
106 | sim = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args); | ||
107 | |||
70 | 108 | ||
71 | return null; | 109 | return null; |
72 | } | 110 | } |
111 | |||
112 | private GridRegion FindDestination(UserAccount account, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) | ||
113 | { | ||
114 | where = "home"; | ||
115 | position = new Vector3(128, 128, 0); | ||
116 | lookAt = new Vector3(0, 1, 0); | ||
117 | if (startLocation.Equals("home")) | ||
118 | { | ||
119 | // logging into home region | ||
120 | if (m_PresenceService == null || m_GridService == null) | ||
121 | return null; | ||
122 | |||
123 | GridRegion region = null; | ||
124 | PresenceInfo pinfo = m_PresenceService.GetAgent(sessionID); | ||
125 | // this should succeed; if it doesn't there's something wrong with this grid | ||
126 | if (pinfo == null) | ||
127 | return null; | ||
128 | |||
129 | if (pinfo.HomeRegionID.Equals(UUID.Zero)) | ||
130 | region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | ||
131 | else | ||
132 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID); | ||
133 | |||
134 | return region; | ||
135 | } | ||
136 | else if (startLocation.Equals("last")) | ||
137 | { | ||
138 | // logging into last visited region | ||
139 | where = "last"; | ||
140 | if (m_PresenceService == null || m_GridService == null) | ||
141 | return null; | ||
142 | |||
143 | GridRegion region = null; | ||
144 | PresenceInfo pinfo = m_PresenceService.GetAgent(sessionID); | ||
145 | // this should succeed; if it doesn't there's something wrong with this grid | ||
146 | if (pinfo == null) | ||
147 | return null; | ||
148 | |||
149 | if (pinfo.RegionID.Equals(UUID.Zero)) | ||
150 | region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | ||
151 | else | ||
152 | { | ||
153 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID); | ||
154 | position = pinfo.Position; | ||
155 | lookAt = pinfo.LookAt; | ||
156 | } | ||
157 | return region; | ||
158 | |||
159 | } | ||
160 | else | ||
161 | { | ||
162 | // free uri form | ||
163 | // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 | ||
164 | where = "url"; | ||
165 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
166 | Match uriMatch = reURI.Match(startLocation); | ||
167 | if (uriMatch == null) | ||
168 | { | ||
169 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation); | ||
170 | return null; | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), | ||
175 | float.Parse(uriMatch.Groups["y"].Value), | ||
176 | float.Parse(uriMatch.Groups["z"].Value)); | ||
177 | |||
178 | string regionName = uriMatch.Groups["region"].ToString(); | ||
179 | if (regionName != null) | ||
180 | { | ||
181 | if (!regionName.Contains("@")) | ||
182 | { | ||
183 | List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1); | ||
184 | if ((regions == null) || (regions != null && regions.Count == 0)) | ||
185 | { | ||
186 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName); | ||
187 | return null; | ||
188 | } | ||
189 | return regions[0]; | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | string[] parts = regionName.Split(new char[] { '@' }); | ||
194 | if (parts.Length < 2) | ||
195 | { | ||
196 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName); | ||
197 | return null; | ||
198 | } | ||
199 | // Valid specification of a remote grid | ||
200 | regionName = parts[0]; | ||
201 | string domainLocator = parts[1]; | ||
202 | parts = domainLocator.Split(new char[] {':'}); | ||
203 | string domainName = parts[0]; | ||
204 | uint port = 0; | ||
205 | if (parts.Length > 1) | ||
206 | UInt32.TryParse(parts[1], out port); | ||
207 | GridRegion region = new GridRegion(); | ||
208 | region.ExternalHostName = domainName; | ||
209 | region.HttpPort = port; | ||
210 | region.RegionName = regionName; | ||
211 | return region; | ||
212 | } | ||
213 | |||
214 | } | ||
215 | else | ||
216 | { | ||
217 | if (m_PresenceService == null || m_GridService == null) | ||
218 | return null; | ||
219 | |||
220 | return m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | ||
221 | |||
222 | } | ||
223 | } | ||
224 | //response.LookAt = "[r0,r1,r0]"; | ||
225 | //// can be: last, home, safe, url | ||
226 | //response.StartLocation = "url"; | ||
227 | |||
228 | } | ||
229 | |||
230 | } | ||
73 | } | 231 | } |
74 | } | 232 | } |