From b2e6ec9e12ad07eb08496ebe8ca0476b793017d5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 18:04:55 -0800 Subject: Agent gets there through the Gatekeeper, but still a few quirks to fix. --- .../Simulation/SimulationServiceConnector.cs | 23 ++++++-- .../Services/HypergridService/GatekeeperService.cs | 68 ++++++++++++++++++++-- OpenSim/Services/Interfaces/IGatekeeperService.cs | 7 +++ OpenSim/Services/Interfaces/IHypergridService.cs | 1 + 4 files changed, 87 insertions(+), 12 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index b1b2a30..683fe79 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -65,6 +65,11 @@ namespace OpenSim.Services.Connectors.Simulation #region Agents + protected virtual string AgentPath() + { + return "/agent/"; + } + public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) { reason = String.Empty; @@ -80,7 +85,7 @@ namespace OpenSim.Services.Connectors.Simulation string uri = string.Empty; try { - uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + aCircuit.AgentID + "/"; + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + aCircuit.AgentID + "/"; } catch (Exception e) { @@ -197,7 +202,8 @@ namespace OpenSim.Services.Connectors.Simulation catch (WebException ex) { m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); - // ignore, really + reason = "Destination did not reply"; + return false; } finally { @@ -224,7 +230,7 @@ namespace OpenSim.Services.Connectors.Simulation string uri = string.Empty; try { - uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + cAgentData.AgentID + "/"; + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + cAgentData.AgentID + "/"; } catch (Exception e) { @@ -329,7 +335,7 @@ namespace OpenSim.Services.Connectors.Simulation { agent = null; // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/"; + string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); @@ -426,7 +432,7 @@ namespace OpenSim.Services.Connectors.Simulation string uri = string.Empty; try { - uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/"; + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; } catch (Exception e) { @@ -474,10 +480,15 @@ namespace OpenSim.Services.Connectors.Simulation #region Objects + protected virtual string ObjectPath() + { + return "/object/"; + } + public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) { string uri - = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/object/" + sog.UUID + "/"; + = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + ObjectPath() + sog.UUID + "/"; //m_log.Debug(" >>> DoCreateObjectCall <<< " + uri); WebRequest ObjectCreateRequest = WebRequest.Create(uri); diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index a5bd881..416e443 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -164,57 +164,103 @@ namespace OpenSim.Services.HypergridService return region; } - public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination) + public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) { + reason = string.Empty; + string authURL = string.Empty; if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); - m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to login foreign agent {0} {1} @ {2} ({3}) at destination {4}", aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName); if (!Authenticate(aCircuit)) { + reason = "Unable to verify identity"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Unable to verify identity of agent {0} {1}. Refusing service.", aCircuit.firstname, aCircuit.lastname); return false; } + m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL); // Check to see if we have a local user with that UUID UserAccount account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); if (account != null) { // No, sorry; go away + reason = "User identifier not allowed on this grid"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has UUID of local user {3}. Refusing service.", aCircuit.firstname, aCircuit.lastname, aCircuit.AgentID); return false; } + m_log.DebugFormat("[GATEKEEPER SERVICE]: User ID ok"); // May want to authorize // Login the presence if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) { + reason = "Unable to login presence"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Presence login failed for foreign agent {0} {1}. Refusing service.", aCircuit.firstname, aCircuit.lastname); return false; } + m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); + + // Get the region + destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID); + if (destination == null) + { + reason = "Destination region not found"; + return false; + } + m_log.DebugFormat("[GATEKEEPER SERVICE]: destination ok : {0}", destination.RegionName); // Finally launch the agent at the destination - string reason = string.Empty; aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname; aCircuit.lastname = "@" + aCircuit.ServiceURLs["HomeURI"].ToString(); return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); } - public bool LoginAttachments(ISceneObject sog, GridRegion destination) + public bool UpdateAgent(GridRegion destination, AgentData agent) + { + // Get the region + destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID); + if (destination == null) + { + return false; + } + + return m_SimulationService.UpdateAgent(destination, agent); + } + + public bool LoginAttachment(GridRegion destination, ISceneObject sog) { + // Get the region + destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID); + if (destination == null) + { + return false; + } + // May want to filter attachments return m_SimulationService.CreateObject(destination, sog, false); } + public void ReleaseAgent(UUID regionID, UUID agentID) + { + GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID); + if (region != null) + { + string uri = "http://" + region.ExternalHostName + ":" + region.HttpPort + + "/agent/" + agentID.ToString() + "/" + regionID.ToString() + "/release/"; + + m_SimulationService.ReleaseAgent(regionID, agentID, uri); + } + } + protected bool Authenticate(AgentCircuitData aCircuit) { - string authURL = string.Empty; + string authURL = string.Empty; if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); @@ -227,7 +273,17 @@ namespace OpenSim.Services.HypergridService Object[] args = new Object[] { authURL }; IAuthenticationService authService = ServerUtils.LoadPlugin(m_AuthDll, args); if (authService != null) - return authService.Verify(aCircuit.AgentID, aCircuit.SecureSessionID.ToString(), 30); + { + try + { + return authService.Verify(aCircuit.AgentID, aCircuit.SecureSessionID.ToString(), 30); + } + catch + { + m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", authURL); + return false; + } + } return false; } diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs index 9904e20..5e21804 100644 --- a/OpenSim/Services/Interfaces/IGatekeeperService.cs +++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using OpenSim.Framework; using OpenMetaverse; namespace OpenSim.Services.Interfaces @@ -36,5 +37,11 @@ namespace OpenSim.Services.Interfaces { bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason); GridRegion GetHyperlinkRegion(UUID regionID); + + bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason); + bool UpdateAgent(GridRegion destination, AgentData agent); + void ReleaseAgent(UUID regionID, UUID agentID); + + bool LoginAttachment(GridRegion destination, ISceneObject sog); } } diff --git a/OpenSim/Services/Interfaces/IHypergridService.cs b/OpenSim/Services/Interfaces/IHypergridService.cs index f2a1983..dd3c053 100644 --- a/OpenSim/Services/Interfaces/IHypergridService.cs +++ b/OpenSim/Services/Interfaces/IHypergridService.cs @@ -44,4 +44,5 @@ namespace OpenSim.Services.Interfaces List GetRegionsByName(string name); List GetRegionRange(int xmin, int xmax, int ymin, int ymax); } + } -- cgit v1.1