diff options
Diffstat (limited to 'OpenSim/Services/HypergridService/GatekeeperService.cs')
-rw-r--r-- | OpenSim/Services/HypergridService/GatekeeperService.cs | 118 |
1 files changed, 99 insertions, 19 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 72db93f..283ab3e 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | 32 | ||
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
@@ -51,6 +52,7 @@ namespace OpenSim.Services.HypergridService | |||
51 | IPresenceService m_PresenceService; | 52 | IPresenceService m_PresenceService; |
52 | IAuthenticationService m_AuthenticationService; | 53 | IAuthenticationService m_AuthenticationService; |
53 | IUserAccountService m_UserAccountService; | 54 | IUserAccountService m_UserAccountService; |
55 | IHomeUsersSecurityService m_HomeUsersSecurityService; | ||
54 | ISimulationService m_SimulationService; | 56 | ISimulationService m_SimulationService; |
55 | 57 | ||
56 | string m_AuthDll; | 58 | string m_AuthDll; |
@@ -66,14 +68,15 @@ namespace OpenSim.Services.HypergridService | |||
66 | throw new Exception(String.Format("No section GatekeeperService in config file")); | 68 | throw new Exception(String.Format("No section GatekeeperService in config file")); |
67 | 69 | ||
68 | string accountService = serverConfig.GetString("UserAccountService", String.Empty); | 70 | string accountService = serverConfig.GetString("UserAccountService", String.Empty); |
71 | string homeUsersSecurityService = serverConfig.GetString("HomeUsersSecurityService", string.Empty); | ||
69 | string gridService = serverConfig.GetString("GridService", String.Empty); | 72 | string gridService = serverConfig.GetString("GridService", String.Empty); |
70 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); | 73 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); |
71 | string simulationService = serverConfig.GetString("SimulationService", String.Empty); | 74 | string simulationService = serverConfig.GetString("SimulationService", String.Empty); |
72 | 75 | ||
73 | m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); | 76 | m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); |
74 | 77 | ||
75 | if (accountService == string.Empty || gridService == string.Empty || | 78 | // These 3 are mandatory, the others aren't |
76 | presenceService == string.Empty || m_AuthDll == string.Empty) | 79 | if (gridService == string.Empty || presenceService == string.Empty || m_AuthDll == string.Empty) |
77 | throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); | 80 | throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); |
78 | 81 | ||
79 | string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString()); | 82 | string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString()); |
@@ -82,16 +85,20 @@ namespace OpenSim.Services.HypergridService | |||
82 | m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); | 85 | m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); |
83 | 86 | ||
84 | Object[] args = new Object[] { config }; | 87 | Object[] args = new Object[] { config }; |
85 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); | ||
86 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | 88 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); |
87 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); | 89 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); |
90 | |||
91 | if (accountService != string.Empty) | ||
92 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); | ||
93 | if (homeUsersSecurityService != string.Empty) | ||
94 | m_HomeUsersSecurityService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(homeUsersSecurityService, args); | ||
95 | |||
88 | if (simService != null) | 96 | if (simService != null) |
89 | m_SimulationService = simService; | 97 | m_SimulationService = simService; |
90 | else if (simulationService != string.Empty) | 98 | else if (simulationService != string.Empty) |
91 | m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); | 99 | m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); |
92 | 100 | ||
93 | if (m_UserAccountService == null || m_GridService == null || | 101 | if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) |
94 | m_PresenceService == null || m_SimulationService == null) | ||
95 | throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); | 102 | throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); |
96 | 103 | ||
97 | m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); | 104 | m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); |
@@ -164,6 +171,7 @@ namespace OpenSim.Services.HypergridService | |||
164 | return region; | 171 | return region; |
165 | } | 172 | } |
166 | 173 | ||
174 | #region Login Agent | ||
167 | public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) | 175 | public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) |
168 | { | 176 | { |
169 | reason = string.Empty; | 177 | reason = string.Empty; |
@@ -174,6 +182,9 @@ namespace OpenSim.Services.HypergridService | |||
174 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to login foreign agent {0} {1} @ {2} ({3}) at destination {4}", | 182 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to login foreign agent {0} {1} @ {2} ({3}) at destination {4}", |
175 | aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName); | 183 | aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName); |
176 | 184 | ||
185 | // | ||
186 | // Authenticate the user | ||
187 | // | ||
177 | if (!Authenticate(aCircuit)) | 188 | if (!Authenticate(aCircuit)) |
178 | { | 189 | { |
179 | reason = "Unable to verify identity"; | 190 | reason = "Unable to verify identity"; |
@@ -181,22 +192,40 @@ namespace OpenSim.Services.HypergridService | |||
181 | return false; | 192 | return false; |
182 | } | 193 | } |
183 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL); | 194 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL); |
184 | 195 | ||
185 | // Check to see if we have a local user with that UUID | 196 | // |
186 | UserAccount account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); | 197 | // Check for impersonations |
187 | if (account != null) | 198 | // |
199 | UserAccount account = null; | ||
200 | if (m_UserAccountService != null) | ||
188 | { | 201 | { |
189 | // No, sorry; go away | 202 | // Check to see if we have a local user with that UUID |
190 | reason = "User identifier not allowed on this grid"; | 203 | account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); |
191 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has UUID of local user {3}. Refusing service.", | 204 | if (account != null) |
192 | aCircuit.firstname, aCircuit.lastname, aCircuit.AgentID); | 205 | { |
193 | return false; | 206 | // Make sure this is the user coming home, and not a fake |
207 | if (m_HomeUsersSecurityService != null) | ||
208 | { | ||
209 | Object ep = m_HomeUsersSecurityService.GetEndPoint(aCircuit.SessionID); | ||
210 | if (ep == null) | ||
211 | { | ||
212 | // This is a fake, this session never left this grid | ||
213 | reason = "Unauthorized"; | ||
214 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has same ID as local user. Refusing service.", | ||
215 | aCircuit.firstname, aCircuit.lastname); | ||
216 | return false; | ||
217 | |||
218 | } | ||
219 | } | ||
220 | } | ||
194 | } | 221 | } |
195 | m_log.DebugFormat("[GATEKEEPER SERVICE]: User ID ok"); | 222 | m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok"); |
196 | 223 | ||
197 | // May want to authorize | 224 | // May want to authorize |
198 | 225 | ||
226 | // | ||
199 | // Login the presence | 227 | // Login the presence |
228 | // | ||
200 | if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) | 229 | if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) |
201 | { | 230 | { |
202 | reason = "Unable to login presence"; | 231 | reason = "Unable to login presence"; |
@@ -206,22 +235,38 @@ namespace OpenSim.Services.HypergridService | |||
206 | } | 235 | } |
207 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); | 236 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); |
208 | 237 | ||
238 | // | ||
209 | // Get the region | 239 | // Get the region |
240 | // | ||
210 | destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID); | 241 | destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID); |
211 | if (destination == null) | 242 | if (destination == null) |
212 | { | 243 | { |
213 | reason = "Destination region not found"; | 244 | reason = "Destination region not found"; |
214 | return false; | 245 | return false; |
215 | } | 246 | } |
216 | m_log.DebugFormat("[GATEKEEPER SERVICE]: destination ok : {0}", destination.RegionName); | 247 | m_log.DebugFormat("[GATEKEEPER SERVICE]: destination ok: {0}", destination.RegionName); |
217 | 248 | ||
249 | // | ||
250 | // Adjust the visible name | ||
251 | // | ||
252 | if (account != null) | ||
253 | { | ||
254 | aCircuit.firstname = account.FirstName; | ||
255 | aCircuit.lastname = account.LastName; | ||
256 | } | ||
257 | if (account == null && !aCircuit.lastname.StartsWith("@")) | ||
258 | { | ||
259 | aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname; | ||
260 | aCircuit.lastname = "@" + aCircuit.ServiceURLs["HomeURI"].ToString(); | ||
261 | } | ||
262 | |||
263 | // | ||
218 | // Finally launch the agent at the destination | 264 | // Finally launch the agent at the destination |
219 | aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname; | 265 | // |
220 | aCircuit.lastname = "@" + aCircuit.ServiceURLs["HomeURI"].ToString(); | ||
221 | return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); | 266 | return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); |
222 | } | 267 | } |
223 | 268 | ||
224 | protected bool Authenticate(AgentCircuitData aCircuit) | 269 | protected bool Authenticate(AgentCircuitData aCircuit) |
225 | { | 270 | { |
226 | string authURL = string.Empty; | 271 | string authURL = string.Empty; |
227 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | 272 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) |
@@ -250,5 +295,40 @@ namespace OpenSim.Services.HypergridService | |||
250 | 295 | ||
251 | return false; | 296 | return false; |
252 | } | 297 | } |
298 | |||
299 | #endregion | ||
300 | |||
301 | public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) | ||
302 | { | ||
303 | position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; | ||
304 | |||
305 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get home region of user {0}", userID); | ||
306 | |||
307 | GridRegion home = null; | ||
308 | PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() }); | ||
309 | if (presences != null && presences.Length > 0) | ||
310 | { | ||
311 | UUID homeID = presences[0].HomeRegionID; | ||
312 | if (homeID != UUID.Zero) | ||
313 | { | ||
314 | home = m_GridService.GetRegionByUUID(m_ScopeID, homeID); | ||
315 | position = presences[0].HomePosition; | ||
316 | lookAt = presences[0].HomeLookAt; | ||
317 | } | ||
318 | if (home == null) | ||
319 | { | ||
320 | List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); | ||
321 | if (defs != null && defs.Count > 0) | ||
322 | home = defs[0]; | ||
323 | } | ||
324 | } | ||
325 | |||
326 | return home; | ||
327 | } | ||
328 | |||
329 | #region Misc | ||
330 | |||
331 | |||
332 | #endregion | ||
253 | } | 333 | } |
254 | } | 334 | } |