aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie2010-01-19 04:18:01 +0000
committerMelanie2010-01-19 04:18:01 +0000
commita3f48a7ca66347b11990e5444a636d40bec5dbf1 (patch)
treea5708996ccf28ce8696b8257a0b33352f56e2afe /OpenSim/Services
parentAdd a Hyperlink flag to the regions table (diff)
parent* Towards enabling hyperlinks at grid-level. (diff)
downloadopensim-SC_OLD-a3f48a7ca66347b11990e5444a636d40bec5dbf1.zip
opensim-SC_OLD-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.gz
opensim-SC_OLD-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.bz2
opensim-SC_OLD-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.xz
Merge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensim into presence-refactor
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs119
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs132
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs110
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs118
-rw-r--r--OpenSim/Services/HypergridService/HomeUsersSecurityService.cs67
-rw-r--r--OpenSim/Services/HypergridService/HypergridService.cs8
-rw-r--r--OpenSim/Services/Interfaces/IGatekeeperService.cs14
-rw-r--r--OpenSim/Services/Interfaces/IHypergridService.cs1
8 files changed, 543 insertions, 26 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
new file mode 100644
index 0000000..a8d9292
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -0,0 +1,119 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5
6using OpenSim.Services.Interfaces;
7using GridRegion = OpenSim.Services.Interfaces.GridRegion;
8
9using OpenMetaverse;
10using Nwc.XmlRpc;
11
12using OpenSim.Services.Connectors.Simulation;
13
14namespace OpenSim.Services.Connectors.Hypergrid
15{
16 public class GatekeeperServiceConnector : SimulationServiceConnector
17 {
18 protected override string AgentPath()
19 {
20 return "/foreignagent/";
21 }
22
23 protected override string ObjectPath()
24 {
25 return "/foreignobject/";
26 }
27
28 public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt)
29 {
30 position = Vector3.UnitY; lookAt = Vector3.UnitY;
31
32 Hashtable hash = new Hashtable();
33 hash["userID"] = userID.ToString();
34
35 IList paramList = new ArrayList();
36 paramList.Add(hash);
37
38 XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList);
39 string uri = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort + "/";
40 XmlRpcResponse response = null;
41 try
42 {
43 response = request.Send(uri, 10000);
44 }
45 catch (Exception e)
46 {
47 return null;
48 }
49
50 if (response.IsFault)
51 {
52 return null;
53 }
54
55 hash = (Hashtable)response.Value;
56 //foreach (Object o in hash)
57 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
58 try
59 {
60 bool success = false;
61 Boolean.TryParse((string)hash["result"], out success);
62 if (success)
63 {
64 GridRegion region = new GridRegion();
65
66 UUID.TryParse((string)hash["uuid"], out region.RegionID);
67 //m_log.Debug(">> HERE, uuid: " + region.RegionID);
68 int n = 0;
69 if (hash["x"] != null)
70 {
71 Int32.TryParse((string)hash["x"], out n);
72 region.RegionLocX = n;
73 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
74 }
75 if (hash["y"] != null)
76 {
77 Int32.TryParse((string)hash["y"], out n);
78 region.RegionLocY = n;
79 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
80 }
81 if (hash["region_name"] != null)
82 {
83 region.RegionName = (string)hash["region_name"];
84 //m_log.Debug(">> HERE, name: " + region.RegionName);
85 }
86 if (hash["hostname"] != null)
87 region.ExternalHostName = (string)hash["hostname"];
88 if (hash["http_port"] != null)
89 {
90 uint p = 0;
91 UInt32.TryParse((string)hash["http_port"], out p);
92 region.HttpPort = p;
93 }
94 if (hash["internal_port"] != null)
95 {
96 int p = 0;
97 Int32.TryParse((string)hash["internal_port"], out p);
98 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
99 }
100 if (hash["position"] != null)
101 Vector3.TryParse((string)hash["position"], out position);
102 if (hash["lookAt"] != null)
103 Vector3.TryParse((string)hash["lookAt"], out lookAt);
104
105 // Successful return
106 return region;
107 }
108
109 }
110 catch (Exception e)
111 {
112 return null;
113 }
114
115 return null;
116
117 }
118 }
119}
diff --git a/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs
new file mode 100644
index 0000000..150690b
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs
@@ -0,0 +1,132 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5using System.Reflection;
6
7using OpenSim.Services.Interfaces;
8
9using OpenMetaverse;
10using log4net;
11using Nwc.XmlRpc;
12using Nini.Config;
13
14namespace OpenSim.Services.Connectors.Hypergrid
15{
16 public class HomeUsersSecurityServiceConnector : IHomeUsersSecurityService
17 {
18 private static readonly ILog m_log =
19 LogManager.GetLogger(
20 MethodBase.GetCurrentMethod().DeclaringType);
21
22 string m_ServerURL;
23 public HomeUsersSecurityServiceConnector(string url)
24 {
25 m_ServerURL = url;
26 }
27
28 public HomeUsersSecurityServiceConnector(IConfigSource config)
29 {
30 }
31
32 public void SetEndPoint(UUID sessionID, IPEndPoint ep)
33 {
34 Hashtable hash = new Hashtable();
35 hash["sessionID"] = sessionID.ToString();
36 hash["ep_addr"] = ep.Address.ToString();
37 hash["ep_port"] = ep.Port.ToString();
38
39 Call("ep_set", hash);
40 }
41
42 public void RemoveEndPoint(UUID sessionID)
43 {
44 Hashtable hash = new Hashtable();
45 hash["sessionID"] = sessionID.ToString();
46
47 Call("ep_remove", hash);
48 }
49
50 public IPEndPoint GetEndPoint(UUID sessionID)
51 {
52 Hashtable hash = new Hashtable();
53 hash["sessionID"] = sessionID.ToString();
54
55 IList paramList = new ArrayList();
56 paramList.Add(hash);
57
58 XmlRpcRequest request = new XmlRpcRequest("ep_get", paramList);
59 //m_log.Debug("[HGrid]: Linking to " + uri);
60 XmlRpcResponse response = null;
61 try
62 {
63 response = request.Send(m_ServerURL, 10000);
64 }
65 catch (Exception e)
66 {
67 m_log.Debug("[HGrid]: Exception " + e.Message);
68 return null;
69 }
70
71 if (response.IsFault)
72 {
73 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
74 return null;
75 }
76
77 hash = (Hashtable)response.Value;
78 //foreach (Object o in hash)
79 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
80 try
81 {
82 bool success = false;
83 Boolean.TryParse((string)hash["result"], out success);
84 if (success)
85 {
86 IPEndPoint ep = null;
87 int port = 0;
88 if (hash["ep_port"] != null)
89 Int32.TryParse((string)hash["ep_port"], out port);
90 if (hash["ep_addr"] != null)
91 ep = new IPEndPoint(IPAddress.Parse((string)hash["ep_addr"]), port);
92
93 return ep;
94 }
95
96 }
97 catch (Exception e)
98 {
99 m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace);
100 return null;
101 }
102
103 return null;
104 }
105
106 private void Call(string method, Hashtable hash)
107 {
108 IList paramList = new ArrayList();
109 paramList.Add(hash);
110
111 XmlRpcRequest request = new XmlRpcRequest(method, paramList);
112 XmlRpcResponse response = null;
113 try
114 {
115 response = request.Send(m_ServerURL, 10000);
116 }
117 catch (Exception e)
118 {
119 m_log.Debug("[HGrid]: Exception " + e.Message);
120 return ;
121 }
122
123 if (response.IsFault)
124 {
125 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
126 return ;
127 }
128
129 }
130
131 }
132}
diff --git a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
index 953c7bd..1786d38 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
@@ -41,22 +41,49 @@ using OpenMetaverse;
41using OpenMetaverse.Imaging; 41using OpenMetaverse.Imaging;
42using log4net; 42using log4net;
43using Nwc.XmlRpc; 43using Nwc.XmlRpc;
44using Nini.Config;
44 45
45namespace OpenSim.Services.Connectors.Hypergrid 46namespace OpenSim.Services.Connectors.Hypergrid
46{ 47{
47 public class HypergridServiceConnector 48 public class HypergridServiceConnector : IHypergridService
48 { 49 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 51
51 private IAssetService m_AssetService; 52 private IAssetService m_AssetService;
53 private string m_ServerURL;
52 54
53 public HypergridServiceConnector() : this(null) { } 55 public HypergridServiceConnector() { }
54 56
55 public HypergridServiceConnector(IAssetService assService) 57 public HypergridServiceConnector(IAssetService assService)
56 { 58 {
57 m_AssetService = assService; 59 m_AssetService = assService;
58 } 60 }
59 61
62 public HypergridServiceConnector(IConfigSource source)
63 {
64 Initialise(source);
65 }
66
67 public virtual void Initialise(IConfigSource source)
68 {
69 IConfig hgConfig = source.Configs["HypergridService"];
70 if (hgConfig == null)
71 {
72 m_log.Error("[HYPERGRID CONNECTOR]: HypergridService missing from OpenSim.ini");
73 throw new Exception("Hypergrid connector init error");
74 }
75
76 string serviceURI = hgConfig.GetString("HypergridServerURI",
77 String.Empty);
78
79 if (serviceURI == String.Empty)
80 {
81 m_log.Error("[HYPERGRID CONNECTOR]: No Server URI named in section HypergridService");
82 throw new Exception("Hypergrid connector init error");
83 }
84 m_ServerURL = serviceURI;
85 }
86
60 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) 87 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason)
61 { 88 {
62 regionID = UUID.Zero; 89 regionID = UUID.Zero;
@@ -246,5 +273,82 @@ namespace OpenSim.Services.Connectors.Hypergrid
246 273
247 return null; 274 return null;
248 } 275 }
276
277 #region From local regions to grid-wide hypergrid service
278
279 public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong realHandle, out string imageURL, out string reason)
280 {
281 regionID = UUID.Zero;
282 imageURL = string.Empty;
283 realHandle = 0;
284 reason = string.Empty;
285
286 Hashtable hash = new Hashtable();
287 hash["region_desc"] = regionDescriptor;
288
289 IList paramList = new ArrayList();
290 paramList.Add(hash);
291
292 XmlRpcRequest request = new XmlRpcRequest("link_region_by_desc", paramList);
293 XmlRpcResponse response = null;
294 try
295 {
296 response = request.Send(m_ServerURL, 10000);
297 }
298 catch (Exception e)
299 {
300 m_log.Debug("[HGrid]: Exception " + e.Message);
301 reason = "Error contacting remote server";
302 return false;
303 }
304
305 if (response.IsFault)
306 {
307 reason = response.FaultString;
308 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
309 return false;
310 }
311
312 hash = (Hashtable)response.Value;
313 //foreach (Object o in hash)
314 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
315 try
316 {
317 bool success = false;
318 Boolean.TryParse((string)hash["result"], out success);
319 if (success)
320 {
321 UUID.TryParse((string)hash["uuid"], out regionID);
322 //m_log.Debug(">> HERE, uuid: " + uuid);
323 if ((string)hash["handle"] != null)
324 {
325 realHandle = Convert.ToUInt64((string)hash["handle"]);
326 //m_log.Debug(">> HERE, realHandle: " + realHandle);
327 }
328 if (hash["region_image"] != null)
329 {
330 imageURL = (string)hash["region_image"];
331 }
332 }
333
334 }
335 catch (Exception e)
336 {
337 reason = "Error parsing return arguments";
338 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
339 return false;
340 }
341
342 return true;
343 }
344
345 // TODO !!!
346 public GridRegion GetRegionByUUID(UUID regionID) { return null; }
347 public GridRegion GetRegionByPosition(int x, int y) { return null; }
348 public GridRegion GetRegionByName(string name) { return null; }
349 public List<GridRegion> GetRegionsByName(string name) { return null; }
350 public List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax) { return null; }
351
352 #endregion
249 } 353 }
250} 354}
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
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
30using System.Reflection; 31using System.Reflection;
31 32
32using OpenSim.Framework; 33using 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}
diff --git a/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs b/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs
new file mode 100644
index 0000000..a7adfc1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs
@@ -0,0 +1,67 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.Reflection;
5
6using OpenSim.Services.Interfaces;
7
8using OpenMetaverse;
9using log4net;
10using Nini.Config;
11
12namespace OpenSim.Services.HypergridService
13{
14 /// <summary>
15 /// This service is for HG1.5 only, to make up for the fact that clients don't
16 /// keep any private information in themselves, and that their 'home service'
17 /// needs to do it for them.
18 /// Once we have better clients, this shouldn't be needed.
19 /// </summary>
20 public class HomeUsersSecurityService : IHomeUsersSecurityService
21 {
22 private static readonly ILog m_log =
23 LogManager.GetLogger(
24 MethodBase.GetCurrentMethod().DeclaringType);
25
26 //
27 // This is a persistent storage wannabe for dealing with the
28 // quirks of HG1.5. We don't really want to store this in a table.
29 // But this is the necessary information for securing clients
30 // coming home.
31 //
32 protected static Dictionary<UUID, IPEndPoint> m_ClientEndPoints = new Dictionary<UUID, IPEndPoint>();
33
34 public HomeUsersSecurityService(IConfigSource config)
35 {
36 m_log.DebugFormat("[HOME USERS SECURITY]: Starting...");
37 }
38
39 public void SetEndPoint(UUID sessionID, IPEndPoint ep)
40 {
41 m_log.DebugFormat("[HOME USERS SECURITY]: Set EndPoint {0} for session {1}", ep.ToString(), sessionID);
42
43 lock (m_ClientEndPoints)
44 m_ClientEndPoints[sessionID] = ep;
45 }
46
47 public IPEndPoint GetEndPoint(UUID sessionID)
48 {
49 lock (m_ClientEndPoints)
50 if (m_ClientEndPoints.ContainsKey(sessionID))
51 {
52 m_log.DebugFormat("[HOME USERS SECURITY]: Get EndPoint {0} for session {1}", m_ClientEndPoints[sessionID].ToString(), sessionID);
53 return m_ClientEndPoints[sessionID];
54 }
55
56 return null;
57 }
58
59 public void RemoveEndPoint(UUID sessionID)
60 {
61 m_log.DebugFormat("[HOME USERS SECURITY]: Remove EndPoint for session {0}", sessionID);
62 lock (m_ClientEndPoints)
63 if (m_ClientEndPoints.ContainsKey(sessionID))
64 m_ClientEndPoints.Remove(sessionID);
65 }
66 }
67}
diff --git a/OpenSim/Services/HypergridService/HypergridService.cs b/OpenSim/Services/HypergridService/HypergridService.cs
index 734931d..ac0f5ac 100644
--- a/OpenSim/Services/HypergridService/HypergridService.cs
+++ b/OpenSim/Services/HypergridService/HypergridService.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Services.HypergridService
51 private static HypergridService m_RootInstance = null; 51 private static HypergridService m_RootInstance = null;
52 protected IConfigSource m_config; 52 protected IConfigSource m_config;
53 53
54 protected IAuthenticationService m_AuthenticationService = null; 54 protected IPresenceService m_PresenceService = null;
55 protected IGridService m_GridService; 55 protected IGridService m_GridService;
56 protected IAssetService m_AssetService; 56 protected IAssetService m_AssetService;
57 protected HypergridServiceConnector m_HypergridConnector; 57 protected HypergridServiceConnector m_HypergridConnector;
@@ -94,7 +94,7 @@ namespace OpenSim.Services.HypergridService
94 if (gridConfig != null) 94 if (gridConfig != null)
95 { 95 {
96 string gridService = gridConfig.GetString("GridService", string.Empty); 96 string gridService = gridConfig.GetString("GridService", string.Empty);
97 string authService = gridConfig.GetString("AuthenticationService", String.Empty); 97 string presenceService = gridConfig.GetString("PresenceService", String.Empty);
98 string assetService = gridConfig.GetString("AssetService", string.Empty); 98 string assetService = gridConfig.GetString("AssetService", string.Empty);
99 99
100 Object[] args = new Object[] { config }; 100 Object[] args = new Object[] { config };
@@ -104,8 +104,8 @@ namespace OpenSim.Services.HypergridService
104 if (m_GridService == null) 104 if (m_GridService == null)
105 throw new Exception("HypergridService cannot function without a GridService"); 105 throw new Exception("HypergridService cannot function without a GridService");
106 106
107 if (authService != String.Empty) 107 if (presenceService != String.Empty)
108 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 108 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
109 109
110 if (assetService != string.Empty) 110 if (assetService != string.Empty)
111 m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args); 111 m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args);
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs
index d41df75..5b5c9d1 100644
--- a/OpenSim/Services/Interfaces/IGatekeeperService.cs
+++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Net;
29using System.Collections.Generic; 30using System.Collections.Generic;
30 31
31using OpenSim.Framework; 32using OpenSim.Framework;
@@ -39,5 +40,18 @@ namespace OpenSim.Services.Interfaces
39 GridRegion GetHyperlinkRegion(UUID regionID); 40 GridRegion GetHyperlinkRegion(UUID regionID);
40 41
41 bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason); 42 bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason);
43
44 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
45
46 }
47
48 /// <summary>
49 /// HG1.5 only
50 /// </summary>
51 public interface IHomeUsersSecurityService
52 {
53 void SetEndPoint(UUID sessionID, IPEndPoint ep);
54 IPEndPoint GetEndPoint(UUID sessionID);
55 void RemoveEndPoint(UUID sessionID);
42 } 56 }
43} 57}
diff --git a/OpenSim/Services/Interfaces/IHypergridService.cs b/OpenSim/Services/Interfaces/IHypergridService.cs
index dd3c053..86ef1b4 100644
--- a/OpenSim/Services/Interfaces/IHypergridService.cs
+++ b/OpenSim/Services/Interfaces/IHypergridService.cs
@@ -43,6 +43,7 @@ namespace OpenSim.Services.Interfaces
43 GridRegion GetRegionByName(string name); 43 GridRegion GetRegionByName(string name);
44 List<GridRegion> GetRegionsByName(string name); 44 List<GridRegion> GetRegionsByName(string name);
45 List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax); 45 List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax);
46
46 } 47 }
47 48
48} 49}