From 982e3ff5d927df498c1d14111e2c61f0251c09d4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 01:27:51 +0000 Subject: Presence Step 1 --- OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 2558fa0..d41ee28 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -95,7 +95,6 @@ namespace OpenSim.Server.Handlers.Presence byte[] Report(Dictionary request) { PresenceInfo info = new PresenceInfo(); - info.Data = new Dictionary(); if (request["PrincipalID"] == null || request["RegionID"] == null) return FailureResult(); @@ -108,15 +107,6 @@ namespace OpenSim.Server.Handlers.Presence out info.RegionID)) return FailureResult(); - foreach (KeyValuePair kvp in request) - { - if (kvp.Key == "METHOD" || - kvp.Key == "PrincipalID" || - kvp.Key == "RegionID") - continue; - - info.Data[kvp.Key] = kvp.Value; - } if (m_PresenceService.Report(info)) return SuccessResult(); -- cgit v1.1 From 490c09363641c6f90b8c4fc574d47daee6074a63 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 02:11:25 +0000 Subject: Just make it compile :) --- OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index d41ee28..8a68169 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -108,8 +108,8 @@ namespace OpenSim.Server.Handlers.Presence return FailureResult(); - if (m_PresenceService.Report(info)) - return SuccessResult(); +// if (m_PresenceService.ReportAgent(info)) +// return SuccessResult(); return FailureResult(); } -- cgit v1.1 From 9cef5f92a1c3edf2ef475706931f1536f2c8524f Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 03:31:53 +0000 Subject: Change the signature of the forms requester data in preparation to getting to where lists can be sent as requests --- .../AuthenticationServerPostHandler.cs | 14 ++-- .../Server/Handlers/Grid/GridServerPostHandler.cs | 92 +++++++++++----------- .../Handlers/Presence/PresenceServerPostHandler.cs | 8 +- 3 files changed, 57 insertions(+), 57 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 490a13a..47bc860 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs @@ -86,14 +86,14 @@ namespace OpenSim.Server.Handlers.Authentication private byte[] DoPlainMethods(string body) { - Dictionary request = + Dictionary request = ServerUtils.ParseQueryString(body); int lifetime = 30; if (request.ContainsKey("LIFETIME")) { - lifetime = Convert.ToInt32(request["LIFETIME"]); + lifetime = Convert.ToInt32(request["LIFETIME"].ToString()); if (lifetime > 30) lifetime = 30; } @@ -103,12 +103,12 @@ namespace OpenSim.Server.Handlers.Authentication if (!request.ContainsKey("PRINCIPAL")) return FailureResult(); - string method = request["METHOD"]; + string method = request["METHOD"].ToString(); UUID principalID; string token; - if (!UUID.TryParse(request["PRINCIPAL"], out principalID)) + if (!UUID.TryParse(request["PRINCIPAL"].ToString(), out principalID)) return FailureResult(); switch (method) @@ -117,7 +117,7 @@ namespace OpenSim.Server.Handlers.Authentication if (!request.ContainsKey("PASSWORD")) return FailureResult(); - token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"], lifetime); + token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"].ToString(), lifetime); if (token != String.Empty) return SuccessResult(token); @@ -126,7 +126,7 @@ namespace OpenSim.Server.Handlers.Authentication if (!request.ContainsKey("TOKEN")) return FailureResult(); - if (m_AuthenticationService.Verify(principalID, request["TOKEN"], lifetime)) + if (m_AuthenticationService.Verify(principalID, request["TOKEN"].ToString(), lifetime)) return SuccessResult(); return FailureResult(); @@ -134,7 +134,7 @@ namespace OpenSim.Server.Handlers.Authentication if (!request.ContainsKey("TOKEN")) return FailureResult(); - if (m_AuthenticationService.Release(principalID, request["TOKEN"])) + if (m_AuthenticationService.Release(principalID, request["TOKEN"].ToString())) return SuccessResult(); return FailureResult(); diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 433ed0b..d99b791 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -69,13 +69,13 @@ namespace OpenSim.Server.Handlers.Grid try { - Dictionary request = + Dictionary request = ServerUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) return FailureResult(); - string method = request["METHOD"]; + string method = request["METHOD"].ToString(); switch (method) { @@ -117,22 +117,22 @@ namespace OpenSim.Server.Handlers.Grid #region Method-specific handlers - byte[] Register(Dictionary request) + byte[] Register(Dictionary request) { UUID scopeID = UUID.Zero; if (request.ContainsKey("SCOPEID")) - UUID.TryParse(request["SCOPEID"], out scopeID); + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); int versionNumberMin = 0, versionNumberMax = 0; if (request.ContainsKey("VERSIONMIN")) - Int32.TryParse(request["VERSIONMIN"], out versionNumberMin); + Int32.TryParse(request["VERSIONMIN"].ToString(), out versionNumberMin); else m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region"); if (request.ContainsKey("VERSIONMAX")) - Int32.TryParse(request["VERSIONMAX"], out versionNumberMax); + Int32.TryParse(request["VERSIONMAX"].ToString(), out versionNumberMax); else m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); @@ -147,8 +147,8 @@ namespace OpenSim.Server.Handlers.Grid GridRegion rinfo = null; try { - foreach (KeyValuePair kvp in request) - rinfoData[kvp.Key] = kvp.Value; + foreach (KeyValuePair kvp in request) + rinfoData[kvp.Key] = kvp.Value.ToString(); rinfo = new GridRegion(rinfoData); } catch (Exception e) @@ -166,11 +166,11 @@ namespace OpenSim.Server.Handlers.Grid return FailureResult(); } - byte[] Deregister(Dictionary request) + byte[] Deregister(Dictionary request) { UUID regionID = UUID.Zero; - if (request["REGIONID"] != null) - UUID.TryParse(request["REGIONID"], out regionID); + if (request.ContainsKey("REGIONID")) + UUID.TryParse(request["REGIONID"].ToString(), out regionID); else m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region"); @@ -183,17 +183,17 @@ namespace OpenSim.Server.Handlers.Grid } - byte[] GetNeighbours(Dictionary request) + byte[] GetNeighbours(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); UUID regionID = UUID.Zero; - if (request["REGIONID"] != null) - UUID.TryParse(request["REGIONID"], out regionID); + if (request.ContainsKey("REGIONID")) + UUID.TryParse(request["REGIONID"].ToString(), out regionID); else m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); @@ -221,17 +221,17 @@ namespace OpenSim.Server.Handlers.Grid } - byte[] GetRegionByUUID(Dictionary request) + byte[] GetRegionByUUID(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); UUID regionID = UUID.Zero; - if (request["REGIONID"] != null) - UUID.TryParse(request["REGIONID"], out regionID); + if (request.ContainsKey("REGIONID")) + UUID.TryParse(request["REGIONID"].ToString(), out regionID); else m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); @@ -250,21 +250,21 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } - byte[] GetRegionByPosition(Dictionary request) + byte[] GetRegionByPosition(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); int x = 0, y = 0; - if (request["X"] != null) - Int32.TryParse(request["X"], out x); + if (request.ContainsKey("X")) + Int32.TryParse(request["X"].ToString(), out x); else m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); - if (request["Y"] != null) - Int32.TryParse(request["Y"], out y); + if (request.ContainsKey("Y")) + Int32.TryParse(request["Y"].ToString(), out y); else m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); @@ -283,17 +283,17 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } - byte[] GetRegionByName(Dictionary request) + byte[] GetRegionByName(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); string regionName = string.Empty; - if (request["NAME"] != null) - regionName = request["NAME"]; + if (request.ContainsKey("NAME")) + regionName = request["NAME"].ToString(); else m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); @@ -312,23 +312,23 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } - byte[] GetRegionsByName(Dictionary request) + byte[] GetRegionsByName(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); string regionName = string.Empty; - if (request["NAME"] != null) - regionName = request["NAME"]; + if (request.ContainsKey("NAME")) + regionName = request["NAME"].ToString(); else m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); int max = 0; - if (request["MAX"] != null) - Int32.TryParse(request["MAX"], out max); + if (request.ContainsKey("MAX")) + Int32.TryParse(request["MAX"].ToString(), out max); else m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); @@ -355,30 +355,30 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } - byte[] GetRegionRange(Dictionary request) + byte[] GetRegionRange(Dictionary request) { //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); UUID scopeID = UUID.Zero; if (request.ContainsKey("SCOPEID")) - UUID.TryParse(request["SCOPEID"], out scopeID); + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); int xmin = 0, xmax = 0, ymin = 0, ymax = 0; if (request.ContainsKey("XMIN")) - Int32.TryParse(request["XMIN"], out xmin); + Int32.TryParse(request["XMIN"].ToString(), out xmin); else m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); if (request.ContainsKey("XMAX")) - Int32.TryParse(request["XMAX"], out xmax); + Int32.TryParse(request["XMAX"].ToString(), out xmax); else m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); if (request.ContainsKey("YMIN")) - Int32.TryParse(request["YMIN"], out ymin); + Int32.TryParse(request["YMIN"].ToString(), out ymin); else m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); if (request.ContainsKey("YMAX")) - Int32.TryParse(request["YMAX"], out ymax); + Int32.TryParse(request["YMAX"].ToString(), out ymax); else m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 8a68169..d914d32 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -68,13 +68,13 @@ namespace OpenSim.Server.Handlers.Presence try { - Dictionary request = + Dictionary request = ServerUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) return FailureResult(); - string method = request["METHOD"]; + string method = request["METHOD"].ToString(); switch (method) { @@ -92,11 +92,11 @@ namespace OpenSim.Server.Handlers.Presence } - byte[] Report(Dictionary request) + byte[] Report(Dictionary request) { PresenceInfo info = new PresenceInfo(); - if (request["PrincipalID"] == null || request["RegionID"] == null) + if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("RegionID")) return FailureResult(); if (!UUID.TryParse(request["PrincipalID"].ToString(), -- cgit v1.1 From 3ef513e863097bdccffa8c84283ab8ffc0915a8f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Dec 2009 20:34:42 -0800 Subject: Presence remote connector and handler. Presence HG Broker. Nothing tested, just compiles. --- .../Handlers/Presence/PresenceServerPostHandler.cs | 152 +++++++++++++++++++-- 1 file changed, 144 insertions(+), 8 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index d914d32..b02c2ed 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -78,8 +78,18 @@ namespace OpenSim.Server.Handlers.Presence switch (method) { + case "login": + return LoginAgent(request); + case "logout": + return LogoutAgent(request); + case "logoutregion": + return LogoutRegionAgents(request); case "report": return Report(request); + case "getagent": + return GetAgent(request); + case "getagents": + return GetAgents(request); } m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); } @@ -92,28 +102,154 @@ namespace OpenSim.Server.Handlers.Presence } + byte[] LoginAgent(Dictionary request) + { + UUID principal = UUID.Zero; + UUID session = UUID.Zero; + UUID ssession = UUID.Zero; + + if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("SessionID")) + return FailureResult(); + + if (!UUID.TryParse(request["PrincipalID"].ToString(), out principal)) + return FailureResult(); + + if (!UUID.TryParse(request["SessionID"].ToString(), out session)) + return FailureResult(); + + if (request.ContainsKey("SecureSessionID")) + // If it's malformed, we go on with a Zero on it + UUID.TryParse(request["SecureSessionID"].ToString(), out ssession); + + if (m_PresenceService.LoginAgent(principal, session, ssession)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] LogoutAgent(Dictionary request) + { + UUID session = UUID.Zero; + + if (!request.ContainsKey("SessionID")) + return FailureResult(); + + if (!UUID.TryParse(request["SessionID"].ToString(), out session)) + return FailureResult(); + + if (m_PresenceService.LogoutAgent(session)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] LogoutRegionAgents(Dictionary request) + { + UUID region = UUID.Zero; + + if (!request.ContainsKey("RegionID")) + return FailureResult(); + + if (!UUID.TryParse(request["RegionID"].ToString(), out region)) + return FailureResult(); + + if (m_PresenceService.LogoutRegionAgents(region)) + return SuccessResult(); + + return FailureResult(); + } + byte[] Report(Dictionary request) { - PresenceInfo info = new PresenceInfo(); + UUID session = UUID.Zero; + UUID region = UUID.Zero; + Vector3 position = new Vector3(128, 128, 70); + Vector3 look = Vector3.Zero; - if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("RegionID")) + if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID")) return FailureResult(); - if (!UUID.TryParse(request["PrincipalID"].ToString(), - out info.PrincipalID)) + if (!UUID.TryParse(request["SessionID"].ToString(), out session)) return FailureResult(); - if (!UUID.TryParse(request["RegionID"].ToString(), - out info.RegionID)) + if (!UUID.TryParse(request["RegionID"].ToString(), out region)) return FailureResult(); + if (request.ContainsKey("position")) + Vector3.TryParse(request["position"].ToString(), out position); -// if (m_PresenceService.ReportAgent(info)) -// return SuccessResult(); + if (request.ContainsKey("lookAt")) + Vector3.TryParse(request["lookAt"].ToString(), out look); + + if (m_PresenceService.ReportAgent(session, region, position, look)) + return SuccessResult(); return FailureResult(); } + byte[] GetAgent(Dictionary request) + { + UUID session = UUID.Zero; + + if (!request.ContainsKey("SessionID")) + return FailureResult(); + + if (!UUID.TryParse(request["SessionID"].ToString(), out session)) + return FailureResult(); + + PresenceInfo pinfo = m_PresenceService.GetAgent(session); + + Dictionary result = new Dictionary(); + if (pinfo == null) + result["result"] = "null"; + else + result["result"] = pinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + + byte[] GetAgents(Dictionary request) + { + + string[] userIDs; + + if (!request.ContainsKey("uuids")) + return FailureResult(); + + if (!(request["uuids"] is List)) + { + m_log.DebugFormat("[PRESENCE HANDLER]: GetAgents input argument was of unexpected type {0}", request["uuids"].GetType().ToString()); + return FailureResult(); + } + + userIDs = ((List)request["uuids"]).ToArray(); + + PresenceInfo[] pinfos = m_PresenceService.GetAgents(userIDs); + + Dictionary result = new Dictionary(); + if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (PresenceInfo pinfo in pinfos) + { + Dictionary rinfoDict = pinfo.ToKeyValuePairs(); + result["presence" + i] = rinfoDict; + i++; + } + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + + private byte[] SuccessResult() { XmlDocument doc = new XmlDocument(); -- cgit v1.1 From 92a40129b5dfde0d8ef798941f5efb31ca3a73fd Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 17:34:42 +0000 Subject: Database and presence changes. Untested --- OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index b02c2ed..580cb15 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -104,15 +104,14 @@ namespace OpenSim.Server.Handlers.Presence byte[] LoginAgent(Dictionary request) { - UUID principal = UUID.Zero; + string user = String.Empty; UUID session = UUID.Zero; UUID ssession = UUID.Zero; - if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("SessionID")) + if (!request.ContainsKey("UserID") || !request.ContainsKey("SessionID")) return FailureResult(); - if (!UUID.TryParse(request["PrincipalID"].ToString(), out principal)) - return FailureResult(); + user = request["UserID"].ToString(); if (!UUID.TryParse(request["SessionID"].ToString(), out session)) return FailureResult(); @@ -121,7 +120,7 @@ namespace OpenSim.Server.Handlers.Presence // If it's malformed, we go on with a Zero on it UUID.TryParse(request["SecureSessionID"].ToString(), out ssession); - if (m_PresenceService.LoginAgent(principal, session, ssession)) + if (m_PresenceService.LoginAgent(user, session, ssession)) return SuccessResult(); return FailureResult(); -- cgit v1.1 From e0fc854f05b137c353196356e5b26d11b6ee6867 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 23:42:08 +0000 Subject: Adding new fields and home location methid to presence. Adding cleanup (deleting all but one presence record) on logout so that they don't pile up. --- .../Handlers/Presence/PresenceServerPostHandler.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 580cb15..bb00a00 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -90,6 +90,8 @@ namespace OpenSim.Server.Handlers.Presence return GetAgent(request); case "getagents": return GetAgents(request); + case "sethome": + return SetHome(request); } m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); } @@ -303,5 +305,32 @@ namespace OpenSim.Server.Handlers.Presence return ms.ToArray(); } + + byte[] SetHome(Dictionary request) + { + UUID region = UUID.Zero; + Vector3 position = new Vector3(128, 128, 70); + Vector3 look = Vector3.Zero; + + if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID")) + return FailureResult(); + + string user = request["UserID"].ToString(); + + if (!UUID.TryParse(request["RegionID"].ToString(), out region)) + return FailureResult(); + + if (request.ContainsKey("position")) + Vector3.TryParse(request["position"].ToString(), out position); + + if (request.ContainsKey("lookAt")) + Vector3.TryParse(request["lookAt"].ToString(), out look); + + if (m_PresenceService.SetHomeLocation(user, region, position, look)) + return SuccessResult(); + + return FailureResult(); + } + } } -- cgit v1.1 From b4483df2701483aabd43fc7d03ebd74770d70170 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Dec 2009 15:58:40 -0800 Subject: * All modules and connectors for user account service are in place. Untested. * Cleaned up a few things on presence connectors --- .../Handlers/Presence/PresenceServerPostHandler.cs | 4 +- .../UserAccounts/UserAccountServerConnector.cs | 61 +++++ .../UserAccounts/UserAccountServerPostHandler.cs | 276 +++++++++++++++++++++ 3 files changed, 339 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs create mode 100644 OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index bb00a00..11adc4a 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -265,7 +265,7 @@ namespace OpenSim.Server.Handlers.Presence doc.AppendChild(rootElement); - XmlElement result = doc.CreateElement("", "Result", ""); + XmlElement result = doc.CreateElement("", "result", ""); result.AppendChild(doc.CreateTextNode("Success")); rootElement.AppendChild(result); @@ -287,7 +287,7 @@ namespace OpenSim.Server.Handlers.Presence doc.AppendChild(rootElement); - XmlElement result = doc.CreateElement("", "Result", ""); + XmlElement result = doc.CreateElement("", "result", ""); result.AppendChild(doc.CreateTextNode("Failure")); rootElement.AppendChild(result); diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs new file mode 100644 index 0000000..f17a8de --- /dev/null +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs @@ -0,0 +1,61 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using Nini.Config; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +namespace OpenSim.Server.Handlers.UserAccounts +{ + public class UserAccountServiceConnector : ServiceConnector + { + private IUserAccountService m_UserAccountService; + private string m_ConfigName = "UserAccountService"; + + public UserAccountServiceConnector(IConfigSource config, IHttpServer server, string configName) : + base(config, server, configName) + { + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); + + string service = serverConfig.GetString("LocalServiceModule", + String.Empty); + + if (service == String.Empty) + throw new Exception("No LocalServiceModule in config file"); + + Object[] args = new Object[] { config }; + m_UserAccountService = ServerUtils.LoadPlugin(service, args); + + server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService)); + } + } +} diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs new file mode 100644 index 0000000..a92148c --- /dev/null +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs @@ -0,0 +1,276 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using Nini.Config; +using log4net; +using System; +using System.Reflection; +using System.IO; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Serialization; +using System.Collections.Generic; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.UserAccounts +{ + public class UserAccountServerPostHandler : BaseStreamHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IUserAccountService m_UserAccountService; + + public UserAccountServerPostHandler(IUserAccountService service) : + base("POST", "/accounts") + { + m_UserAccountService = service; + } + + public override byte[] Handle(string path, Stream requestData, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + StreamReader sr = new StreamReader(requestData); + string body = sr.ReadToEnd(); + sr.Close(); + body = body.Trim(); + + // We need to check the authorization header + //httpRequest.Headers["authorization"] ... + + //m_log.DebugFormat("[XXX]: query String: {0}", body); + + try + { + Dictionary request = + ServerUtils.ParseQueryString(body); + + if (!request.ContainsKey("METHOD")) + return FailureResult(); + + string method = request["METHOD"].ToString(); + + switch (method) + { + case "getaccount": + return GetAccount(request); + case "getaccounts": + return GetAccounts(request); + case "createaccount": + return CreateAccount(request); + case "setaccount": + return SetAccount(request); + } + m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); + } + catch (Exception e) + { + m_log.Debug("[PRESENCE HANDLER]: Exception {0}" + e); + } + + return FailureResult(); + + } + + byte[] GetAccount(Dictionary request) + { + UserAccount account = null; + UUID scopeID = UUID.Zero; + Dictionary result = new Dictionary(); + + if (!request.ContainsKey("ScopeID")) + { + result["result"] = "null"; + return ResultToBytes(result); + } + + if (!UUID.TryParse(request["ScopeID"].ToString(), out scopeID)) + { + result["result"] = "null"; + return ResultToBytes(result); + } + + if (request.ContainsKey("UserID") && request["UserID"] != null) + { + UUID userID; + if (UUID.TryParse(request["UserID"].ToString(), out userID)) + account = m_UserAccountService.GetUserAccount(scopeID, userID); + } + + else if (request.ContainsKey("Email") && request["Email"] != null) + account = m_UserAccountService.GetUserAccount(scopeID, request["Email"].ToString()); + + else if (request.ContainsKey("FirstName") && request.ContainsKey("LastName") && + request["FirstName"] != null && request["LastName"] != null) + account = m_UserAccountService.GetUserAccount(scopeID, request["FirstName"].ToString(), request["LastName"].ToString()); + + if (account == null) + result["result"] = "null"; + else + result["result"] = account.ToKeyValuePairs(); + + return ResultToBytes(result); + } + + byte[] GetAccounts(Dictionary request) + { + if (!request.ContainsKey("ScopeID") || !request.ContainsKey("query")) + return FailureResult(); + + UUID scopeID = UUID.Zero; + if (!UUID.TryParse(request["ScopeID"].ToString(), out scopeID)) + return FailureResult(); + + string query = request["query"].ToString(); + + List accounts = m_UserAccountService.GetUserAccounts(scopeID, query); + + Dictionary result = new Dictionary(); + if ((accounts == null) || ((accounts != null) && (accounts.Count == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (UserAccount acc in accounts) + { + Dictionary rinfoDict = acc.ToKeyValuePairs(); + result["account" + i] = rinfoDict; + i++; + } + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + + byte[] CreateAccount(Dictionary request) + { + if (!request.ContainsKey("account")) + return FailureResult(); + if (request["account"] == null) + return FailureResult(); + if (!(request["account"] is Dictionary)) + return FailureResult(); + + UserAccount account = new UserAccount((Dictionary) request["account"]); + + if (m_UserAccountService.CreateUserAccount(account)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] SetAccount(Dictionary request) + { + if (!request.ContainsKey("account")) + return FailureResult(); + if (request["account"] == null) + return FailureResult(); + if (!(request["account"] is Dictionary)) + return FailureResult(); + + UserAccount account = new UserAccount((Dictionary)request["account"]); + + if (m_UserAccountService.SetUserAccount(account)) + return SuccessResult(); + + return FailureResult(); + } + + private byte[] SuccessResult() + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + XmlElement result = doc.CreateElement("", "result", ""); + result.AppendChild(doc.CreateTextNode("Success")); + + rootElement.AppendChild(result); + + return DocToBytes(doc); + } + + private byte[] FailureResult() + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + XmlElement result = doc.CreateElement("", "result", ""); + result.AppendChild(doc.CreateTextNode("Failure")); + + rootElement.AppendChild(result); + + return DocToBytes(doc); + } + + private byte[] DocToBytes(XmlDocument doc) + { + MemoryStream ms = new MemoryStream(); + XmlTextWriter xw = new XmlTextWriter(ms, null); + xw.Formatting = Formatting.Indented; + doc.WriteTo(xw); + xw.Flush(); + + return ms.ToArray(); + } + + private byte[] ResultToBytes(Dictionary result) + { + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + + + } +} -- cgit v1.1 From 3507005d9decdbf579fb2b7b9928a7d97bd6cf5b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 01:16:16 +0000 Subject: Remove CreateUserAccount. Rename SetUserAccount to StoreUserAccount. Implement the fetch operations fully. Rename one last UserService file to UserAccountService --- .../UserAccounts/UserAccountServerPostHandler.cs | 25 +++------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index a92148c..544ffea 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs @@ -85,10 +85,8 @@ namespace OpenSim.Server.Handlers.UserAccounts return GetAccount(request); case "getaccounts": return GetAccounts(request); - case "createaccount": - return CreateAccount(request); case "setaccount": - return SetAccount(request); + return StoreAccount(request); } m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); } @@ -174,24 +172,7 @@ namespace OpenSim.Server.Handlers.UserAccounts return encoding.GetBytes(xmlString); } - byte[] CreateAccount(Dictionary request) - { - if (!request.ContainsKey("account")) - return FailureResult(); - if (request["account"] == null) - return FailureResult(); - if (!(request["account"] is Dictionary)) - return FailureResult(); - - UserAccount account = new UserAccount((Dictionary) request["account"]); - - if (m_UserAccountService.CreateUserAccount(account)) - return SuccessResult(); - - return FailureResult(); - } - - byte[] SetAccount(Dictionary request) + byte[] StoreAccount(Dictionary request) { if (!request.ContainsKey("account")) return FailureResult(); @@ -202,7 +183,7 @@ namespace OpenSim.Server.Handlers.UserAccounts UserAccount account = new UserAccount((Dictionary)request["account"]); - if (m_UserAccountService.SetUserAccount(account)) + if (m_UserAccountService.StoreUserAccount(account)) return SuccessResult(); return FailureResult(); -- cgit v1.1 From a8901a40f4526720f68049706cabd34cf9717172 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 31 Dec 2009 09:25:16 -0800 Subject: Simulation handlers (agents & objects) completed. --- .../Server/Handlers/Simulation/AgentHandlers.cs | 244 ++++++++++++++++++++- .../Server/Handlers/Simulation/ObjectHandlers.cs | 191 ++++++++++++++++ .../Simulation/SimulationServiceInConnector.cs | 19 +- OpenSim/Server/Handlers/Simulation/Utils.cs | 103 +++++++++ 4 files changed, 544 insertions(+), 13 deletions(-) create mode 100644 OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs create mode 100644 OpenSim/Server/Handlers/Simulation/Utils.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 3da72c7..4966f66 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections; using System.IO; using System.Reflection; using System.Net; @@ -45,6 +46,247 @@ using log4net; namespace OpenSim.Server.Handlers.Simulation { + public class AgentHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private ISimulationService m_SimulationService; + + public AgentHandler(ISimulationService sim) + { + m_SimulationService = sim; + } + + public Hashtable Handler(Hashtable request) + { + //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); + + m_log.Debug("---------------------------"); + m_log.Debug(" >> uri=" + request["uri"]); + m_log.Debug(" >> content-type=" + request["content-type"]); + m_log.Debug(" >> http-method=" + request["http-method"]); + m_log.Debug("---------------------------\n"); + + Hashtable responsedata = new Hashtable(); + responsedata["content_type"] = "text/html"; + responsedata["keepalive"] = false; + + + UUID agentID; + string action; + ulong regionHandle; + if (!Utils.GetParams((string)request["uri"], out agentID, out regionHandle, out action)) + { + m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]); + responsedata["int_response_code"] = 404; + responsedata["str_response_string"] = "false"; + + return responsedata; + } + + // Next, let's parse the verb + string method = (string)request["http-method"]; + if (method.Equals("PUT")) + { + DoAgentPut(request, responsedata); + return responsedata; + } + else if (method.Equals("POST")) + { + DoAgentPost(request, responsedata, agentID); + return responsedata; + } + else if (method.Equals("GET")) + { + DoAgentGet(request, responsedata, agentID, regionHandle); + return responsedata; + } + else if (method.Equals("DELETE")) + { + DoAgentDelete(request, responsedata, agentID, action, regionHandle); + return responsedata; + } + else + { + m_log.InfoFormat("[AGENT HANDLER]: method {0} not supported in agent message", method); + responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; + responsedata["str_response_string"] = "Method not allowed"; + + return responsedata; + } + + } + + protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) + { + OSDMap args = Utils.GetOSDMap((string)request["body"]); + if (args == null) + { + responsedata["int_response_code"] = HttpStatusCode.BadRequest; + responsedata["str_response_string"] = "Bad request"; + return; + } + + // retrieve the regionhandle + ulong regionhandle = 0; + if (args["destination_handle"] != null) + UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); + + AgentCircuitData aCircuit = new AgentCircuitData(); + try + { + aCircuit.UnpackAgentCircuitData(args); + } + catch (Exception ex) + { + m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); + responsedata["int_response_code"] = HttpStatusCode.BadRequest; + responsedata["str_response_string"] = "Bad request"; + return; + } + + OSDMap resp = new OSDMap(2); + string reason = String.Empty; + uint teleportFlags = 0; + if (args.ContainsKey("teleport_flags")) + { + teleportFlags = args["teleport_flags"].AsUInteger(); + } + + // This is the meaning of POST agent + //m_regionClient.AdjustUserInformation(aCircuit); + bool result = m_SimulationService.CreateAgent(regionhandle, aCircuit, teleportFlags, out reason); + + resp["reason"] = OSD.FromString(reason); + resp["success"] = OSD.FromBoolean(result); + + // TODO: add reason if not String.Empty? + responsedata["int_response_code"] = HttpStatusCode.OK; + responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); + } + + protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) + { + OSDMap args = Utils.GetOSDMap((string)request["body"]); + if (args == null) + { + responsedata["int_response_code"] = HttpStatusCode.BadRequest; + responsedata["str_response_string"] = "Bad request"; + return; + } + + // retrieve the regionhandle + ulong regionhandle = 0; + if (args["destination_handle"] != null) + UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); + + string messageType; + if (args["message_type"] != null) + messageType = args["message_type"].AsString(); + else + { + m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. "); + messageType = "AgentData"; + } + + bool result = true; + if ("AgentData".Equals(messageType)) + { + AgentData agent = new AgentData(); + try + { + agent.Unpack(args); + } + catch (Exception ex) + { + m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); + responsedata["int_response_code"] = HttpStatusCode.BadRequest; + responsedata["str_response_string"] = "Bad request"; + return; + } + + //agent.Dump(); + // This is one of the meanings of PUT agent + result = m_SimulationService.UpdateAgent(regionhandle, agent); + + } + else if ("AgentPosition".Equals(messageType)) + { + AgentPosition agent = new AgentPosition(); + try + { + agent.Unpack(args); + } + catch (Exception ex) + { + m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); + return; + } + //agent.Dump(); + // This is one of the meanings of PUT agent + result = m_SimulationService.UpdateAgent(regionhandle, agent); + + } + + responsedata["int_response_code"] = HttpStatusCode.OK; + responsedata["str_response_string"] = result.ToString(); + //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead + } + + protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle) + { + IAgentData agent = null; + bool result = m_SimulationService.RetrieveAgent(regionHandle, id, out agent); + OSDMap map = null; + if (result) + { + if (agent != null) // just to make sure + { + map = agent.Pack(); + string strBuffer = ""; + try + { + strBuffer = OSDParser.SerializeJsonString(map); + } + catch (Exception e) + { + m_log.WarnFormat("[AGENT HANDLER]: Exception thrown on serialization of DoAgentGet: {0}", e.Message); + responsedata["int_response_code"] = HttpStatusCode.InternalServerError; + // ignore. buffer will be empty, caller should check. + } + + responsedata["content_type"] = "application/json"; + responsedata["int_response_code"] = HttpStatusCode.OK; + responsedata["str_response_string"] = strBuffer; + } + else + { + responsedata["int_response_code"] = HttpStatusCode.InternalServerError; + responsedata["str_response_string"] = "Internal error"; + } + } + else + { + responsedata["int_response_code"] = HttpStatusCode.NotFound; + responsedata["str_response_string"] = "Not Found"; + } + } + + protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) + { + //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); + + if (action.Equals("release")) + m_SimulationService.ReleaseAgent(regionHandle, id, ""); + else + m_SimulationService.CloseAgent(regionHandle, id); + + responsedata["int_response_code"] = HttpStatusCode.OK; + responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); + + m_log.Debug("[AGENT HANDLER]: Agent Deleted."); + } + } + public class AgentGetHandler : BaseStreamHandler { // TODO: unused: private ISimulationService m_SimulationService; @@ -153,7 +395,7 @@ namespace OpenSim.Server.Handlers.Simulation // m_regionClient.AdjustUserInformation(aCircuit); // Finally! - bool success = m_SimulationService.CreateAgent(regionhandle, aCircuit, out reason); + bool success = m_SimulationService.CreateAgent(regionhandle, aCircuit, /*!!!*/0, out reason); OSDMap resp = new OSDMap(1); diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs new file mode 100644 index 0000000..8c3af72 --- /dev/null +++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs @@ -0,0 +1,191 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Net; +using System.Text; + +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using Nini.Config; +using log4net; + + +namespace OpenSim.Server.Handlers.Simulation +{ + public class ObjectHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private ISimulationService m_SimulationService; + + public ObjectHandler(ISimulationService sim) + { + m_SimulationService = sim; + } + + public Hashtable Handler(Hashtable request) + { + m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); + + m_log.Debug("---------------------------"); + m_log.Debug(" >> uri=" + request["uri"]); + m_log.Debug(" >> content-type=" + request["content-type"]); + m_log.Debug(" >> http-method=" + request["http-method"]); + m_log.Debug("---------------------------\n"); + + Hashtable responsedata = new Hashtable(); + responsedata["content_type"] = "text/html"; + + UUID objectID; + string action; + ulong regionHandle; + if (!Utils.GetParams((string)request["uri"], out objectID, out regionHandle, out action)) + { + m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); + responsedata["int_response_code"] = 404; + responsedata["str_response_string"] = "false"; + + return responsedata; + } + + // Next, let's parse the verb + string method = (string)request["http-method"]; + if (method.Equals("POST")) + { + DoObjectPost(request, responsedata, regionHandle); + return responsedata; + } + else if (method.Equals("PUT")) + { + DoObjectPut(request, responsedata, regionHandle); + return responsedata; + } + //else if (method.Equals("DELETE")) + //{ + // DoObjectDelete(request, responsedata, agentID, action, regionHandle); + // return responsedata; + //} + else + { + m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method); + responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; + responsedata["str_response_string"] = "Mthod not allowed"; + + return responsedata; + } + + } + + protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle) + { + OSDMap args = Utils.GetOSDMap((string)request["body"]); + if (args == null) + { + responsedata["int_response_code"] = 400; + responsedata["str_response_string"] = "false"; + return; + } + + string sogXmlStr = "", extraStr = "", stateXmlStr = ""; + if (args["sog"] != null) + sogXmlStr = args["sog"].AsString(); + if (args["extra"] != null) + extraStr = args["extra"].AsString(); + + IScene s = m_SimulationService.GetScene(regionhandle); + ISceneObject sog = null; + try + { + //sog = SceneObjectSerializer.FromXml2Format(sogXmlStr); + sog = s.DeserializeObject(sogXmlStr); + sog.ExtraFromXmlString(extraStr); + } + catch (Exception ex) + { + m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message); + responsedata["int_response_code"] = HttpStatusCode.BadRequest; + responsedata["str_response_string"] = "Bad request"; + return; + } + + if ((args["state"] != null) && s.AllowScriptCrossings) + { + stateXmlStr = args["state"].AsString(); + if (stateXmlStr != "") + { + try + { + sog.SetState(stateXmlStr, s); + } + catch (Exception ex) + { + m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message); + // ignore and continue + } + } + } + // This is the meaning of POST object + bool result = m_SimulationService.CreateObject(regionhandle, sog, false); + + responsedata["int_response_code"] = HttpStatusCode.OK; + responsedata["str_response_string"] = result.ToString(); + } + + protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle) + { + OSDMap args = Utils.GetOSDMap((string)request["body"]); + if (args == null) + { + responsedata["int_response_code"] = 400; + responsedata["str_response_string"] = "false"; + return; + } + + UUID userID = UUID.Zero, itemID = UUID.Zero; + if (args["userid"] != null) + userID = args["userid"].AsUUID(); + if (args["itemid"] != null) + itemID = args["itemid"].AsUUID(); + + // This is the meaning of PUT object + bool result = m_SimulationService.CreateObject(regionhandle, userID, itemID); + + responsedata["int_response_code"] = 200; + responsedata["str_response_string"] = result.ToString(); + } + + } +} \ No newline at end of file diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs index fe93fa5..b2aa52f 100644 --- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs @@ -47,13 +47,6 @@ namespace OpenSim.Server.Handlers.Simulation if (serverConfig == null) throw new Exception("No section 'SimulationService' in config file"); - bool authentication = serverConfig.GetBoolean("RequireAuthentication", false); - - if (authentication) - m_AuthenticationService = scene.RequestModuleInterface(); - - bool foreignGuests = serverConfig.GetBoolean("AllowForeignGuests", false); - //string simService = serverConfig.GetString("LocalServiceModule", // String.Empty); @@ -69,12 +62,14 @@ namespace OpenSim.Server.Handlers.Simulation //System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no")); - server.AddStreamHandler(new AgentGetHandler(m_SimulationService, m_AuthenticationService)); - server.AddStreamHandler(new AgentPostHandler(m_SimulationService, m_AuthenticationService, foreignGuests)); - server.AddStreamHandler(new AgentPutHandler(m_SimulationService, m_AuthenticationService)); - server.AddStreamHandler(new AgentDeleteHandler(m_SimulationService, m_AuthenticationService)); + //server.AddStreamHandler(new AgentGetHandler(m_SimulationService, m_AuthenticationService)); + //server.AddStreamHandler(new AgentPostHandler(m_SimulationService, m_AuthenticationService)); + //server.AddStreamHandler(new AgentPutHandler(m_SimulationService, m_AuthenticationService)); + //server.AddStreamHandler(new AgentDeleteHandler(m_SimulationService, m_AuthenticationService)); + server.AddHTTPHandler("/agent/", new AgentHandler(m_SimulationService).Handler); + server.AddHTTPHandler("/object/", new ObjectHandler(m_SimulationService).Handler); + //server.AddStreamHandler(new ObjectPostHandler(m_SimulationService, authentication)); - //server.AddStreamHandler(new NeighborPostHandler(m_SimulationService, authentication)); } } } diff --git a/OpenSim/Server/Handlers/Simulation/Utils.cs b/OpenSim/Server/Handlers/Simulation/Utils.cs new file mode 100644 index 0000000..1f2f851 --- /dev/null +++ b/OpenSim/Server/Handlers/Simulation/Utils.cs @@ -0,0 +1,103 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +using log4net; + +namespace OpenSim.Server.Handlers.Simulation +{ + public class Utils + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// Extract the param from an uri. + /// + /// Something like this: /agent/uuid/ or /agent/uuid/handle/release + /// uuid on uuid field + /// optional action + public static bool GetParams(string uri, out UUID uuid, out ulong regionHandle, out string action) + { + uuid = UUID.Zero; + action = ""; + regionHandle = 0; + + uri = uri.Trim(new char[] { '/' }); + string[] parts = uri.Split('/'); + if (parts.Length <= 1) + { + return false; + } + else + { + if (!UUID.TryParse(parts[1], out uuid)) + return false; + + if (parts.Length >= 3) + UInt64.TryParse(parts[2], out regionHandle); + if (parts.Length >= 4) + action = parts[3]; + + return true; + } + } + + public static OSDMap GetOSDMap(string data) + { + OSDMap args = null; + try + { + OSD buffer; + // We should pay attention to the content-type, but let's assume we know it's Json + buffer = OSDParser.DeserializeJson(data); + if (buffer.Type == OSDType.Map) + { + args = (OSDMap)buffer; + return args; + } + else + { + // uh? + m_log.Debug(("[REST COMMS]: Got OSD of unexpected type " + buffer.Type.ToString())); + return null; + } + } + catch (Exception ex) + { + m_log.Debug("[REST COMMS]: exception on parse of REST message " + ex.Message); + return null; + } + } + + } +} -- cgit v1.1 From 0ce9be653d2194877cb972cbce261eecb0cd58a8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 31 Dec 2009 14:59:26 -0800 Subject: * Added the Login server handlers that were lost in yesterday's commit grief * More beef to the LLLoginService * Better design for handling local simulation service --- OpenSim/Server/Handlers/Login/LLLoginHandlers.cs | 139 +++++++++++++++++++++ .../Handlers/Login/LLLoginServiceInConnector.cs | 93 ++++++++++++++ .../Simulation/SimulationServiceInConnector.cs | 12 +- 3 files changed, 236 insertions(+), 8 deletions(-) create mode 100644 OpenSim/Server/Handlers/Login/LLLoginHandlers.cs create mode 100644 OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs new file mode 100644 index 0000000..b973c11 --- /dev/null +++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs @@ -0,0 +1,139 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Net; +using System.Text; + +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using Nwc.XmlRpc; +using Nini.Config; +using log4net; + + +namespace OpenSim.Server.Handlers.Login +{ + public class LLLoginHandlers + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private ILoginService m_LocalService; + + public LLLoginHandlers(ILoginService service) + { + m_LocalService = service; + } + + public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + + if (requestData != null) + { + if (requestData.ContainsKey("first") && requestData["first"] != null && + requestData.ContainsKey("last") && requestData["last"] != null && + requestData.ContainsKey("passwd") && requestData["passwd"] != null) + { + string startLocation = string.Empty; + if (requestData.ContainsKey("start")) + startLocation = requestData["start"].ToString(); + + LoginResponse reply = null; + reply = m_LocalService.Login(requestData["first"].ToString(), requestData["last"].ToString(), requestData["passwd"].ToString(), startLocation); + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = reply.ToHashtable(); + return response; + + } + } + + return FailedXMLRPCResponse(); + + } + + public OSD HandleLLSDLogin(OSD request, IPEndPoint remoteClient) + { + if (request.Type == OSDType.Map) + { + OSDMap map = (OSDMap)request; + + if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) + { + string startLocation = string.Empty; + + if (map.ContainsKey("start")) + startLocation = map["start"].AsString(); + + m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation); + + LoginResponse reply = null; + reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation); + return reply.ToOSDMap(); + + } + } + + return FailedOSDResponse(); + } + + private XmlRpcResponse FailedXMLRPCResponse() + { + Hashtable hash = new Hashtable(); + hash["reason"] = "key"; + hash["message"] = "Incomplete login credentials. Check your username and password."; + hash["login"] = "false"; + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + + return response; + } + + private OSD FailedOSDResponse() + { + OSDMap map = new OSDMap(); + + map["reason"] = OSD.FromString("key"); + map["message"] = OSD.FromString("Invalid login credentials. Check your username and passwd."); + map["login"] = OSD.FromString("false"); + + return map; + } + } + +} diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs new file mode 100644 index 0000000..42ecd4d --- /dev/null +++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs @@ -0,0 +1,93 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using log4net; +using Nini.Config; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +namespace OpenSim.Server.Handlers.Login +{ + public class LLLoginServiceInConnector : ServiceConnector + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private ILoginService m_LoginService; + + public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : + base(config, server, String.Empty) + { + string loginService = ReadLocalServiceFromConfig(config); + + ISimulationService simService = scene.RequestModuleInterface(); + + Object[] args = new Object[] { config, simService }; + m_LoginService = ServerUtils.LoadPlugin(loginService, args); + + InitializeHandlers(server); + } + + public LLLoginServiceInConnector(IConfigSource config, IHttpServer server) : + base(config, server, String.Empty) + { + string loginService = ReadLocalServiceFromConfig(config); + + Object[] args = new Object[] { config }; + + m_LoginService = ServerUtils.LoadPlugin(loginService, args); + + InitializeHandlers(server); + } + + private string ReadLocalServiceFromConfig(IConfigSource config) + { + IConfig serverConfig = config.Configs["LoginService"]; + if (serverConfig == null) + throw new Exception(String.Format("No section LoginService in config file")); + + string loginService = serverConfig.GetString("LocalServiceModule", String.Empty); + if (loginService == string.Empty) + throw new Exception(String.Format("No LocalServiceModule for LoginService in config file")); + + return loginService; + } + + private void InitializeHandlers(IHttpServer server) + { + LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService); + server.AddXmlRPCHandler("Login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); + server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin); + } + + } +} diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs index b2aa52f..8611228 100644 --- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs @@ -37,7 +37,7 @@ namespace OpenSim.Server.Handlers.Simulation { public class SimulationServiceInConnector : ServiceConnector { - private ISimulationService m_SimulationService; + private ISimulationService m_LocalSimulationService; private IAuthenticationService m_AuthenticationService; public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : @@ -54,20 +54,16 @@ namespace OpenSim.Server.Handlers.Simulation // throw new Exception("No SimulationService in config file"); //Object[] args = new Object[] { config }; - m_SimulationService = scene.RequestModuleInterface(); + m_LocalSimulationService = scene.RequestModuleInterface(); //ServerUtils.LoadPlugin(simService, args); - if (m_SimulationService == null) - throw new Exception("No Local ISimulationService Module"); - - //System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no")); //server.AddStreamHandler(new AgentGetHandler(m_SimulationService, m_AuthenticationService)); //server.AddStreamHandler(new AgentPostHandler(m_SimulationService, m_AuthenticationService)); //server.AddStreamHandler(new AgentPutHandler(m_SimulationService, m_AuthenticationService)); //server.AddStreamHandler(new AgentDeleteHandler(m_SimulationService, m_AuthenticationService)); - server.AddHTTPHandler("/agent/", new AgentHandler(m_SimulationService).Handler); - server.AddHTTPHandler("/object/", new ObjectHandler(m_SimulationService).Handler); + server.AddHTTPHandler("/agent/", new AgentHandler(m_LocalSimulationService).Handler); + server.AddHTTPHandler("/object/", new ObjectHandler(m_LocalSimulationService).Handler); //server.AddStreamHandler(new ObjectPostHandler(m_SimulationService, authentication)); } -- cgit v1.1 From 130c80efe004fa06808cc639ad8e2ee31c35744b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 31 Dec 2009 17:18:55 -0800 Subject: A lot more beef on the login service. The LLLoginResponse is a MONSTER! Almost done... --- OpenSim/Server/Handlers/Login/LLLoginHandlers.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs index b973c11..aaa958b 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs @@ -68,12 +68,22 @@ namespace OpenSim.Server.Handlers.Login requestData.ContainsKey("last") && requestData["last"] != null && requestData.ContainsKey("passwd") && requestData["passwd"] != null) { + string first = requestData["first"].ToString(); + string last = requestData["last"].ToString(); + string passwd = requestData["passwd"].ToString(); string startLocation = string.Empty; if (requestData.ContainsKey("start")) startLocation = requestData["start"].ToString(); + string clientVersion = "Unknown"; + if (requestData.Contains("version")) + clientVersion = requestData["version"].ToString(); + // We should do something interesting with the client version... + + m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion); + LoginResponse reply = null; - reply = m_LocalService.Login(requestData["first"].ToString(), requestData["last"].ToString(), requestData["passwd"].ToString(), startLocation); + reply = m_LocalService.Login(first, last, passwd, startLocation, remoteClient); XmlRpcResponse response = new XmlRpcResponse(); response.Value = reply.ToHashtable(); @@ -102,7 +112,7 @@ namespace OpenSim.Server.Handlers.Login m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation); LoginResponse reply = null; - reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation); + reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation, remoteClient); return reply.ToOSDMap(); } -- cgit v1.1 From 1387919c204eb66ab6a37eb0fdf0f3c38f0a6813 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 31 Dec 2009 20:51:35 -0800 Subject: Yes! First test of new login service done still in 2009! Bombs in auth, because the data migration is missing. Will fix it next year... * HAPPY NEW YEAR! --- OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs index 42ecd4d..d5e073c 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs @@ -47,6 +47,7 @@ namespace OpenSim.Server.Handlers.Login public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : base(config, server, String.Empty) { + m_log.Debug("[LLLOGIN IN CONNECTOR]: Starting..."); string loginService = ReadLocalServiceFromConfig(config); ISimulationService simService = scene.RequestModuleInterface(); @@ -85,7 +86,7 @@ namespace OpenSim.Server.Handlers.Login private void InitializeHandlers(IHttpServer server) { LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService); - server.AddXmlRPCHandler("Login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); + server.AddXmlRPCHandler("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin); } -- cgit v1.1 From 8a9677a5319793ff630d0761e204ae8961f375aa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 1 Jan 2010 21:12:46 -0800 Subject: The Library Service is now working. UserProfileCacheService.LibraryRoot is obsolete. Didn't delete it yet to avoid merge conflicts later -- want to stay out of core as much as possible. --- OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs index d5e073c..e24055b 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs @@ -51,8 +51,9 @@ namespace OpenSim.Server.Handlers.Login string loginService = ReadLocalServiceFromConfig(config); ISimulationService simService = scene.RequestModuleInterface(); + ILibraryService libService = scene.RequestModuleInterface(); - Object[] args = new Object[] { config, simService }; + Object[] args = new Object[] { config, simService, libService }; m_LoginService = ServerUtils.LoadPlugin(loginService, args); InitializeHandlers(server); -- cgit v1.1 From 28702f585f632da43bcee2ca0d4c7a59fe036543 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 2 Jan 2010 15:07:38 -0800 Subject: * Avatar service connectors all in place, but untested. * Fixed a typo in RemoteUserAccountServiceConnector module. --- .../Handlers/Avatar/AvatarServerConnector.cs | 61 +++++ .../Handlers/Avatar/AvatarServerPostHandler.cs | 272 +++++++++++++++++++++ 2 files changed, 333 insertions(+) create mode 100644 OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs create mode 100644 OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs new file mode 100644 index 0000000..9a57cd9 --- /dev/null +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs @@ -0,0 +1,61 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using Nini.Config; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +namespace OpenSim.Server.Handlers.Avatar +{ + public class AvatarServiceConnector : ServiceConnector + { + private IAvatarService m_AvatarService; + private string m_ConfigName = "AvatarService"; + + public AvatarServiceConnector(IConfigSource config, IHttpServer server, string configName) : + base(config, server, configName) + { + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); + + string avatarService = serverConfig.GetString("LocalServiceModule", + String.Empty); + + if (avatarService == String.Empty) + throw new Exception("No LocalServiceModule in config file"); + + Object[] args = new Object[] { config }; + m_AvatarService = ServerUtils.LoadPlugin(avatarService, args); + + server.AddStreamHandler(new AvatarServerPostHandler(m_AvatarService)); + } + } +} diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs new file mode 100644 index 0000000..c781cce --- /dev/null +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs @@ -0,0 +1,272 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using Nini.Config; +using log4net; +using System; +using System.Reflection; +using System.IO; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Serialization; +using System.Collections.Generic; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.Avatar +{ + public class AvatarServerPostHandler : BaseStreamHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IAvatarService m_AvatarService; + + public AvatarServerPostHandler(IAvatarService service) : + base("POST", "/avatar") + { + m_AvatarService = service; + } + + public override byte[] Handle(string path, Stream requestData, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + StreamReader sr = new StreamReader(requestData); + string body = sr.ReadToEnd(); + sr.Close(); + body = body.Trim(); + + //m_log.DebugFormat("[XXX]: query String: {0}", body); + + try + { + Dictionary request = + ServerUtils.ParseQueryString(body); + + if (!request.ContainsKey("METHOD")) + return FailureResult(); + + string method = request["METHOD"].ToString(); + + switch (method) + { + case "getavatar": + return GetAvatar(request); + case "setavatar": + return SetAvatar(request); + case "resetavatar": + return ResetAvatar(request); + case "setitems": + return SetItems(request); + case "removeitems": + return RemoveItems(request); + } + m_log.DebugFormat("[AVATAR HANDLER]: unknown method request: {0}", method); + } + catch (Exception e) + { + m_log.Debug("[AVATAR HANDLER]: Exception {0}" + e); + } + + return FailureResult(); + + } + + byte[] GetAvatar(Dictionary request) + { + UUID user = UUID.Zero; + + if (!request.ContainsKey("UserID")) + return FailureResult(); + + if (UUID.TryParse(request["UserID"].ToString(), out user)) + { + AvatarData avatar = m_AvatarService.GetAvatar(user); + if (avatar == null) + return FailureResult(); + + Dictionary result = new Dictionary(); + if (avatar == null) + result["result"] = "null"; + else + result["result"] = avatar.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + + return FailureResult(); + } + + byte[] SetAvatar(Dictionary request) + { + UUID user = UUID.Zero; + + if (!request.ContainsKey("UserID")) + return FailureResult(); + + if (!UUID.TryParse(request["UserID"].ToString(), out user)) + return FailureResult(); + + if (request.ContainsKey("Avatar") && request["Avatar"] is Dictionary) + { + AvatarData avatar = new AvatarData((Dictionary)request["Avatar"]); + if (m_AvatarService.SetAvatar(user, avatar)) + return SuccessResult(); + } + + return FailureResult(); + } + + byte[] ResetAvatar(Dictionary request) + { + UUID user = UUID.Zero; + if (!request.ContainsKey("UserID")) + return FailureResult(); + + if (!UUID.TryParse(request["UserID"].ToString(), out user)) + return FailureResult(); + + if (m_AvatarService.ResetAvatar(user)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] SetItems(Dictionary request) + { + UUID user = UUID.Zero; + string[] names, values; + + if (!request.ContainsKey("UserID") || !request.ContainsKey("Names") || !request.ContainsKey("Values")) + return FailureResult(); + + if (!UUID.TryParse(request["UserID"].ToString(), out user)) + return FailureResult(); + + if (!(request["Names"] is List || request["Values"] is List)) + return FailureResult(); + + List _names = (List)request["Names"]; + names = _names.ToArray(); + List _values = (List)request["Values"]; + values = _values.ToArray(); + + if (m_AvatarService.SetItems(user, names, values)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] RemoveItems(Dictionary request) + { + UUID user = UUID.Zero; + string[] names; + + if (!request.ContainsKey("UserID") || !request.ContainsKey("Names")) + return FailureResult(); + + if (!UUID.TryParse(request["UserID"].ToString(), out user)) + return FailureResult(); + + if (!(request["Names"] is List)) + return FailureResult(); + + List _names = (List)request["Names"]; + names = _names.ToArray(); + + if (m_AvatarService.RemoveItems(user, names)) + return SuccessResult(); + + return FailureResult(); + } + + + + private byte[] SuccessResult() + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + XmlElement result = doc.CreateElement("", "result", ""); + result.AppendChild(doc.CreateTextNode("Success")); + + rootElement.AppendChild(result); + + return DocToBytes(doc); + } + + private byte[] FailureResult() + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + XmlElement result = doc.CreateElement("", "result", ""); + result.AppendChild(doc.CreateTextNode("Failure")); + + rootElement.AppendChild(result); + + return DocToBytes(doc); + } + + private byte[] DocToBytes(XmlDocument doc) + { + MemoryStream ms = new MemoryStream(); + XmlTextWriter xw = new XmlTextWriter(ms, null); + xw.Formatting = Formatting.Indented; + doc.WriteTo(xw); + xw.Flush(); + + return ms.ToArray(); + } + + } +} -- cgit v1.1 From 08b507517b8dc33f66de1e0815af330bb3c54696 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 2 Jan 2010 18:18:13 -0800 Subject: Test client for remote presence connector, and for the service itself. Connector seems to work well. --- OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 11adc4a..6e47b22 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -312,7 +312,7 @@ namespace OpenSim.Server.Handlers.Presence Vector3 position = new Vector3(128, 128, 70); Vector3 look = Vector3.Zero; - if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID")) + if (!request.ContainsKey("UserID") || !request.ContainsKey("RegionID")) return FailureResult(); string user = request["UserID"].ToString(); -- cgit v1.1 From 8bed461957c38fb90a65a148d3f3791e9e0222f8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 2 Jan 2010 20:16:21 -0800 Subject: Test client for remote user account connector and service. It seems to be working. --- .../UserAccounts/UserAccountServerPostHandler.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index 544ffea..b54b63e 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs @@ -174,14 +174,14 @@ namespace OpenSim.Server.Handlers.UserAccounts byte[] StoreAccount(Dictionary request) { - if (!request.ContainsKey("account")) - return FailureResult(); - if (request["account"] == null) - return FailureResult(); - if (!(request["account"] is Dictionary)) - return FailureResult(); - - UserAccount account = new UserAccount((Dictionary)request["account"]); + //if (!request.ContainsKey("account")) + // return FailureResult(); + //if (request["account"] == null) + // return FailureResult(); + //if (!(request["account"] is Dictionary)) + // return FailureResult(); + + UserAccount account = new UserAccount(request); if (m_UserAccountService.StoreUserAccount(account)) return SuccessResult(); -- cgit v1.1 From ae1bdaa7b5f4bf485a52c2fcd81be2e1cd8d0400 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 3 Jan 2010 07:03:14 -0800 Subject: Applied fix for avatar connectors similar to yesterday's fix of user account connectors. --- OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs index c781cce..49c2e43 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs @@ -138,12 +138,9 @@ namespace OpenSim.Server.Handlers.Avatar if (!UUID.TryParse(request["UserID"].ToString(), out user)) return FailureResult(); - if (request.ContainsKey("Avatar") && request["Avatar"] is Dictionary) - { - AvatarData avatar = new AvatarData((Dictionary)request["Avatar"]); - if (m_AvatarService.SetAvatar(user, avatar)) - return SuccessResult(); - } + AvatarData avatar = new AvatarData(request); + if (m_AvatarService.SetAvatar(user, avatar)) + return SuccessResult(); return FailureResult(); } -- cgit v1.1 From c268e342d19b6cc5969b1c1d94f20a3f4eb844ef Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 3 Jan 2010 09:35:12 -0800 Subject: * Changed ISimulation interface to take a GridRegion as input arg instead of a regionHandle. * Added the RemoteSimulationConnectorModule, which is the replacement for RESTComms. Scenes is not using this yet, only (standalone) Login uses these region modules for now. * Completed SimulationServiceConnector and corresponding handlers. --- .../Server/Handlers/Simulation/AgentHandlers.cs | 244 +++++---------------- .../Server/Handlers/Simulation/ObjectHandlers.cs | 64 ++++-- .../Simulation/SimulationServiceInConnector.cs | 6 +- OpenSim/Server/Handlers/Simulation/Utils.cs | 6 +- 4 files changed, 115 insertions(+), 205 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 4966f66..f4f3eea 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -35,6 +35,7 @@ using System.Text; using OpenSim.Server.Base; using OpenSim.Server.Handlers.Base; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; @@ -72,9 +73,9 @@ namespace OpenSim.Server.Handlers.Simulation UUID agentID; + UUID regionID; string action; - ulong regionHandle; - if (!Utils.GetParams((string)request["uri"], out agentID, out regionHandle, out action)) + if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action)) { m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]); responsedata["int_response_code"] = 404; @@ -97,12 +98,12 @@ namespace OpenSim.Server.Handlers.Simulation } else if (method.Equals("GET")) { - DoAgentGet(request, responsedata, agentID, regionHandle); + DoAgentGet(request, responsedata, agentID, regionID); return responsedata; } else if (method.Equals("DELETE")) { - DoAgentDelete(request, responsedata, agentID, action, regionHandle); + DoAgentDelete(request, responsedata, agentID, action, regionID); return responsedata; } else @@ -126,10 +127,27 @@ namespace OpenSim.Server.Handlers.Simulation return; } - // retrieve the regionhandle - ulong regionhandle = 0; - if (args["destination_handle"] != null) - UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); + // retrieve the input arguments + int x = 0, y = 0; + UUID uuid = UUID.Zero; + string regionname = string.Empty; + uint teleportFlags = 0; + if (args.ContainsKey("destination_x") && args["destination_x"] != null) + Int32.TryParse(args["destination_x"].AsString(), out x); + if (args.ContainsKey("destination_y") && args["destination_y"] != null) + Int32.TryParse(args["destination_y"].AsString(), out y); + if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) + UUID.TryParse(args["destination_uuid"].AsString(), out uuid); + if (args.ContainsKey("destination_name") && args["destination_name"] != null) + regionname = args["destination_name"].ToString(); + if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null) + teleportFlags = args["teleport_flags"].AsUInteger(); + + GridRegion destination = new GridRegion(); + destination.RegionID = uuid; + destination.RegionLocX = x; + destination.RegionLocY = y; + destination.RegionName = regionname; AgentCircuitData aCircuit = new AgentCircuitData(); try @@ -146,15 +164,10 @@ namespace OpenSim.Server.Handlers.Simulation OSDMap resp = new OSDMap(2); string reason = String.Empty; - uint teleportFlags = 0; - if (args.ContainsKey("teleport_flags")) - { - teleportFlags = args["teleport_flags"].AsUInteger(); - } // This is the meaning of POST agent //m_regionClient.AdjustUserInformation(aCircuit); - bool result = m_SimulationService.CreateAgent(regionhandle, aCircuit, teleportFlags, out reason); + bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); @@ -174,10 +187,24 @@ namespace OpenSim.Server.Handlers.Simulation return; } - // retrieve the regionhandle - ulong regionhandle = 0; - if (args["destination_handle"] != null) - UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); + // retrieve the input arguments + int x = 0, y = 0; + UUID uuid = UUID.Zero; + string regionname = string.Empty; + if (args.ContainsKey("destination_x") && args["destination_x"] != null) + Int32.TryParse(args["destination_x"].AsString(), out x); + if (args.ContainsKey("destination_y") && args["destination_y"] != null) + Int32.TryParse(args["destination_y"].AsString(), out y); + if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) + UUID.TryParse(args["destination_uuid"].AsString(), out uuid); + if (args.ContainsKey("destination_name") && args["destination_name"] != null) + regionname = args["destination_name"].ToString(); + + GridRegion destination = new GridRegion(); + destination.RegionID = uuid; + destination.RegionLocX = x; + destination.RegionLocY = y; + destination.RegionName = regionname; string messageType; if (args["message_type"] != null) @@ -206,7 +233,7 @@ namespace OpenSim.Server.Handlers.Simulation //agent.Dump(); // This is one of the meanings of PUT agent - result = m_SimulationService.UpdateAgent(regionhandle, agent); + result = m_SimulationService.UpdateAgent(destination, agent); } else if ("AgentPosition".Equals(messageType)) @@ -223,7 +250,7 @@ namespace OpenSim.Server.Handlers.Simulation } //agent.Dump(); // This is one of the meanings of PUT agent - result = m_SimulationService.UpdateAgent(regionhandle, agent); + result = m_SimulationService.UpdateAgent(destination, agent); } @@ -232,10 +259,13 @@ namespace OpenSim.Server.Handlers.Simulation //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead } - protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle) + protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) { + GridRegion destination = new GridRegion(); + destination.RegionID = regionID; + IAgentData agent = null; - bool result = m_SimulationService.RetrieveAgent(regionHandle, id, out agent); + bool result = m_SimulationService.RetrieveAgent(destination, id, out agent); OSDMap map = null; if (result) { @@ -271,14 +301,17 @@ namespace OpenSim.Server.Handlers.Simulation } } - protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) + protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID) { //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); + GridRegion destination = new GridRegion(); + destination.RegionID = regionID; + if (action.Equals("release")) - m_SimulationService.ReleaseAgent(regionHandle, id, ""); + m_SimulationService.ReleaseAgent(destination, id, ""); else - m_SimulationService.CloseAgent(regionHandle, id); + m_SimulationService.CloseAgent(destination, id); responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); @@ -287,165 +320,4 @@ namespace OpenSim.Server.Handlers.Simulation } } - public class AgentGetHandler : BaseStreamHandler - { - // TODO: unused: private ISimulationService m_SimulationService; - // TODO: unused: private IAuthenticationService m_AuthenticationService; - - public AgentGetHandler(ISimulationService service, IAuthenticationService authentication) : - base("GET", "/agent") - { - // TODO: unused: m_SimulationService = service; - // TODO: unused: m_AuthenticationService = authentication; - } - - public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - // Not implemented yet - httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; - return new byte[] { }; - } - } - - public class AgentPostHandler : BaseStreamHandler - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private ISimulationService m_SimulationService; - private IAuthenticationService m_AuthenticationService; - // TODO: unused: private bool m_AllowForeignGuests; - - public AgentPostHandler(ISimulationService service, IAuthenticationService authentication, bool foreignGuests) : - base("POST", "/agent") - { - m_SimulationService = service; - m_AuthenticationService = authentication; - // TODO: unused: m_AllowForeignGuests = foreignGuests; - } - - public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - byte[] result = new byte[0]; - - UUID agentID; - string action; - ulong regionHandle; - if (!RestHandlerUtils.GetParams(path, out agentID, out regionHandle, out action)) - { - m_log.InfoFormat("[AgentPostHandler]: Invalid parameters for agent message {0}", path); - httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; - httpResponse.StatusDescription = "Invalid parameters for agent message " + path; - - return result; - } - - if (m_AuthenticationService != null) - { - // Authentication - string authority = string.Empty; - string authToken = string.Empty; - if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken)) - { - m_log.InfoFormat("[AgentPostHandler]: Authentication failed for agent message {0}", path); - httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; - return result; - } - // TODO: Rethink this - //if (!m_AuthenticationService.VerifyKey(agentID, authToken)) - //{ - // m_log.InfoFormat("[AgentPostHandler]: Authentication failed for agent message {0}", path); - // httpResponse.StatusCode = (int)HttpStatusCode.Forbidden; - // return result; - //} - m_log.DebugFormat("[AgentPostHandler]: Authentication succeeded for {0}", agentID); - } - - OSDMap args = Util.GetOSDMap(request, (int)httpRequest.ContentLength); - if (args == null) - { - httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; - httpResponse.StatusDescription = "Unable to retrieve data"; - m_log.DebugFormat("[AgentPostHandler]: Unable to retrieve data for post {0}", path); - return result; - } - - // retrieve the regionhandle - ulong regionhandle = 0; - if (args["destination_handle"] != null) - UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); - - AgentCircuitData aCircuit = new AgentCircuitData(); - try - { - aCircuit.UnpackAgentCircuitData(args); - } - catch (Exception ex) - { - m_log.InfoFormat("[AgentPostHandler]: exception on unpacking CreateAgent message {0}", ex.Message); - httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; - httpResponse.StatusDescription = "Problems with data deserialization"; - return result; - } - - string reason = string.Empty; - - // We need to clean up a few things in the user service before I can do this - //if (m_AllowForeignGuests) - // m_regionClient.AdjustUserInformation(aCircuit); - - // Finally! - bool success = m_SimulationService.CreateAgent(regionhandle, aCircuit, /*!!!*/0, out reason); - - OSDMap resp = new OSDMap(1); - - resp["success"] = OSD.FromBoolean(success); - - httpResponse.StatusCode = (int)HttpStatusCode.OK; - - return Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp)); - } - } - - public class AgentPutHandler : BaseStreamHandler - { - // TODO: unused: private ISimulationService m_SimulationService; - // TODO: unused: private IAuthenticationService m_AuthenticationService; - - public AgentPutHandler(ISimulationService service, IAuthenticationService authentication) : - base("PUT", "/agent") - { - // TODO: unused: m_SimulationService = service; - // TODO: unused: m_AuthenticationService = authentication; - } - - public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - // Not implemented yet - httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; - return new byte[] { }; - } - } - - public class AgentDeleteHandler : BaseStreamHandler - { - // TODO: unused: private ISimulationService m_SimulationService; - // TODO: unused: private IAuthenticationService m_AuthenticationService; - - public AgentDeleteHandler(ISimulationService service, IAuthenticationService authentication) : - base("DELETE", "/agent") - { - // TODO: unused: m_SimulationService = service; - // TODO: unused: m_AuthenticationService = authentication; - } - - public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - // Not implemented yet - httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; - return new byte[] { }; - } - } } diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs index 8c3af72..995a3c4 100644 --- a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs @@ -35,6 +35,7 @@ using System.Text; using OpenSim.Server.Base; using OpenSim.Server.Handlers.Base; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; @@ -70,9 +71,9 @@ namespace OpenSim.Server.Handlers.Simulation responsedata["content_type"] = "text/html"; UUID objectID; + UUID regionID; string action; - ulong regionHandle; - if (!Utils.GetParams((string)request["uri"], out objectID, out regionHandle, out action)) + if (!Utils.GetParams((string)request["uri"], out objectID, out regionID, out action)) { m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); responsedata["int_response_code"] = 404; @@ -85,12 +86,12 @@ namespace OpenSim.Server.Handlers.Simulation string method = (string)request["http-method"]; if (method.Equals("POST")) { - DoObjectPost(request, responsedata, regionHandle); + DoObjectPost(request, responsedata, regionID); return responsedata; } else if (method.Equals("PUT")) { - DoObjectPut(request, responsedata, regionHandle); + DoObjectPut(request, responsedata, regionID); return responsedata; } //else if (method.Equals("DELETE")) @@ -109,7 +110,7 @@ namespace OpenSim.Server.Handlers.Simulation } - protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle) + protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) @@ -118,14 +119,32 @@ namespace OpenSim.Server.Handlers.Simulation responsedata["str_response_string"] = "false"; return; } + // retrieve the input arguments + int x = 0, y = 0; + UUID uuid = UUID.Zero; + string regionname = string.Empty; + if (args.ContainsKey("destination_x") && args["destination_x"] != null) + Int32.TryParse(args["destination_x"].AsString(), out x); + if (args.ContainsKey("destination_y") && args["destination_y"] != null) + Int32.TryParse(args["destination_y"].AsString(), out y); + if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) + UUID.TryParse(args["destination_uuid"].AsString(), out uuid); + if (args.ContainsKey("destination_name") && args["destination_name"] != null) + regionname = args["destination_name"].ToString(); + + GridRegion destination = new GridRegion(); + destination.RegionID = uuid; + destination.RegionLocX = x; + destination.RegionLocY = y; + destination.RegionName = regionname; string sogXmlStr = "", extraStr = "", stateXmlStr = ""; - if (args["sog"] != null) + if (args.ContainsKey("sog") && args["sog"] != null) sogXmlStr = args["sog"].AsString(); - if (args["extra"] != null) + if (args.ContainsKey("extra") && args["extra"] != null) extraStr = args["extra"].AsString(); - IScene s = m_SimulationService.GetScene(regionhandle); + IScene s = m_SimulationService.GetScene(destination.RegionHandle); ISceneObject sog = null; try { @@ -158,13 +177,13 @@ namespace OpenSim.Server.Handlers.Simulation } } // This is the meaning of POST object - bool result = m_SimulationService.CreateObject(regionhandle, sog, false); + bool result = m_SimulationService.CreateObject(destination, sog, false); responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = result.ToString(); } - protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle) + protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, UUID regionID) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) @@ -174,14 +193,33 @@ namespace OpenSim.Server.Handlers.Simulation return; } + // retrieve the input arguments + int x = 0, y = 0; + UUID uuid = UUID.Zero; + string regionname = string.Empty; + if (args.ContainsKey("destination_x") && args["destination_x"] != null) + Int32.TryParse(args["destination_x"].AsString(), out x); + if (args.ContainsKey("destination_y") && args["destination_y"] != null) + Int32.TryParse(args["destination_y"].AsString(), out y); + if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) + UUID.TryParse(args["destination_uuid"].AsString(), out uuid); + if (args.ContainsKey("destination_name") && args["destination_name"] != null) + regionname = args["destination_name"].ToString(); + + GridRegion destination = new GridRegion(); + destination.RegionID = uuid; + destination.RegionLocX = x; + destination.RegionLocY = y; + destination.RegionName = regionname; + UUID userID = UUID.Zero, itemID = UUID.Zero; - if (args["userid"] != null) + if (args.ContainsKey("userid") && args["userid"] != null) userID = args["userid"].AsUUID(); - if (args["itemid"] != null) + if (args.ContainsKey("itemid") && args["itemid"] != null) itemID = args["itemid"].AsUUID(); // This is the meaning of PUT object - bool result = m_SimulationService.CreateObject(regionhandle, userID, itemID); + bool result = m_SimulationService.CreateObject(destination, userID, itemID); responsedata["int_response_code"] = 200; responsedata["str_response_string"] = result.ToString(); diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs index 8611228..55a575c 100644 --- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs @@ -43,9 +43,9 @@ namespace OpenSim.Server.Handlers.Simulation public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : base(config, server, String.Empty) { - IConfig serverConfig = config.Configs["SimulationService"]; - if (serverConfig == null) - throw new Exception("No section 'SimulationService' in config file"); + //IConfig serverConfig = config.Configs["SimulationService"]; + //if (serverConfig == null) + // throw new Exception("No section 'SimulationService' in config file"); //string simService = serverConfig.GetString("LocalServiceModule", // String.Empty); diff --git a/OpenSim/Server/Handlers/Simulation/Utils.cs b/OpenSim/Server/Handlers/Simulation/Utils.cs index 1f2f851..ed379da 100644 --- a/OpenSim/Server/Handlers/Simulation/Utils.cs +++ b/OpenSim/Server/Handlers/Simulation/Utils.cs @@ -46,11 +46,11 @@ namespace OpenSim.Server.Handlers.Simulation /// Something like this: /agent/uuid/ or /agent/uuid/handle/release /// uuid on uuid field /// optional action - public static bool GetParams(string uri, out UUID uuid, out ulong regionHandle, out string action) + public static bool GetParams(string uri, out UUID uuid, out UUID regionID, out string action) { uuid = UUID.Zero; + regionID = UUID.Zero; action = ""; - regionHandle = 0; uri = uri.Trim(new char[] { '/' }); string[] parts = uri.Split('/'); @@ -64,7 +64,7 @@ namespace OpenSim.Server.Handlers.Simulation return false; if (parts.Length >= 3) - UInt64.TryParse(parts[2], out regionHandle); + UUID.TryParse(parts[2], out regionID); if (parts.Length >= 4) action = parts[3]; -- cgit v1.1 From 99efa99585639c94fdb484681663ac7b6f03538e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 3 Jan 2010 11:44:57 -0800 Subject: Successfully logged into a grid. --- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index f4f3eea..ccb4c70 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -134,8 +134,12 @@ namespace OpenSim.Server.Handlers.Simulation uint teleportFlags = 0; if (args.ContainsKey("destination_x") && args["destination_x"] != null) Int32.TryParse(args["destination_x"].AsString(), out x); + else + m_log.WarnFormat(" -- request didn't have destination_x"); if (args.ContainsKey("destination_y") && args["destination_y"] != null) Int32.TryParse(args["destination_y"].AsString(), out y); + else + m_log.WarnFormat(" -- request didn't have destination_y"); if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) UUID.TryParse(args["destination_uuid"].AsString(), out uuid); if (args.ContainsKey("destination_name") && args["destination_name"] != null) -- cgit v1.1 From f11a97f12d328af8bb39b92fec5cb5780983b66a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 7 Jan 2010 15:53:55 -0800 Subject: * Finished SimulationServiceConnector * Started rerouting calls to UserService. * Compiles. May run. --- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index ccb4c70..782034b 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -313,7 +313,7 @@ namespace OpenSim.Server.Handlers.Simulation destination.RegionID = regionID; if (action.Equals("release")) - m_SimulationService.ReleaseAgent(destination, id, ""); + m_SimulationService.ReleaseAgent(regionID, id, ""); else m_SimulationService.CloseAgent(destination, id); -- cgit v1.1 From 4dd523b45d1e635c66eb4e556764fabe29dbfc58 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 15:34:56 -0800 Subject: * Changed IPresenceService Logout, so that it takes a position and a lookat * CommsManager.AvatarService rerouted --- OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 6e47b22..926c195 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -131,6 +131,8 @@ namespace OpenSim.Server.Handlers.Presence byte[] LogoutAgent(Dictionary request) { UUID session = UUID.Zero; + Vector3 position = Vector3.Zero; + Vector3 lookat = Vector3.Zero; if (!request.ContainsKey("SessionID")) return FailureResult(); @@ -138,7 +140,12 @@ namespace OpenSim.Server.Handlers.Presence if (!UUID.TryParse(request["SessionID"].ToString(), out session)) return FailureResult(); - if (m_PresenceService.LogoutAgent(session)) + if (request.ContainsKey("Position") && request["Position"] != null) + Vector3.TryParse(request["Position"].ToString(), out position); + if (request.ContainsKey("LookAt") && request["Position"] != null) + Vector3.TryParse(request["LookAt"].ToString(), out lookat); + + if (m_PresenceService.LogoutAgent(session, position, lookat)) return SuccessResult(); return FailureResult(); -- cgit v1.1 From b0bbe861cd0f3eb06de73a371ab961428c549c69 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 17:15:02 -0800 Subject: Moved OpenId authentication from user server to Server.Handlers.Authentication. --- .../Authentication/OpenIdServerConnector.cs | 77 +++++ .../Handlers/Authentication/OpenIdServerHandler.cs | 345 +++++++++++++++++++++ 2 files changed, 422 insertions(+) create mode 100644 OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs create mode 100644 OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs new file mode 100644 index 0000000..a0a92ed --- /dev/null +++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs @@ -0,0 +1,77 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +namespace OpenSim.Server.Handlers.Authentication +{ + public class OpenIdServerConnector : ServiceConnector + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IAuthenticationService m_AuthenticationService; + private IUserAccountService m_UserAccountService; + private string m_ConfigName = "OpenIdService"; + + public OpenIdServerConnector(IConfigSource config, IHttpServer server, string configName) : + base(config, server, configName) + { + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); + + string authService = serverConfig.GetString("AuthenticationServiceModule", + String.Empty); + string userService = serverConfig.GetString("UserAccountServiceModule", + String.Empty); + + if (authService == String.Empty || userService == String.Empty) + throw new Exception("No AuthenticationServiceModule or no UserAccountServiceModule in config file for OpenId authentication"); + + Object[] args = new Object[] { config }; + m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); + m_UserAccountService = ServerUtils.LoadPlugin(authService, args); + + // Handler for OpenID user identity pages + server.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", m_UserAccountService, m_AuthenticationService)); + // Handlers for the OpenID endpoint server + server.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", m_UserAccountService, m_AuthenticationService)); + server.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", m_UserAccountService, m_AuthenticationService)); + + m_log.Info("[OPENID]: OpenId service enabled"); + } + } +} diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs new file mode 100644 index 0000000..e73961b --- /dev/null +++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs @@ -0,0 +1,345 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.IO; +using System.Net; +using System.Web; +using DotNetOpenId; +using DotNetOpenId.Provider; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; +using OpenSim.Services.Interfaces; +using Nini.Config; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.Authentication +{ + /// + /// Temporary, in-memory store for OpenID associations + /// + public class ProviderMemoryStore : IAssociationStore + { + private class AssociationItem + { + public AssociationRelyingPartyType DistinguishingFactor; + public string Handle; + public DateTime Expires; + public byte[] PrivateData; + } + + Dictionary m_store = new Dictionary(); + SortedList m_sortedStore = new SortedList(); + object m_syncRoot = new object(); + + #region IAssociationStore Members + + public void StoreAssociation(AssociationRelyingPartyType distinguishingFactor, Association assoc) + { + AssociationItem item = new AssociationItem(); + item.DistinguishingFactor = distinguishingFactor; + item.Handle = assoc.Handle; + item.Expires = assoc.Expires.ToLocalTime(); + item.PrivateData = assoc.SerializePrivateData(); + + lock (m_syncRoot) + { + m_store[item.Handle] = item; + m_sortedStore[item.Expires] = item; + } + } + + public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor) + { + lock (m_syncRoot) + { + if (m_sortedStore.Count > 0) + { + AssociationItem item = m_sortedStore.Values[m_sortedStore.Count - 1]; + return Association.Deserialize(item.Handle, item.Expires.ToUniversalTime(), item.PrivateData); + } + else + { + return null; + } + } + } + + public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor, string handle) + { + AssociationItem item; + bool success = false; + lock (m_syncRoot) + success = m_store.TryGetValue(handle, out item); + + if (success) + return Association.Deserialize(item.Handle, item.Expires.ToUniversalTime(), item.PrivateData); + else + return null; + } + + public bool RemoveAssociation(AssociationRelyingPartyType distinguishingFactor, string handle) + { + lock (m_syncRoot) + { + for (int i = 0; i < m_sortedStore.Values.Count; i++) + { + AssociationItem item = m_sortedStore.Values[i]; + if (item.Handle == handle) + { + m_sortedStore.RemoveAt(i); + break; + } + } + + return m_store.Remove(handle); + } + } + + public void ClearExpiredAssociations() + { + lock (m_syncRoot) + { + List itemsCopy = new List(m_sortedStore.Values); + DateTime now = DateTime.Now; + + for (int i = 0; i < itemsCopy.Count; i++) + { + AssociationItem item = itemsCopy[i]; + + if (item.Expires <= now) + { + m_sortedStore.RemoveAt(i); + m_store.Remove(item.Handle); + } + } + } + } + + #endregion + } + + public class OpenIdStreamHandler : IStreamHandler + { + #region HTML + + /// Login form used to authenticate OpenID requests + const string LOGIN_PAGE = +@" +OpenSim OpenID Login + +

OpenSim Login

+
+ + + + +
+ +"; + + /// Page shown for a valid OpenID identity + const string OPENID_PAGE = +@" + +{2} {3} + + +OpenID identifier for {2} {3} + +"; + + /// Page shown for an invalid OpenID identity + const string INVALID_OPENID_PAGE = +@"Identity not found +Invalid OpenID identity"; + + /// Page shown if the OpenID endpoint is requested directly + const string ENDPOINT_PAGE = +@"OpenID Endpoint +This is an OpenID server endpoint, not a human-readable resource. +For more information, see http://openid.net/. +"; + + #endregion HTML + + public string ContentType { get { return m_contentType; } } + public string HttpMethod { get { return m_httpMethod; } } + public string Path { get { return m_path; } } + + string m_contentType; + string m_httpMethod; + string m_path; + IAuthenticationService m_authenticationService; + IUserAccountService m_userAccountService; + ProviderMemoryStore m_openidStore = new ProviderMemoryStore(); + + /// + /// Constructor + /// + public OpenIdStreamHandler(string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService) + { + m_authenticationService = authService; + m_userAccountService = userService; + m_httpMethod = httpMethod; + m_path = path; + + m_contentType = "text/html"; + } + + /// + /// Handles all GET and POST requests for OpenID identifier pages and endpoint + /// server communication + /// + public void Handle(string path, Stream request, Stream response, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath)); + + // Defult to returning HTML content + m_contentType = "text/html"; + + try + { + NameValueCollection postQuery = HttpUtility.ParseQueryString(new StreamReader(httpRequest.InputStream).ReadToEnd()); + NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query); + NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery); + + OpenIdProvider provider = new OpenIdProvider(m_openidStore, providerEndpoint, httpRequest.Url, openIdQuery); + + if (provider.Request != null) + { + if (!provider.Request.IsResponseReady && provider.Request is IAuthenticationRequest) + { + IAuthenticationRequest authRequest = (IAuthenticationRequest)provider.Request; + string[] passwordValues = postQuery.GetValues("pass"); + + UserAccount account; + if (TryGetAccount(new Uri(authRequest.ClaimedIdentifier.ToString()), out account)) + { + // Check for form POST data + if (passwordValues != null && passwordValues.Length == 1) + { + if (account != null && + (m_authenticationService.Authenticate(account.PrincipalID, passwordValues[0], 30) != string.Empty)) + authRequest.IsAuthenticated = true; + else + authRequest.IsAuthenticated = false; + } + else + { + // Authentication was requested, send the client a login form + using (StreamWriter writer = new StreamWriter(response)) + writer.Write(String.Format(LOGIN_PAGE, account.FirstName, account.LastName)); + return; + } + } + else + { + // Cannot find an avatar matching the claimed identifier + authRequest.IsAuthenticated = false; + } + } + + // Add OpenID headers to the response + foreach (string key in provider.Request.Response.Headers.Keys) + httpResponse.AddHeader(key, provider.Request.Response.Headers[key]); + + string[] contentTypeValues = provider.Request.Response.Headers.GetValues("Content-Type"); + if (contentTypeValues != null && contentTypeValues.Length == 1) + m_contentType = contentTypeValues[0]; + + // Set the response code and document body based on the OpenID result + httpResponse.StatusCode = (int)provider.Request.Response.Code; + response.Write(provider.Request.Response.Body, 0, provider.Request.Response.Body.Length); + response.Close(); + } + else if (httpRequest.Url.AbsolutePath.Contains("/openid/server")) + { + // Standard HTTP GET was made on the OpenID endpoint, send the client the default error page + using (StreamWriter writer = new StreamWriter(response)) + writer.Write(ENDPOINT_PAGE); + } + else + { + // Try and lookup this avatar + UserAccount account; + if (TryGetAccount(httpRequest.Url, out account)) + { + using (StreamWriter writer = new StreamWriter(response)) + { + // TODO: Print out a full profile page for this avatar + writer.Write(String.Format(OPENID_PAGE, httpRequest.Url.Scheme, + httpRequest.Url.Authority, account.FirstName, account.LastName)); + } + } + else + { + // Couldn't parse an avatar name, or couldn't find the avatar in the user server + using (StreamWriter writer = new StreamWriter(response)) + writer.Write(INVALID_OPENID_PAGE); + } + } + } + catch (Exception ex) + { + httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError; + using (StreamWriter writer = new StreamWriter(response)) + writer.Write(ex.Message); + } + } + + /// + /// Parse a URL with a relative path of the form /users/First_Last and try to + /// retrieve the profile matching that avatar name + /// + /// URL to parse for an avatar name + /// Profile data for the avatar + /// True if the parse and lookup were successful, otherwise false + bool TryGetAccount(Uri requestUrl, out UserAccount account) + { + if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/") + { + // Parse the avatar name from the path + string username = requestUrl.Segments[requestUrl.Segments.Length - 1]; + string[] name = username.Split('_'); + + if (name.Length == 2) + { + account = m_userAccountService.GetUserAccount(UUID.Zero, name[0], name[1]); + return (account != null); + } + } + + account = null; + return false; + } + } +} -- cgit v1.1 From eb6d49e02ca89aa8a834fc964881e30eb17251a4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 17:19:40 -0800 Subject: Fixed small inconsistency in config var name. --- OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs index 2abef0a..adb1e5b 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs @@ -49,7 +49,7 @@ namespace OpenSim.Server.Handlers.Authentication if (serverConfig == null) throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); - string authenticationService = serverConfig.GetString("AuthenticationServiceModule", + string authenticationService = serverConfig.GetString("LocalServiceModule", String.Empty); if (authenticationService == String.Empty) -- cgit v1.1 From 49618dc102c42b7125303511d826f76f0ebaab4c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 19:19:34 -0800 Subject: Moved GridInfo service from where it was to Handlers/Grid --- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 154 +++++++++++++++++++++ .../Handlers/Grid/GridInfoServerInConnector.cs | 55 ++++++++ 2 files changed, 209 insertions(+) create mode 100644 OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs create mode 100644 OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs new file mode 100644 index 0000000..d1233dc --- /dev/null +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -0,0 +1,154 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; + +namespace OpenSim.Server.Handlers.Grid +{ + public class GridInfoHandlers + { + private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Hashtable _info = new Hashtable(); + + /// + /// Instantiate a GridInfoService object. + /// + /// path to config path containing + /// grid information + /// + /// GridInfoService uses the [GridInfo] section of the + /// standard OpenSim.ini file --- which is not optimal, but + /// anything else requires a general redesign of the config + /// system. + /// + public GridInfoHandlers(IConfigSource configSource) + { + loadGridInfo(configSource); + } + + private void loadGridInfo(IConfigSource configSource) + { + _info["platform"] = "OpenSim"; + try + { + IConfig startupCfg = configSource.Configs["Startup"]; + IConfig gridCfg = configSource.Configs["GridInfoService"]; + IConfig netCfg = configSource.Configs["Network"]; + + bool grid = startupCfg.GetBoolean("gridmode", false); + + if (null != gridCfg) + { + foreach (string k in gridCfg.GetKeys()) + { + _info[k] = gridCfg.GetString(k); + } + } + else if (null != netCfg) + { + if (grid) + _info["login"] + = netCfg.GetString( + "user_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultUserServerHttpPort.ToString()); + else + _info["login"] + = String.Format( + "http://127.0.0.1:{0}/", + netCfg.GetString( + "http_listener_port", ConfigSettings.DefaultRegionHttpPort.ToString())); + + IssueWarning(); + } + else + { + _info["login"] = "http://127.0.0.1:9000/"; + IssueWarning(); + } + } + catch (Exception) + { + _log.Debug("[GRID INFO SERVICE]: Cannot get grid info from config source, using minimal defaults"); + } + + _log.DebugFormat("[GRID INFO SERVICE]: Grid info service initialized with {0} keys", _info.Count); + + } + + private void IssueWarning() + { + _log.Warn("[GRID INFO SERVICE]: found no [GridInfo] section in your OpenSim.ini"); + _log.Warn("[GRID INFO SERVICE]: trying to guess sensible defaults, you might want to provide better ones:"); + + foreach (string k in _info.Keys) + { + _log.WarnFormat("[GRID INFO SERVICE]: {0}: {1}", k, _info[k]); + } + } + + public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request, IPEndPoint remoteClient) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + _log.Info("[GRID INFO SERVICE]: Request for grid info"); + + foreach (string k in _info.Keys) + { + responseData[k] = _info[k]; + } + response.Value = responseData; + + return response; + } + + public string RestGetGridInfoMethod(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + StringBuilder sb = new StringBuilder(); + + sb.Append("\n"); + foreach (string k in _info.Keys) + { + sb.AppendFormat("<{0}>{1}\n", k, _info[k]); + } + sb.Append("\n"); + + return sb.ToString(); + } + } +} diff --git a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs new file mode 100644 index 0000000..c9e80d9 --- /dev/null +++ b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs @@ -0,0 +1,55 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using log4net; +using OpenMetaverse; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +namespace OpenSim.Server.Handlers.Grid +{ + public class GridInfoServerInConnector : ServiceConnector + { + private string m_ConfigName = "GridInfoService"; + + public GridInfoServerInConnector(IConfigSource config, IHttpServer server, string configName) : + base(config, server, configName) + { + GridInfoHandlers handlers = new GridInfoHandlers(config); + + server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", + handlers.RestGetGridInfoMethod)); + server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); + } + + } +} -- cgit v1.1 From 7356860b487febd12c2e0de2f009a6df9ea0aeec Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 09:17:30 -0800 Subject: Several more buglets removed. --- .../Handlers/Presence/PresenceServerPostHandler.cs | 10 ++++--- .../Server/Handlers/Simulation/AgentHandlers.cs | 12 ++++---- .../Server/Handlers/Simulation/ObjectHandlers.cs | 35 ++++++++++++++-------- .../UserAccounts/UserAccountServerPostHandler.cs | 11 +++---- 4 files changed, 40 insertions(+), 28 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 926c195..d180bbb 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -65,7 +65,7 @@ namespace OpenSim.Server.Handlers.Presence body = body.Trim(); //m_log.DebugFormat("[XXX]: query String: {0}", body); - + string method = string.Empty; try { Dictionary request = @@ -74,7 +74,7 @@ namespace OpenSim.Server.Handlers.Presence if (!request.ContainsKey("METHOD")) return FailureResult(); - string method = request["METHOD"].ToString(); + method = request["METHOD"].ToString(); switch (method) { @@ -97,7 +97,7 @@ namespace OpenSim.Server.Handlers.Presence } catch (Exception e) { - m_log.Debug("[PRESENCE HANDLER]: Exception {0}" + e); + m_log.DebugFormat("[PRESENCE HANDLER]: Exception in method {0}: {1}", method, e); } return FailureResult(); @@ -188,9 +188,11 @@ namespace OpenSim.Server.Handlers.Presence if (request.ContainsKey("lookAt")) Vector3.TryParse(request["lookAt"].ToString(), out look); - + if (m_PresenceService.ReportAgent(session, region, position, look)) + { return SuccessResult(); + } return FailureResult(); } diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 782034b..da9c015 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -61,11 +61,11 @@ namespace OpenSim.Server.Handlers.Simulation { //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); - m_log.Debug("---------------------------"); - m_log.Debug(" >> uri=" + request["uri"]); - m_log.Debug(" >> content-type=" + request["content-type"]); - m_log.Debug(" >> http-method=" + request["http-method"]); - m_log.Debug("---------------------------\n"); + //m_log.Debug("---------------------------"); + //m_log.Debug(" >> uri=" + request["uri"]); + //m_log.Debug(" >> content-type=" + request["content-type"]); + //m_log.Debug(" >> http-method=" + request["http-method"]); + //m_log.Debug("---------------------------\n"); Hashtable responsedata = new Hashtable(); responsedata["content_type"] = "text/html"; @@ -320,7 +320,7 @@ namespace OpenSim.Server.Handlers.Simulation responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); - m_log.Debug("[AGENT HANDLER]: Agent Deleted."); + m_log.Debug("[AGENT HANDLER]: Agent Released/Deleted."); } } diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs index 995a3c4..b6eabe3 100644 --- a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs @@ -59,13 +59,13 @@ namespace OpenSim.Server.Handlers.Simulation public Hashtable Handler(Hashtable request) { - m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); + //m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); - m_log.Debug("---------------------------"); - m_log.Debug(" >> uri=" + request["uri"]); - m_log.Debug(" >> content-type=" + request["content-type"]); - m_log.Debug(" >> http-method=" + request["http-method"]); - m_log.Debug("---------------------------\n"); + //m_log.Debug("---------------------------"); + //m_log.Debug(" >> uri=" + request["uri"]); + //m_log.Debug(" >> content-type=" + request["content-type"]); + //m_log.Debug(" >> http-method=" + request["http-method"]); + //m_log.Debug("---------------------------\n"); Hashtable responsedata = new Hashtable(); responsedata["content_type"] = "text/html"; @@ -75,7 +75,7 @@ namespace OpenSim.Server.Handlers.Simulation string action; if (!Utils.GetParams((string)request["uri"], out objectID, out regionID, out action)) { - m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); + m_log.InfoFormat("[OBJECT HANDLER]: Invalid parameters for object message {0}", request["uri"]); responsedata["int_response_code"] = 404; responsedata["str_response_string"] = "false"; @@ -101,7 +101,7 @@ namespace OpenSim.Server.Handlers.Simulation //} else { - m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method); + m_log.InfoFormat("[OBJECT HANDLER]: method {0} not supported in object message", method); responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; responsedata["str_response_string"] = "Mthod not allowed"; @@ -148,13 +148,13 @@ namespace OpenSim.Server.Handlers.Simulation ISceneObject sog = null; try { - //sog = SceneObjectSerializer.FromXml2Format(sogXmlStr); + //m_log.DebugFormat("[OBJECT HANDLER]: received {0}", sogXmlStr); sog = s.DeserializeObject(sogXmlStr); sog.ExtraFromXmlString(extraStr); } catch (Exception ex) { - m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message); + m_log.InfoFormat("[OBJECT HANDLER]: exception on deserializing scene object {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; @@ -171,13 +171,22 @@ namespace OpenSim.Server.Handlers.Simulation } catch (Exception ex) { - m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message); + m_log.InfoFormat("[OBJECT HANDLER]: exception on setting state for scene object {0}", ex.Message); // ignore and continue } } } - // This is the meaning of POST object - bool result = m_SimulationService.CreateObject(destination, sog, false); + + bool result = false; + try + { + // This is the meaning of POST object + result = m_SimulationService.CreateObject(destination, sog, false); + } + catch (Exception e) + { + m_log.DebugFormat("[OBJECT HANDLER]: Exception in CreateObject: {0}", e.StackTrace); + } responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = result.ToString(); diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index b54b63e..6a82165 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs @@ -68,7 +68,7 @@ namespace OpenSim.Server.Handlers.UserAccounts //httpRequest.Headers["authorization"] ... //m_log.DebugFormat("[XXX]: query String: {0}", body); - + string method = string.Empty; try { Dictionary request = @@ -77,7 +77,7 @@ namespace OpenSim.Server.Handlers.UserAccounts if (!request.ContainsKey("METHOD")) return FailureResult(); - string method = request["METHOD"].ToString(); + method = request["METHOD"].ToString(); switch (method) { @@ -88,11 +88,11 @@ namespace OpenSim.Server.Handlers.UserAccounts case "setaccount": return StoreAccount(request); } - m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); + m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method); } catch (Exception e) { - m_log.Debug("[PRESENCE HANDLER]: Exception {0}" + e); + m_log.DebugFormat("[USER SERVICE HANDLER]: Exception in method {0}: {1}", method, e); } return FailureResult(); @@ -134,7 +134,9 @@ namespace OpenSim.Server.Handlers.UserAccounts if (account == null) result["result"] = "null"; else + { result["result"] = account.ToKeyValuePairs(); + } return ResultToBytes(result); } @@ -247,7 +249,6 @@ namespace OpenSim.Server.Handlers.UserAccounts private byte[] ResultToBytes(Dictionary result) { string xmlString = ServerUtils.BuildXmlResponse(result); - //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); return encoding.GetBytes(xmlString); } -- cgit v1.1 From e90a5895ada61aab7fc27ab6f67b13a20676e07b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 21:32:48 -0800 Subject: Bug fix in releasing agent. In Scene, always use SimulatonService, and not m_SimulationService, because it may be null... --- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index da9c015..0c098d9 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -59,13 +59,13 @@ namespace OpenSim.Server.Handlers.Simulation public Hashtable Handler(Hashtable request) { - //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); + m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); - //m_log.Debug("---------------------------"); - //m_log.Debug(" >> uri=" + request["uri"]); - //m_log.Debug(" >> content-type=" + request["content-type"]); - //m_log.Debug(" >> http-method=" + request["http-method"]); - //m_log.Debug("---------------------------\n"); + m_log.Debug("---------------------------"); + m_log.Debug(" >> uri=" + request["uri"]); + m_log.Debug(" >> content-type=" + request["content-type"]); + m_log.Debug(" >> http-method=" + request["http-method"]); + m_log.Debug("---------------------------\n"); Hashtable responsedata = new Hashtable(); responsedata["content_type"] = "text/html"; @@ -307,7 +307,7 @@ namespace OpenSim.Server.Handlers.Simulation protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID) { - //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); + m_log.Debug(" >>> DoDelete action:" + action + "; RegionID:" + regionID); GridRegion destination = new GridRegion(); destination.RegionID = regionID; -- cgit v1.1 From 369e57beee4464c8d54c8982da535d747f3ad338 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 21:34:29 -0800 Subject: Take the verbose debug messages in AgentHandler out again. --- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 0c098d9..45e88ce 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -59,13 +59,13 @@ namespace OpenSim.Server.Handlers.Simulation public Hashtable Handler(Hashtable request) { - m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); + //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); - m_log.Debug("---------------------------"); - m_log.Debug(" >> uri=" + request["uri"]); - m_log.Debug(" >> content-type=" + request["content-type"]); - m_log.Debug(" >> http-method=" + request["http-method"]); - m_log.Debug("---------------------------\n"); + //m_log.Debug("---------------------------"); + //m_log.Debug(" >> uri=" + request["uri"]); + //m_log.Debug(" >> content-type=" + request["content-type"]); + //m_log.Debug(" >> http-method=" + request["http-method"]); + //m_log.Debug("---------------------------\n"); Hashtable responsedata = new Hashtable(); responsedata["content_type"] = "text/html"; -- cgit v1.1 From 4bae547ecb67fcf74981ad85c02872dedc99f94a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 14 Jan 2010 06:36:39 -0800 Subject: Added the 2 missing methods in the grid service remote connections. --- .../Server/Handlers/Grid/GridServerPostHandler.cs | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index d99b791..1601575 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -103,6 +103,12 @@ namespace OpenSim.Server.Handlers.Grid case "get_region_range": return GetRegionRange(request); + case "get_default_regions": + return GetDefaultRegions(request); + + case "get_fallback_regions": + return GetFallbackRegions(request); + } m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); } @@ -404,6 +410,77 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } + byte[] GetDefaultRegions(Dictionary request) + { + //m_log.DebugFormat("[GRID HANDLER]: GetDefaultRegions"); + UUID scopeID = UUID.Zero; + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); + + List rinfos = m_GridService.GetDefaultRegions(scopeID); + + Dictionary result = new Dictionary(); + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } + } + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + + byte[] GetFallbackRegions(Dictionary request) + { + //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); + UUID scopeID = UUID.Zero; + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get fallback regions"); + + int x = 0, y = 0; + if (request.ContainsKey("X")) + Int32.TryParse(request["X"].ToString(), out x); + else + m_log.WarnFormat("[GRID HANDLER]: no X in request to get fallback regions"); + if (request.ContainsKey("Y")) + Int32.TryParse(request["Y"].ToString(), out y); + else + m_log.WarnFormat("[GRID HANDLER]: no Y in request to get fallback regions"); + + + List rinfos = m_GridService.GetFallbackRegions(scopeID, x, y); + + Dictionary result = new Dictionary(); + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } + } + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + #endregion #region Misc -- cgit v1.1 From 04e29c1bacbc1e2df980ae15896a847ce7535da2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 16 Jan 2010 21:42:44 -0800 Subject: Beginning of rewriting HG. Compiles, and runs, but HG functions not restored yet. --- .../Hypergrid/GatekeeperServerConnector.cs | 140 +++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs new file mode 100644 index 0000000..ec8dde4 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -0,0 +1,140 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using log4net; +using Nwc.XmlRpc; + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class GatekeeperServiceInConnector : ServiceConnector + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IGatekeeperService m_GatekeeperService; + + public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : + base(config, server, String.Empty) + { + IConfig gridConfig = config.Configs["GatekeeperService"]; + if (gridConfig != null) + { + string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); + Object[] args = new Object[] { config, simService }; + m_GatekeeperService = ServerUtils.LoadPlugin(serviceDll, args); + } + if (m_GatekeeperService == null) + throw new Exception("Gatekeeper server connector cannot proceed because of missing service"); + + server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); + server.AddXmlRPCHandler("get_region", GetRegion, false); + } + + public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server) + : this(config, server, null) + { + } + + /// + /// Someone wants to link to us + /// + /// + /// + public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string name = (string)requestData["region_name"]; + + m_log.DebugFormat("[HGrid]: Hyperlink request"); + + UUID regionID = UUID.Zero; + string imageURL = string.Empty; + ulong regionHandle = 0; + string reason = string.Empty; + + bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out imageURL, out reason); + + Hashtable hash = new Hashtable(); + hash["result"] = success.ToString(); + hash["uuid"] = regionID.ToString(); + hash["handle"] = regionHandle.ToString(); + hash["region_image"] = imageURL; + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + } + + public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string regionID_str = (string)requestData["regionID"]; + UUID regionID = UUID.Zero; + UUID.TryParse(regionID_str, out regionID); + + GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID); + + Hashtable hash = new Hashtable(); + if (regInfo == null) + hash["result"] = "false"; + else + { + hash["result"] = "true"; + hash["uuid"] = regInfo.RegionID.ToString(); + hash["x"] = regInfo.RegionLocX.ToString(); + hash["y"] = regInfo.RegionLocY.ToString(); + hash["region_name"] = regInfo.RegionName; + hash["hostname"] = regInfo.ExternalHostName; + hash["http_port"] = regInfo.HttpPort.ToString(); + hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); + } + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + } +} -- cgit v1.1 From 6dceb8b4a98974a6869e2695e605caa31711e7a5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 07:37:43 -0800 Subject: These 2 were moved to corresponding Hypergrid folders. The server connector was renamed to Gatekeeper, because it will have all the handlers for the gatekeeper. --- .../Handlers/Grid/HypergridServerConnector.cs | 208 --------------------- 1 file changed, 208 deletions(-) delete mode 100644 OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs deleted file mode 100644 index 115ac29..0000000 --- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Server.Base; -using OpenSim.Services.Interfaces; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Server.Handlers.Base; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -using OpenMetaverse; -using log4net; -using Nwc.XmlRpc; - -namespace OpenSim.Server.Handlers.Grid -{ - public class HypergridServiceInConnector : ServiceConnector - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private List m_RegionsOnSim = new List(); - private IHyperlinkService m_HyperlinkService; - - public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) : - base(config, server, String.Empty) - { - m_HyperlinkService = hyperService; - server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); - server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false); - } - - public void AddRegion(GridRegion rinfo) - { - m_RegionsOnSim.Add(rinfo); - } - - public void RemoveRegion(GridRegion rinfo) - { - if (m_RegionsOnSim.Contains(rinfo)) - m_RegionsOnSim.Remove(rinfo); - } - - /// - /// Someone wants to link to us - /// - /// - /// - public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - //string host = (string)requestData["host"]; - //string portstr = (string)requestData["port"]; - string name = (string)requestData["region_name"]; - - m_log.DebugFormat("[HGrid]: Hyperlink request"); - - GridRegion regInfo = null; - foreach (GridRegion r in m_RegionsOnSim) - { - if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower())) - { - regInfo = r; - break; - } - } - - if (regInfo == null) - regInfo = m_RegionsOnSim[0]; // Send out the first region - - Hashtable hash = new Hashtable(); - hash["uuid"] = regInfo.RegionID.ToString(); - m_log.Debug(">> Here " + regInfo.RegionID); - hash["handle"] = regInfo.RegionHandle.ToString(); - hash["region_image"] = regInfo.TerrainImage.ToString(); - hash["region_name"] = regInfo.RegionName; - hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); - //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port); - - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - } - - /// - /// Received from other HGrid nodes when a user wants to teleport here. This call allows - /// the region to prepare for direct communication from the client. Sends back an empty - /// xmlrpc response on completion. - /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of - /// registering the user in the local user cache. - /// - /// - /// - public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - ForeignUserProfileData userData = new ForeignUserProfileData(); - - userData.FirstName = (string)requestData["firstname"]; - userData.SurName = (string)requestData["lastname"]; - userData.ID = new UUID((string)requestData["agent_id"]); - UUID sessionID = new UUID((string)requestData["session_id"]); - userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]), - (float)Convert.ToDecimal((string)requestData["startpos_y"]), - (float)Convert.ToDecimal((string)requestData["startpos_z"])); - - userData.UserServerURI = (string)requestData["userserver_id"]; - userData.UserAssetURI = (string)requestData["assetserver_id"]; - userData.UserInventoryURI = (string)requestData["inventoryserver_id"]; - - m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}", - userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID); - - ulong userRegionHandle = 0; - int userhomeinternalport = 0; - if (requestData.ContainsKey("region_uuid")) - { - UUID uuid = UUID.Zero; - UUID.TryParse((string)requestData["region_uuid"], out uuid); - userData.HomeRegionID = uuid; - userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); - userData.UserHomeAddress = (string)requestData["home_address"]; - userData.UserHomePort = (string)requestData["home_port"]; - userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]); - - m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress + - "; home_port: " + userData.UserHomePort); - } - else - m_log.WarnFormat("[HGrid]: User has no home region information"); - - XmlRpcResponse resp = new XmlRpcResponse(); - - // Let's check if someone is trying to get in with a stolen local identity. - // The need for this test is a consequence of not having truly global names :-/ - bool comingHome = false; - if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false) - { - m_log.WarnFormat("[HGrid]: Access denied to foreign user."); - Hashtable respdata = new Hashtable(); - respdata["success"] = "FALSE"; - respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled."; - resp.Value = respdata; - return resp; - } - - // Finally, everything looks ok - //m_log.Debug("XXX---- EVERYTHING OK ---XXX"); - - if (!comingHome) - { - // We don't do this if the user is coming to the home grid - GridRegion home = new GridRegion(); - home.RegionID = userData.HomeRegionID; - home.ExternalHostName = userData.UserHomeAddress; - home.HttpPort = Convert.ToUInt32(userData.UserHomePort); - uint x = 0, y = 0; - Utils.LongToUInts(userRegionHandle, out x, out y); - home.RegionLocX = (int)x; - home.RegionLocY = (int)y; - home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport); - - m_HyperlinkService.AcceptUser(userData, home); - } - // else the user is coming to a non-home region of the home grid - // We simply drop this user information altogether - - Hashtable respdata2 = new Hashtable(); - respdata2["success"] = "TRUE"; - resp.Value = respdata2; - - return resp; - } - - } -} -- cgit v1.1 From a7309d90dacf503b0170ad911289c33e9ab42821 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 08:40:05 -0800 Subject: * Added ServiceURLs to AgentCircuitData. * Fixed a configuration buglet introduced yesterday in StandaloneHypergrid.ini. --- OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index ec8dde4..762ea79 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -86,8 +86,6 @@ namespace OpenSim.Server.Handlers.Hypergrid //string portstr = (string)requestData["port"]; string name = (string)requestData["region_name"]; - m_log.DebugFormat("[HGrid]: Hyperlink request"); - UUID regionID = UUID.Zero; string imageURL = string.Empty; ulong regionHandle = 0; -- cgit v1.1 From f276ba57bf5bd732fbc6a255213c9bb7f5f5f148 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 11:33:47 -0800 Subject: HG agent transfers are starting to work. Gatekeeper handlers are missing. --- .../Server/Handlers/Hypergrid/GatekeeperServerConnector.cs | 2 +- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index 762ea79..f72b36c 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -109,7 +109,7 @@ namespace OpenSim.Server.Handlers.Hypergrid Hashtable requestData = (Hashtable)request.Params[0]; //string host = (string)requestData["host"]; //string portstr = (string)requestData["port"]; - string regionID_str = (string)requestData["regionID"]; + string regionID_str = (string)requestData["region_uuid"]; UUID regionID = UUID.Zero; UUID.TryParse(regionID_str, out regionID); diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 45e88ce..0c098d9 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -59,13 +59,13 @@ namespace OpenSim.Server.Handlers.Simulation public Hashtable Handler(Hashtable request) { - //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); + m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); - //m_log.Debug("---------------------------"); - //m_log.Debug(" >> uri=" + request["uri"]); - //m_log.Debug(" >> content-type=" + request["content-type"]); - //m_log.Debug(" >> http-method=" + request["http-method"]); - //m_log.Debug("---------------------------\n"); + m_log.Debug("---------------------------"); + m_log.Debug(" >> uri=" + request["uri"]); + m_log.Debug(" >> content-type=" + request["content-type"]); + m_log.Debug(" >> http-method=" + request["http-method"]); + m_log.Debug("---------------------------\n"); Hashtable responsedata = new Hashtable(); responsedata["content_type"] = "text/html"; -- cgit v1.1 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. --- OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs | 79 ++++++++++++++ .../Hypergrid/GatekeeperServerConnector.cs | 74 ++----------- .../Server/Handlers/Hypergrid/HypergridHandlers.cs | 115 +++++++++++++++++++++ .../Server/Handlers/Hypergrid/ObjectHandlers.cs | 68 ++++++++++++ .../Server/Handlers/Simulation/AgentHandlers.cs | 32 ++++-- .../Server/Handlers/Simulation/ObjectHandlers.cs | 12 ++- 6 files changed, 305 insertions(+), 75 deletions(-) create mode 100644 OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs create mode 100644 OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs create mode 100644 OpenSim/Server/Handlers/Hypergrid/ObjectHandlers.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs new file mode 100644 index 0000000..a56363c --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs @@ -0,0 +1,79 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Net; +using System.Text; + +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Simulation; +using Utils = OpenSim.Server.Handlers.Simulation.Utils; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using Nini.Config; +using log4net; + + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class AgentHandler : OpenSim.Server.Handlers.Simulation.AgentHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private IGatekeeperService m_GatekeeperService; + + public AgentHandler(IGatekeeperService gatekeeper) + { + m_GatekeeperService = gatekeeper; + } + + protected override bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) + { + return m_GatekeeperService.LoginAgent(aCircuit, destination, out reason); + } + + protected override bool UpdateAgent(GridRegion destination, AgentData agent) + { + return m_GatekeeperService.UpdateAgent(destination, agent); + } + + protected override void ReleaseAgent(UUID regionID, UUID id) + { + m_GatekeeperService.ReleaseAgent(regionID, id); + } + + } + +} diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index f72b36c..27b793d 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -26,21 +26,16 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Reflection; -using System.Net; using Nini.Config; using OpenSim.Framework; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; -using OpenMetaverse; using log4net; -using Nwc.XmlRpc; namespace OpenSim.Server.Handlers.Hypergrid { @@ -65,8 +60,13 @@ namespace OpenSim.Server.Handlers.Hypergrid if (m_GatekeeperService == null) throw new Exception("Gatekeeper server connector cannot proceed because of missing service"); - server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); - server.AddXmlRPCHandler("get_region", GetRegion, false); + HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); + server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); + server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); + + server.AddHTTPHandler("/foreignagent/", new AgentHandler(m_GatekeeperService).Handler); + server.AddHTTPHandler("/foreignobject/", new ObjectHandler(m_GatekeeperService).Handler); + } public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server) @@ -74,65 +74,5 @@ namespace OpenSim.Server.Handlers.Hypergrid { } - /// - /// Someone wants to link to us - /// - /// - /// - public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - //string host = (string)requestData["host"]; - //string portstr = (string)requestData["port"]; - string name = (string)requestData["region_name"]; - - UUID regionID = UUID.Zero; - string imageURL = string.Empty; - ulong regionHandle = 0; - string reason = string.Empty; - - bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out imageURL, out reason); - - Hashtable hash = new Hashtable(); - hash["result"] = success.ToString(); - hash["uuid"] = regionID.ToString(); - hash["handle"] = regionHandle.ToString(); - hash["region_image"] = imageURL; - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - } - - public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - //string host = (string)requestData["host"]; - //string portstr = (string)requestData["port"]; - string regionID_str = (string)requestData["region_uuid"]; - UUID regionID = UUID.Zero; - UUID.TryParse(regionID_str, out regionID); - - GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID); - - Hashtable hash = new Hashtable(); - if (regInfo == null) - hash["result"] = "false"; - else - { - hash["result"] = "true"; - hash["uuid"] = regInfo.RegionID.ToString(); - hash["x"] = regInfo.RegionLocX.ToString(); - hash["y"] = regInfo.RegionLocY.ToString(); - hash["region_name"] = regInfo.RegionName; - hash["hostname"] = regInfo.ExternalHostName; - hash["http_port"] = regInfo.HttpPort.ToString(); - hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); - } - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - - } } } diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs new file mode 100644 index 0000000..baafd7d --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; +using System.Reflection; + +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using log4net; +using Nwc.XmlRpc; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class HypergridHandlers + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IGatekeeperService m_GatekeeperService; + + public HypergridHandlers(IGatekeeperService gatekeeper) + { + m_GatekeeperService = gatekeeper; + } + + /// + /// Someone wants to link to us + /// + /// + /// + public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string name = (string)requestData["region_name"]; + + UUID regionID = UUID.Zero; + string imageURL = string.Empty; + ulong regionHandle = 0; + string reason = string.Empty; + + bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out imageURL, out reason); + + Hashtable hash = new Hashtable(); + hash["result"] = success.ToString(); + hash["uuid"] = regionID.ToString(); + hash["handle"] = regionHandle.ToString(); + hash["region_image"] = imageURL; + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + } + + public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string regionID_str = (string)requestData["region_uuid"]; + UUID regionID = UUID.Zero; + UUID.TryParse(regionID_str, out regionID); + + GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID); + + Hashtable hash = new Hashtable(); + if (regInfo == null) + hash["result"] = "false"; + else + { + hash["result"] = "true"; + hash["uuid"] = regInfo.RegionID.ToString(); + hash["x"] = regInfo.RegionLocX.ToString(); + hash["y"] = regInfo.RegionLocY.ToString(); + hash["region_name"] = regInfo.RegionName; + hash["hostname"] = regInfo.ExternalHostName; + hash["http_port"] = regInfo.HttpPort.ToString(); + hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); + } + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + } +} diff --git a/OpenSim/Server/Handlers/Hypergrid/ObjectHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/ObjectHandlers.cs new file mode 100644 index 0000000..20eb375 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/ObjectHandlers.cs @@ -0,0 +1,68 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Net; +using System.Text; + +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Simulation; +using Utils = OpenSim.Server.Handlers.Simulation.Utils; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using Nini.Config; +using log4net; + + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class ObjectHandler : OpenSim.Server.Handlers.Simulation.ObjectHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private IGatekeeperService m_GatekeeperService; + + public ObjectHandler(IGatekeeperService gatekeeper) + { + m_GatekeeperService = gatekeeper; + } + + protected override bool CreateObject(GridRegion destination, ISceneObject sog) + { + return m_GatekeeperService.LoginAttachment(destination, sog); + } + + } +} \ No newline at end of file diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 0c098d9..ab3250d 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -52,6 +52,8 @@ namespace OpenSim.Server.Handlers.Simulation private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private ISimulationService m_SimulationService; + public AgentHandler() { } + public AgentHandler(ISimulationService sim) { m_SimulationService = sim; @@ -117,7 +119,7 @@ namespace OpenSim.Server.Handlers.Simulation } - protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) + protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) @@ -171,7 +173,8 @@ namespace OpenSim.Server.Handlers.Simulation // This is the meaning of POST agent //m_regionClient.AdjustUserInformation(aCircuit); - bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); + //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); + bool result = CreateAgent(destination, aCircuit, teleportFlags, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); @@ -181,7 +184,13 @@ namespace OpenSim.Server.Handlers.Simulation responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); } - protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) + // subclasses can override this + protected virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) + { + return m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); + } + + protected void DoAgentPut(Hashtable request, Hashtable responsedata) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) @@ -237,7 +246,7 @@ namespace OpenSim.Server.Handlers.Simulation //agent.Dump(); // This is one of the meanings of PUT agent - result = m_SimulationService.UpdateAgent(destination, agent); + result = UpdateAgent(destination, agent); } else if ("AgentPosition".Equals(messageType)) @@ -263,6 +272,12 @@ namespace OpenSim.Server.Handlers.Simulation //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead } + // subclasses cab override this + protected virtual bool UpdateAgent(GridRegion destination, AgentData agent) + { + return m_SimulationService.UpdateAgent(destination, agent); + } + protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) { GridRegion destination = new GridRegion(); @@ -305,7 +320,7 @@ namespace OpenSim.Server.Handlers.Simulation } } - protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID) + protected void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID) { m_log.Debug(" >>> DoDelete action:" + action + "; RegionID:" + regionID); @@ -313,7 +328,7 @@ namespace OpenSim.Server.Handlers.Simulation destination.RegionID = regionID; if (action.Equals("release")) - m_SimulationService.ReleaseAgent(regionID, id, ""); + ReleaseAgent(regionID, id); else m_SimulationService.CloseAgent(destination, id); @@ -322,6 +337,11 @@ namespace OpenSim.Server.Handlers.Simulation m_log.Debug("[AGENT HANDLER]: Agent Released/Deleted."); } + + protected virtual void ReleaseAgent(UUID regionID, UUID id) + { + m_SimulationService.ReleaseAgent(regionID, id, ""); + } } } diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs index b6eabe3..33e5aa6 100644 --- a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs @@ -52,6 +52,8 @@ namespace OpenSim.Server.Handlers.Simulation private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private ISimulationService m_SimulationService; + public ObjectHandler() { } + public ObjectHandler(ISimulationService sim) { m_SimulationService = sim; @@ -110,7 +112,7 @@ namespace OpenSim.Server.Handlers.Simulation } - protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID) + protected void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) @@ -181,7 +183,7 @@ namespace OpenSim.Server.Handlers.Simulation try { // This is the meaning of POST object - result = m_SimulationService.CreateObject(destination, sog, false); + result = CreateObject(destination, sog); } catch (Exception e) { @@ -192,6 +194,12 @@ namespace OpenSim.Server.Handlers.Simulation responsedata["str_response_string"] = result.ToString(); } + // subclasses can override this + protected virtual bool CreateObject(GridRegion destination, ISceneObject sog) + { + return m_SimulationService.CreateObject(destination, sog, false); + } + protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, UUID regionID) { OSDMap args = Utils.GetOSDMap((string)request["body"]); -- cgit v1.1 From b5fcb5e872ec138ff7138906bffae193b6dae1a6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 20:10:42 -0800 Subject: HG teleports through gatekeeper are working. --- OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs | 10 ---- .../Hypergrid/GatekeeperServerConnector.cs | 1 - .../Server/Handlers/Hypergrid/ObjectHandlers.cs | 68 ---------------------- 3 files changed, 79 deletions(-) delete mode 100644 OpenSim/Server/Handlers/Hypergrid/ObjectHandlers.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs index a56363c..01e368c 100644 --- a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs @@ -64,16 +64,6 @@ namespace OpenSim.Server.Handlers.Hypergrid return m_GatekeeperService.LoginAgent(aCircuit, destination, out reason); } - protected override bool UpdateAgent(GridRegion destination, AgentData agent) - { - return m_GatekeeperService.UpdateAgent(destination, agent); - } - - protected override void ReleaseAgent(UUID regionID, UUID id) - { - m_GatekeeperService.ReleaseAgent(regionID, id); - } - } } diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index 27b793d..c56ea3f 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -65,7 +65,6 @@ namespace OpenSim.Server.Handlers.Hypergrid server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); server.AddHTTPHandler("/foreignagent/", new AgentHandler(m_GatekeeperService).Handler); - server.AddHTTPHandler("/foreignobject/", new ObjectHandler(m_GatekeeperService).Handler); } diff --git a/OpenSim/Server/Handlers/Hypergrid/ObjectHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/ObjectHandlers.cs deleted file mode 100644 index 20eb375..0000000 --- a/OpenSim/Server/Handlers/Hypergrid/ObjectHandlers.cs +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.IO; -using System.Reflection; -using System.Net; -using System.Text; - -using OpenSim.Server.Base; -using OpenSim.Server.Handlers.Base; -using OpenSim.Services.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; -using OpenSim.Framework; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Server.Handlers.Simulation; -using Utils = OpenSim.Server.Handlers.Simulation.Utils; - -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using Nini.Config; -using log4net; - - -namespace OpenSim.Server.Handlers.Hypergrid -{ - public class ObjectHandler : OpenSim.Server.Handlers.Simulation.ObjectHandler - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private IGatekeeperService m_GatekeeperService; - - public ObjectHandler(IGatekeeperService gatekeeper) - { - m_GatekeeperService = gatekeeper; - } - - protected override bool CreateObject(GridRegion destination, ISceneObject sog) - { - return m_GatekeeperService.LoginAttachment(destination, sog); - } - - } -} \ No newline at end of file -- cgit v1.1 From fd64823466ee667d0d827f95d3001ec8675512b2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 10:37:11 -0800 Subject: * Added missing GatekeeperServiceConnector * Added basic machinery for teleporting users home. Untested. --- .../Hypergrid/GatekeeperServerConnector.cs | 1 + .../Server/Handlers/Hypergrid/HypergridHandlers.cs | 33 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index c56ea3f..f03d33a 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -63,6 +63,7 @@ namespace OpenSim.Server.Handlers.Hypergrid HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); + server.AddXmlRPCHandler("get_home_region", hghandlers.GetHomeRegion, false); server.AddHTTPHandler("/foreignagent/", new AgentHandler(m_GatekeeperService).Handler); diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index baafd7d..846d1c2 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -111,5 +111,38 @@ namespace OpenSim.Server.Handlers.Hypergrid } + public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string userID_str = (string)requestData["userID"]; + UUID userID = UUID.Zero; + UUID.TryParse(userID_str, out userID); + + Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; + GridRegion regInfo = m_GatekeeperService.GetHomeRegion(userID, out position, out lookAt); + + Hashtable hash = new Hashtable(); + if (regInfo == null) + hash["result"] = "false"; + else + { + hash["result"] = "true"; + hash["uuid"] = regInfo.RegionID.ToString(); + hash["x"] = regInfo.RegionLocX.ToString(); + hash["y"] = regInfo.RegionLocY.ToString(); + hash["region_name"] = regInfo.RegionName; + hash["hostname"] = regInfo.ExternalHostName; + hash["http_port"] = regInfo.HttpPort.ToString(); + hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); + hash["position"] = position.ToString(); + hash["lookAt"] = lookAt.ToString(); + } + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } } } -- cgit v1.1 From 3d536944153d4931cf891d6a788a47484f3e6f4d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 16:34:23 -0800 Subject: Go Home works. With security!! --- .../Hypergrid/GatekeeperServerConnector.cs | 4 + .../Hypergrid/HomeUsersSecurityServerConnector.cs | 122 +++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index f03d33a..15b29d2 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -46,6 +46,10 @@ namespace OpenSim.Server.Handlers.Hypergrid MethodBase.GetCurrentMethod().DeclaringType); private IGatekeeperService m_GatekeeperService; + public IGatekeeperService GateKeeper + { + get { return m_GatekeeperService; } + } public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : base(config, server, String.Empty) diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs new file mode 100644 index 0000000..5379784 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; +using System.Reflection; + +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +using log4net; +using Nwc.XmlRpc; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class HomeUsersSecurityServerConnector : ServiceConnector + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IHomeUsersSecurityService m_HomeUsersService; + + public HomeUsersSecurityServerConnector(IConfigSource config, IHttpServer server) : + base(config, server, String.Empty) + { + IConfig gridConfig = config.Configs["HomeUsersSecurityService"]; + if (gridConfig != null) + { + string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); + Object[] args = new Object[] { config }; + m_HomeUsersService = ServerUtils.LoadPlugin(serviceDll, args); + } + if (m_HomeUsersService == null) + throw new Exception("HomeUsersSecurity server connector cannot proceed because of missing service"); + + server.AddXmlRPCHandler("ep_get", GetEndPoint, false); + server.AddXmlRPCHandler("ep_set", SetEndPoint, false); + server.AddXmlRPCHandler("ep_remove", RemoveEndPoint, false); + + } + + public XmlRpcResponse GetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string sessionID_str = (string)requestData["sessionID"]; + UUID sessionID = UUID.Zero; + UUID.TryParse(sessionID_str, out sessionID); + + IPEndPoint ep = m_HomeUsersService.GetEndPoint(sessionID); + + Hashtable hash = new Hashtable(); + if (ep == null) + hash["result"] = "false"; + else + { + hash["result"] = "true"; + hash["ep_addr"] = ep.Address.ToString(); + hash["ep_port"] = ep.Port.ToString(); + } + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + public XmlRpcResponse SetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + string host = (string)requestData["ep_addr"]; + string portstr = (string)requestData["ep_port"]; + string sessionID_str = (string)requestData["sessionID"]; + UUID sessionID = UUID.Zero; + UUID.TryParse(sessionID_str, out sessionID); + int port = 0; + Int32.TryParse(portstr, out port); + + IPEndPoint ep = null; + try + { + ep = new IPEndPoint(IPAddress.Parse(host), port); + } + catch + { + m_log.Debug("[HOME USERS SECURITY]: Exception in creating EndPoint"); + } + + m_HomeUsersService.SetEndPoint(sessionID, ep); + + Hashtable hash = new Hashtable(); + hash["result"] = "true"; + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + public XmlRpcResponse RemoveEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + string sessionID_str = (string)requestData["sessionID"]; + UUID sessionID = UUID.Zero; + UUID.TryParse(sessionID_str, out sessionID); + + m_HomeUsersService.RemoveEndPoint(sessionID); + + Hashtable hash = new Hashtable(); + hash["result"] = "true"; + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + } +} -- cgit v1.1 From 9fbcceb1db84e62eedb75b2bd43f5e59142ec6c8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 20:35:59 -0800 Subject: * Towards enabling hyperlinks at grid-level. * Updated grid configs --- .../Hypergrid/GatekeeperServerConnector.cs | 11 +++++-- .../Server/Handlers/Hypergrid/HypergridHandlers.cs | 34 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index 15b29d2..940ec7a 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -51,6 +51,8 @@ namespace OpenSim.Server.Handlers.Hypergrid get { return m_GatekeeperService; } } + private IHypergridService m_HypergridService; + public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : base(config, server, String.Empty) { @@ -60,12 +62,17 @@ namespace OpenSim.Server.Handlers.Hypergrid string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); Object[] args = new Object[] { config, simService }; m_GatekeeperService = ServerUtils.LoadPlugin(serviceDll, args); + + serviceDll = gridConfig.GetString("HypergridService", string.Empty); + m_HypergridService = ServerUtils.LoadPlugin(serviceDll, args); + } - if (m_GatekeeperService == null) + if (m_GatekeeperService == null || m_HypergridService == null) throw new Exception("Gatekeeper server connector cannot proceed because of missing service"); - HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); + HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService, m_HypergridService); server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); + server.AddXmlRPCHandler("link_region_by_desc", hghandlers.LinkRegionByDescRequest, false); server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); server.AddXmlRPCHandler("get_home_region", hghandlers.GetHomeRegion, false); diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index 846d1c2..1d711a8 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -44,10 +44,12 @@ namespace OpenSim.Server.Handlers.Hypergrid private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IGatekeeperService m_GatekeeperService; + private IHypergridService m_HypergridService; - public HypergridHandlers(IGatekeeperService gatekeeper) + public HypergridHandlers(IGatekeeperService gatekeeper, IHypergridService hyper) { m_GatekeeperService = gatekeeper; + m_HypergridService = hyper; } /// @@ -80,6 +82,36 @@ namespace OpenSim.Server.Handlers.Hypergrid return response; } + /// + /// A local region wants to establish a grid-wide hyperlink to another region + /// + /// + /// + public XmlRpcResponse LinkRegionByDescRequest(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string descriptor = (string)requestData["region_desc"]; + + UUID regionID = UUID.Zero; + string imageURL = string.Empty; + ulong regionHandle = 0; + string reason = string.Empty; + + bool success = m_HypergridService.LinkRegion(descriptor, out regionID, out regionHandle, out imageURL, out reason); + + Hashtable hash = new Hashtable(); + hash["result"] = success.ToString(); + hash["uuid"] = regionID.ToString(); + hash["handle"] = regionHandle.ToString(); + hash["region_image"] = imageURL; + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + } + public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; -- cgit v1.1 From 48b03c2c61a422c3ac9843892a2ae93b29a9f7b8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 24 Jan 2010 14:30:48 -0800 Subject: Integrated the hyperlinking with the GridService. --- .../Hypergrid/GatekeeperServerConnector.cs | 10 ++----- .../Server/Handlers/Hypergrid/HypergridHandlers.cs | 34 +--------------------- 2 files changed, 3 insertions(+), 41 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index 940ec7a..c73b110 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -51,8 +51,6 @@ namespace OpenSim.Server.Handlers.Hypergrid get { return m_GatekeeperService; } } - private IHypergridService m_HypergridService; - public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : base(config, server, String.Empty) { @@ -63,16 +61,12 @@ namespace OpenSim.Server.Handlers.Hypergrid Object[] args = new Object[] { config, simService }; m_GatekeeperService = ServerUtils.LoadPlugin(serviceDll, args); - serviceDll = gridConfig.GetString("HypergridService", string.Empty); - m_HypergridService = ServerUtils.LoadPlugin(serviceDll, args); - } - if (m_GatekeeperService == null || m_HypergridService == null) + if (m_GatekeeperService == null) throw new Exception("Gatekeeper server connector cannot proceed because of missing service"); - HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService, m_HypergridService); + HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); - server.AddXmlRPCHandler("link_region_by_desc", hghandlers.LinkRegionByDescRequest, false); server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); server.AddXmlRPCHandler("get_home_region", hghandlers.GetHomeRegion, false); diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index 1d711a8..846d1c2 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -44,12 +44,10 @@ namespace OpenSim.Server.Handlers.Hypergrid private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IGatekeeperService m_GatekeeperService; - private IHypergridService m_HypergridService; - public HypergridHandlers(IGatekeeperService gatekeeper, IHypergridService hyper) + public HypergridHandlers(IGatekeeperService gatekeeper) { m_GatekeeperService = gatekeeper; - m_HypergridService = hyper; } /// @@ -82,36 +80,6 @@ namespace OpenSim.Server.Handlers.Hypergrid return response; } - /// - /// A local region wants to establish a grid-wide hyperlink to another region - /// - /// - /// - public XmlRpcResponse LinkRegionByDescRequest(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - //string host = (string)requestData["host"]; - //string portstr = (string)requestData["port"]; - string descriptor = (string)requestData["region_desc"]; - - UUID regionID = UUID.Zero; - string imageURL = string.Empty; - ulong regionHandle = 0; - string reason = string.Empty; - - bool success = m_HypergridService.LinkRegion(descriptor, out regionID, out regionHandle, out imageURL, out reason); - - Hashtable hash = new Hashtable(); - hash["result"] = success.ToString(); - hash["uuid"] = regionID.ToString(); - hash["handle"] = regionHandle.ToString(); - hash["region_image"] = imageURL; - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - } - public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; -- cgit v1.1 From 7c00469cd210cfdda3dd835867469159d4c8b9d9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 27 Jan 2010 08:00:29 -0800 Subject: Added ExternalName config on Gatekeeper. --- OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index 846d1c2..7d31730 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -63,17 +63,19 @@ namespace OpenSim.Server.Handlers.Hypergrid string name = (string)requestData["region_name"]; UUID regionID = UUID.Zero; + string externalName = string.Empty; string imageURL = string.Empty; ulong regionHandle = 0; string reason = string.Empty; - bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out imageURL, out reason); + bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out externalName, out imageURL, out reason); Hashtable hash = new Hashtable(); hash["result"] = success.ToString(); hash["uuid"] = regionID.ToString(); hash["handle"] = regionHandle.ToString(); hash["region_image"] = imageURL; + hash["external_name"] = externalName; XmlRpcResponse response = new XmlRpcResponse(); response.Value = hash; -- cgit v1.1 From 00f7d622cbc2c2e61d2efaacd8275da3f9821d8b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 28 Jan 2010 19:19:42 -0800 Subject: HG 1.5 is in place. Tested in standalone only. --- OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs | 4 +- .../Hypergrid/GatekeeperServerConnector.cs | 3 +- .../Hypergrid/HomeUsersSecurityServerConnector.cs | 122 --------------- .../Server/Handlers/Hypergrid/HypergridHandlers.cs | 33 ---- .../Handlers/Hypergrid/UserAgentServerConnector.cs | 168 +++++++++++++++++++++ 5 files changed, 171 insertions(+), 159 deletions(-) delete mode 100644 OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs create mode 100644 OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs index 01e368c..c951653 100644 --- a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs @@ -49,12 +49,12 @@ using log4net; namespace OpenSim.Server.Handlers.Hypergrid { - public class AgentHandler : OpenSim.Server.Handlers.Simulation.AgentHandler + public class GatekeeperAgentHandler : OpenSim.Server.Handlers.Simulation.AgentHandler { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IGatekeeperService m_GatekeeperService; - public AgentHandler(IGatekeeperService gatekeeper) + public GatekeeperAgentHandler(IGatekeeperService gatekeeper) { m_GatekeeperService = gatekeeper; } diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index c73b110..f2d9321 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -68,9 +68,8 @@ namespace OpenSim.Server.Handlers.Hypergrid HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); - server.AddXmlRPCHandler("get_home_region", hghandlers.GetHomeRegion, false); - server.AddHTTPHandler("/foreignagent/", new AgentHandler(m_GatekeeperService).Handler); + server.AddHTTPHandler("/foreignagent/", new GatekeeperAgentHandler(m_GatekeeperService).Handler); } diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs deleted file mode 100644 index 5379784..0000000 --- a/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Net; -using System.Reflection; - -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Server.Base; -using OpenSim.Services.Interfaces; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Server.Handlers.Base; - -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; - -namespace OpenSim.Server.Handlers.Hypergrid -{ - public class HomeUsersSecurityServerConnector : ServiceConnector - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private IHomeUsersSecurityService m_HomeUsersService; - - public HomeUsersSecurityServerConnector(IConfigSource config, IHttpServer server) : - base(config, server, String.Empty) - { - IConfig gridConfig = config.Configs["HomeUsersSecurityService"]; - if (gridConfig != null) - { - string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); - Object[] args = new Object[] { config }; - m_HomeUsersService = ServerUtils.LoadPlugin(serviceDll, args); - } - if (m_HomeUsersService == null) - throw new Exception("HomeUsersSecurity server connector cannot proceed because of missing service"); - - server.AddXmlRPCHandler("ep_get", GetEndPoint, false); - server.AddXmlRPCHandler("ep_set", SetEndPoint, false); - server.AddXmlRPCHandler("ep_remove", RemoveEndPoint, false); - - } - - public XmlRpcResponse GetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - //string host = (string)requestData["host"]; - //string portstr = (string)requestData["port"]; - string sessionID_str = (string)requestData["sessionID"]; - UUID sessionID = UUID.Zero; - UUID.TryParse(sessionID_str, out sessionID); - - IPEndPoint ep = m_HomeUsersService.GetEndPoint(sessionID); - - Hashtable hash = new Hashtable(); - if (ep == null) - hash["result"] = "false"; - else - { - hash["result"] = "true"; - hash["ep_addr"] = ep.Address.ToString(); - hash["ep_port"] = ep.Port.ToString(); - } - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - - } - - public XmlRpcResponse SetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - string host = (string)requestData["ep_addr"]; - string portstr = (string)requestData["ep_port"]; - string sessionID_str = (string)requestData["sessionID"]; - UUID sessionID = UUID.Zero; - UUID.TryParse(sessionID_str, out sessionID); - int port = 0; - Int32.TryParse(portstr, out port); - - IPEndPoint ep = null; - try - { - ep = new IPEndPoint(IPAddress.Parse(host), port); - } - catch - { - m_log.Debug("[HOME USERS SECURITY]: Exception in creating EndPoint"); - } - - m_HomeUsersService.SetEndPoint(sessionID, ep); - - Hashtable hash = new Hashtable(); - hash["result"] = "true"; - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - - } - - public XmlRpcResponse RemoveEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - string sessionID_str = (string)requestData["sessionID"]; - UUID sessionID = UUID.Zero; - UUID.TryParse(sessionID_str, out sessionID); - - m_HomeUsersService.RemoveEndPoint(sessionID); - - Hashtable hash = new Hashtable(); - hash["result"] = "true"; - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - - } - - } -} diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index 7d31730..0b65245 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -113,38 +113,5 @@ namespace OpenSim.Server.Handlers.Hypergrid } - public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - //string host = (string)requestData["host"]; - //string portstr = (string)requestData["port"]; - string userID_str = (string)requestData["userID"]; - UUID userID = UUID.Zero; - UUID.TryParse(userID_str, out userID); - - Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; - GridRegion regInfo = m_GatekeeperService.GetHomeRegion(userID, out position, out lookAt); - - Hashtable hash = new Hashtable(); - if (regInfo == null) - hash["result"] = "false"; - else - { - hash["result"] = "true"; - hash["uuid"] = regInfo.RegionID.ToString(); - hash["x"] = regInfo.RegionLocX.ToString(); - hash["y"] = regInfo.RegionLocY.ToString(); - hash["region_name"] = regInfo.RegionName; - hash["hostname"] = regInfo.ExternalHostName; - hash["http_port"] = regInfo.HttpPort.ToString(); - hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); - hash["position"] = position.ToString(); - hash["lookAt"] = lookAt.ToString(); - } - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - - } } } diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs new file mode 100644 index 0000000..79c6b2a --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; +using System.Reflection; + +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using log4net; +using Nwc.XmlRpc; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class UserAgentServerConnector : ServiceConnector + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IUserAgentService m_HomeUsersService; + + public UserAgentServerConnector(IConfigSource config, IHttpServer server) : + base(config, server, String.Empty) + { + IConfig gridConfig = config.Configs["UserAgentService"]; + if (gridConfig != null) + { + string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); + Object[] args = new Object[] { config }; + m_HomeUsersService = ServerUtils.LoadPlugin(serviceDll, args); + } + if (m_HomeUsersService == null) + throw new Exception("UserAgent server connector cannot proceed because of missing service"); + + server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false); + server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false); + server.AddXmlRPCHandler("verify_agent", VerifyAgent, false); + server.AddXmlRPCHandler("verify_client", VerifyClient, false); + server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); + + server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService).Handler); + } + + public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string userID_str = (string)requestData["userID"]; + UUID userID = UUID.Zero; + UUID.TryParse(userID_str, out userID); + + Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; + GridRegion regInfo = m_HomeUsersService.GetHomeRegion(userID, out position, out lookAt); + + Hashtable hash = new Hashtable(); + if (regInfo == null) + hash["result"] = "false"; + else + { + hash["result"] = "true"; + hash["uuid"] = regInfo.RegionID.ToString(); + hash["x"] = regInfo.RegionLocX.ToString(); + hash["y"] = regInfo.RegionLocY.ToString(); + hash["region_name"] = regInfo.RegionName; + hash["hostname"] = regInfo.ExternalHostName; + hash["http_port"] = regInfo.HttpPort.ToString(); + hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); + hash["position"] = position.ToString(); + hash["lookAt"] = lookAt.ToString(); + } + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + public XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string sessionID_str = (string)requestData["sessionID"]; + UUID sessionID = UUID.Zero; + UUID.TryParse(sessionID_str, out sessionID); + string gridName = (string)requestData["externalName"]; + + bool success = m_HomeUsersService.AgentIsComingHome(sessionID, gridName); + + Hashtable hash = new Hashtable(); + hash["result"] = success.ToString(); + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + public XmlRpcResponse VerifyAgent(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string sessionID_str = (string)requestData["sessionID"]; + UUID sessionID = UUID.Zero; + UUID.TryParse(sessionID_str, out sessionID); + string token = (string)requestData["token"]; + + bool success = m_HomeUsersService.VerifyAgent(sessionID, token); + + Hashtable hash = new Hashtable(); + hash["result"] = success.ToString(); + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + public XmlRpcResponse VerifyClient(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string sessionID_str = (string)requestData["sessionID"]; + UUID sessionID = UUID.Zero; + UUID.TryParse(sessionID_str, out sessionID); + string token = (string)requestData["token"]; + + bool success = m_HomeUsersService.VerifyClient(sessionID, token); + + Hashtable hash = new Hashtable(); + hash["result"] = success.ToString(); + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + public XmlRpcResponse LogoutAgent(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string sessionID_str = (string)requestData["sessionID"]; + UUID sessionID = UUID.Zero; + UUID.TryParse(sessionID_str, out sessionID); + string userID_str = (string)requestData["userID"]; + UUID userID = UUID.Zero; + UUID.TryParse(userID_str, out userID); + + m_HomeUsersService.LogoutAgent(userID, sessionID); + + Hashtable hash = new Hashtable(); + hash["result"] = "true"; + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + + } + + } +} -- cgit v1.1 From 0c81966c0a8f69474fb542d7b4df1780ef756519 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 29 Jan 2010 09:12:22 -0800 Subject: Works for grid login. --- .../Server/Handlers/Grid/GridServerPostHandler.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 318ce85..c90dd6f 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -109,6 +109,8 @@ namespace OpenSim.Server.Handlers.Grid case "get_fallback_regions": return GetFallbackRegions(request); + case "get_region_flags": + return GetRegionFlags(request); } m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); } @@ -481,6 +483,33 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } + byte[] GetRegionFlags(Dictionary request) + { + UUID scopeID = UUID.Zero; + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); + + UUID regionID = UUID.Zero; + if (request.ContainsKey("REGIONID")) + UUID.TryParse(request["REGIONID"].ToString(), out regionID); + else + m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); + + int flags = m_GridService.GetRegionFlags(scopeID, regionID); + // m_log.DebugFormat("[GRID HANDLER]: flags for region {0}: {1}", regionID, flags); + + Dictionary result = new Dictionary(); + result["result"] = flags.ToString(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + + #endregion #region Misc -- cgit v1.1 From 40d8e91008b7d76ce6b9398484c591eb51c85bdb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 31 Jan 2010 11:10:57 -0800 Subject: * Added a few files that were missing in the repo. * New HGInventoryService which allows restricted access to inventory while outside --- .../Hypergrid/HGInventoryServerInConnector.cs | 104 ++++++++++++ .../Server/Handlers/Hypergrid/HomeAgentHandlers.cs | 181 +++++++++++++++++++++ .../Inventory/InventoryServerInConnector.cs | 46 +----- 3 files changed, 290 insertions(+), 41 deletions(-) create mode 100644 OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs create mode 100644 OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs new file mode 100644 index 0000000..cf5d521 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs @@ -0,0 +1,104 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; +using System.Reflection; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Inventory; +using OpenSim.Services.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class HGInventoryServiceInConnector : InventoryServiceInConnector + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + //private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs + //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); + + private IUserAgentService m_UserAgentService; + + public HGInventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) : + base(config, server, configName) + { + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); + + string userAgentService = serverConfig.GetString("UserAgentService", string.Empty); + string m_userserver_url = serverConfig.GetString("UserAgentURI", String.Empty); + if (m_userserver_url != string.Empty) + { + Object[] args = new Object[] { m_userserver_url }; + m_UserAgentService = ServerUtils.LoadPlugin(userAgentService, args); + } + + AddHttpHandlers(server); + m_log.Debug("[HG HG INVENTORY HANDLER]: handlers initialized"); + } + + /// + /// Check that the source of an inventory request for a particular agent is a current session belonging to + /// that agent. + /// + /// + /// + /// + public override bool CheckAuthSession(string session_id, string avatar_id) + { + m_log.InfoFormat("[HG INVENTORY IN CONNECTOR]: checking authed session {0} {1}", session_id, avatar_id); + // This doesn't work + + // if (m_session_cache.getCachedSession(session_id, avatar_id) == null) + // { + // //cache miss, ask userserver + // m_UserAgentService.VerifyAgent(session_id, ???); + // } + // else + // { + // // cache hits + // m_log.Info("[HG INVENTORY IN CONNECTOR]: got authed session from cache"); + // return true; + // } + + // m_log.Warn("[HG INVENTORY IN CONNECTOR]: unknown session_id, request rejected"); + // return false; + + return true; + } + } +} diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs new file mode 100644 index 0000000..17d7850 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs @@ -0,0 +1,181 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Net; +using System.Text; + +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Simulation; +using Utils = OpenSim.Server.Handlers.Simulation.Utils; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using Nini.Config; +using log4net; + + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class HomeAgentHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private IUserAgentService m_UserAgentService; + + public HomeAgentHandler(IUserAgentService userAgentService) + { + m_UserAgentService = userAgentService; + } + + public Hashtable Handler(Hashtable request) + { + m_log.Debug("[CONNECTION DEBUGGING]: HomeAgentHandler Called"); + + m_log.Debug("---------------------------"); + m_log.Debug(" >> uri=" + request["uri"]); + m_log.Debug(" >> content-type=" + request["content-type"]); + m_log.Debug(" >> http-method=" + request["http-method"]); + m_log.Debug("---------------------------\n"); + + Hashtable responsedata = new Hashtable(); + responsedata["content_type"] = "text/html"; + responsedata["keepalive"] = false; + + + UUID agentID; + UUID regionID; + string action; + if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action)) + { + m_log.InfoFormat("[HOME AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]); + responsedata["int_response_code"] = 404; + responsedata["str_response_string"] = "false"; + + return responsedata; + } + + // Next, let's parse the verb + string method = (string)request["http-method"]; + if (method.Equals("POST")) + { + DoAgentPost(request, responsedata, agentID); + return responsedata; + } + else + { + m_log.InfoFormat("[HOME AGENT HANDLER]: method {0} not supported in agent message", method); + responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; + responsedata["str_response_string"] = "Method not allowed"; + + return responsedata; + } + + } + + protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) + { + OSDMap args = Utils.GetOSDMap((string)request["body"]); + if (args == null) + { + responsedata["int_response_code"] = HttpStatusCode.BadRequest; + responsedata["str_response_string"] = "Bad request"; + return; + } + + // retrieve the input arguments + int x = 0, y = 0; + UUID uuid = UUID.Zero; + string regionname = string.Empty; + string gatekeeper_host = string.Empty; + int gatekeeper_port = 0; + + if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null) + gatekeeper_host = args["gatekeeper_host"].AsString(); + if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null) + Int32.TryParse(args["gatekeeper_port"].AsString(), out gatekeeper_port); + + GridRegion gatekeeper = new GridRegion(); + gatekeeper.ExternalHostName = gatekeeper_host; + gatekeeper.HttpPort = (uint)gatekeeper_port; + gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + + if (args.ContainsKey("destination_x") && args["destination_x"] != null) + Int32.TryParse(args["destination_x"].AsString(), out x); + else + m_log.WarnFormat(" -- request didn't have destination_x"); + if (args.ContainsKey("destination_y") && args["destination_y"] != null) + Int32.TryParse(args["destination_y"].AsString(), out y); + else + m_log.WarnFormat(" -- request didn't have destination_y"); + if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) + UUID.TryParse(args["destination_uuid"].AsString(), out uuid); + if (args.ContainsKey("destination_name") && args["destination_name"] != null) + regionname = args["destination_name"].ToString(); + + GridRegion destination = new GridRegion(); + destination.RegionID = uuid; + destination.RegionLocX = x; + destination.RegionLocY = y; + destination.RegionName = regionname; + + AgentCircuitData aCircuit = new AgentCircuitData(); + try + { + aCircuit.UnpackAgentCircuitData(args); + } + catch (Exception ex) + { + m_log.InfoFormat("[HOME AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); + responsedata["int_response_code"] = HttpStatusCode.BadRequest; + responsedata["str_response_string"] = "Bad request"; + return; + } + + OSDMap resp = new OSDMap(2); + string reason = String.Empty; + + bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason); + + resp["reason"] = OSD.FromString(reason); + resp["success"] = OSD.FromBoolean(result); + + // TODO: add reason if not String.Empty? + responsedata["int_response_code"] = HttpStatusCode.OK; + responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); + } + + } + +} diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index 3c92209..53db739 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs @@ -46,7 +46,7 @@ namespace OpenSim.Server.Handlers.Inventory { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private IInventoryService m_InventoryService; + protected IInventoryService m_InventoryService; private bool m_doLookup = false; @@ -54,11 +54,12 @@ namespace OpenSim.Server.Handlers.Inventory //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); private string m_userserver_url; - private string m_ConfigName = "InventoryService"; + protected string m_ConfigName = "InventoryService"; public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) { + m_ConfigName = configName; IConfig serverConfig = config.Configs[m_ConfigName]; if (serverConfig == null) throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); @@ -328,46 +329,9 @@ namespace OpenSim.Server.Handlers.Inventory /// /// /// - public bool CheckAuthSession(string session_id, string avatar_id) + public virtual bool CheckAuthSession(string session_id, string avatar_id) { - if (m_doLookup) - { - m_log.InfoFormat("[INVENTORY IN CONNECTOR]: checking authed session {0} {1}", session_id, avatar_id); - - //if (m_session_cache.getCachedSession(session_id, avatar_id) == null) - //{ - // cache miss, ask userserver - Hashtable requestData = new Hashtable(); - requestData["avatar_uuid"] = avatar_id; - requestData["session_id"] = session_id; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); - XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); - - Hashtable responseData = (Hashtable)UserResp.Value; - if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") - { - m_log.Info("[INVENTORY IN CONNECTOR]: got authed session from userserver"); - //// add to cache; the session time will be automatically renewed - //m_session_cache.Add(session_id, avatar_id); - return true; - } - //} - //else - //{ - // // cache hits - // m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache"); - // return true; - //} - - m_log.Warn("[INVENTORY IN CONNECTOR]: unknown session_id, request rejected"); - return false; - } - else - { - return true; - } + return true; } } -- cgit v1.1 From 22a3ad7f6c5f54e326ac02483a9540fddaeb7506 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 31 Jan 2010 11:26:12 -0800 Subject: * Bug fix in XInventoryData -- groupOwned is an int in the DB * Bug fix in InventoryServerInConnector -- m_config --- OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index 53db739..1d422a7 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs @@ -59,7 +59,9 @@ namespace OpenSim.Server.Handlers.Inventory public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) { - m_ConfigName = configName; + if (configName != string.Empty) + m_ConfigName = configName; + IConfig serverConfig = config.Configs[m_ConfigName]; if (serverConfig == null) throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); -- cgit v1.1 From 0b89afd3e5a8fe95677fb916cfde649361a349fe Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 31 Jan 2010 14:37:22 -0800 Subject: * Simplified the configuration by having [DatabaseService] in it * Fixed configuration issue for HGInventoryServerInConnector * Corrected typos in debug messages --- OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs index cf5d521..a537067 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs @@ -68,7 +68,7 @@ namespace OpenSim.Server.Handlers.Hypergrid } AddHttpHandlers(server); - m_log.Debug("[HG HG INVENTORY HANDLER]: handlers initialized"); + m_log.Debug("[HG INVENTORY HANDLER]: handlers initialized"); } /// -- cgit v1.1 From 35de8e91ecfbb87054599f3d0f5781d041648688 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 31 Jan 2010 17:27:56 -0800 Subject: * Remove unnecessary debug message * Bug fix in UserAgentService, logout --- OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs index a537067..41897eb 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGInventoryServerInConnector.cs @@ -80,7 +80,7 @@ namespace OpenSim.Server.Handlers.Hypergrid /// public override bool CheckAuthSession(string session_id, string avatar_id) { - m_log.InfoFormat("[HG INVENTORY IN CONNECTOR]: checking authed session {0} {1}", session_id, avatar_id); + //m_log.InfoFormat("[HG INVENTORY IN CONNECTOR]: checking authed session {0} {1}", session_id, avatar_id); // This doesn't work // if (m_session_cache.getCachedSession(session_id, avatar_id) == null) -- cgit v1.1 From 29e501d68834ca73e908ce43d8647de86391f7ff Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 6 Feb 2010 19:06:08 -0800 Subject: A little more beef on the xinventory in connector. --- .../Handlers/Inventory/XInventoryInConnector.cs | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index c7d5ff1..ccaf5c4 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -231,6 +231,13 @@ namespace OpenSim.Server.Handlers.Asset { Dictionary result = new Dictionary(); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal); + if (rfolder == null) + return FailureResult(); + + result[rfolder.ID.ToString()] = EncodeFolder(rfolder); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -240,7 +247,15 @@ namespace OpenSim.Server.Handlers.Asset byte[] HandleGetFolderForType(Dictionary request) { Dictionary result = new Dictionary(); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + int type = 0; + Int32.TryParse(request["TYPE"].ToString(), out type); + InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type); + if (folder == null) + return FailureResult(); + result[folder.ID.ToString()] = EncodeFolder(folder); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -250,7 +265,25 @@ namespace OpenSim.Server.Handlers.Asset byte[] HandleGetFolderContent(Dictionary request) { Dictionary result = new Dictionary(); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + UUID folderID = UUID.Zero; + UUID.TryParse(request["FOLDER"].ToString(), out folderID); + InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID); + if (icoll == null) + return FailureResult(); + + Dictionary folders = new Dictionary(); + foreach (InventoryFolderBase f in icoll.Folders) + folders[f.ID.ToString()] = EncodeFolder(f); + result["FOLDERS"] = folders; + + Dictionary items = new Dictionary(); + foreach (InventoryItemBase i in icoll.Items) + items[i.ID.ToString()] = EncodeItem(i); + result["ITEMS"] = folders; + string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -411,6 +444,34 @@ namespace OpenSim.Server.Handlers.Asset return ret; } + private Dictionary EncodeItem(InventoryItemBase item) + { + Dictionary ret = new Dictionary(); + + ret["AssetID"] = item.AssetID.ToString(); + ret["AssetType"] = item.AssetType.ToString(); + ret["BasePermissions"] = item.BasePermissions.ToString(); + ret["CreationDate"] = item.CreationDate.ToString(); + ret["CreatorId"] = item.CreatorId.ToString(); + ret["CurrentPermissions"] = item.CurrentPermissions.ToString(); + ret["Description"] = item.Description.ToString(); + ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString(); + ret["Flags"] = item.Flags.ToString(); + ret["Folder"] = item.Folder.ToString(); + ret["GroupID"] = item.GroupID.ToString(); + ret["GroupedOwned"] = item.GroupOwned.ToString(); + ret["GroupPermissions"] = item.GroupPermissions.ToString(); + ret["ID"] = item.ID.ToString(); + ret["InvType"] = item.InvType.ToString(); + ret["Name"] = item.Name.ToString(); + ret["NextPermissions"] = item.NextPermissions.ToString(); + ret["Owner"] = item.Owner.ToString(); + ret["SalePrice"] = item.SalePrice.ToString(); + ret["SaleType"] = item.SaleType.ToString(); + + return ret; + } + private InventoryFolderBase BuildFolder(Dictionary data) { InventoryFolderBase folder = new InventoryFolderBase(); -- cgit v1.1 From 16f77fa1f1342f2de306c9b4fb7e3c1cd0478c32 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 7 Feb 2010 16:41:41 -0800 Subject: Finished implementing the XInventory connector. Untested. --- .../Handlers/Inventory/XInventoryInConnector.cs | 236 +++++++++++++++------ 1 file changed, 174 insertions(+), 62 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index ccaf5c4..a944972 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -159,6 +159,16 @@ namespace OpenSim.Server.Handlers.Asset private byte[] FailureResult() { + return BoolResult(false); + } + + private byte[] SuccessResult() + { + return BoolResult(true); + } + + private byte[] BoolResult(bool value) + { XmlDocument doc = new XmlDocument(); XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, @@ -172,7 +182,7 @@ namespace OpenSim.Server.Handlers.Asset doc.AppendChild(rootElement); XmlElement result = doc.CreateElement("", "RESULT", ""); - result.AppendChild(doc.CreateTextNode("False")); + result.AppendChild(doc.CreateTextNode(value.ToString())); rootElement.AppendChild(result); @@ -218,8 +228,9 @@ namespace OpenSim.Server.Handlers.Asset List folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString())); - foreach (InventoryFolderBase f in folders) - result[f.ID.ToString()] = EncodeFolder(f); + if (folders != null) + foreach (InventoryFolderBase f in folders) + result[f.ID.ToString()] = EncodeFolder(f); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); @@ -234,10 +245,9 @@ namespace OpenSim.Server.Handlers.Asset UUID principal = UUID.Zero; UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal); - if (rfolder == null) - return FailureResult(); + if (rfolder != null) + result[rfolder.ID.ToString()] = EncodeFolder(rfolder); - result[rfolder.ID.ToString()] = EncodeFolder(rfolder); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -252,10 +262,9 @@ namespace OpenSim.Server.Handlers.Asset int type = 0; Int32.TryParse(request["TYPE"].ToString(), out type); InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type); - if (folder == null) - return FailureResult(); + if (folder != null) + result[folder.ID.ToString()] = EncodeFolder(folder); - result[folder.ID.ToString()] = EncodeFolder(folder); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -271,19 +280,19 @@ namespace OpenSim.Server.Handlers.Asset UUID.TryParse(request["FOLDER"].ToString(), out folderID); InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID); - if (icoll == null) - return FailureResult(); + if (icoll != null) + { + Dictionary folders = new Dictionary(); + foreach (InventoryFolderBase f in icoll.Folders) + folders[f.ID.ToString()] = EncodeFolder(f); + result["FOLDERS"] = folders; - Dictionary folders = new Dictionary(); - foreach (InventoryFolderBase f in icoll.Folders) - folders[f.ID.ToString()] = EncodeFolder(f); - result["FOLDERS"] = folders; + Dictionary items = new Dictionary(); + foreach (InventoryItemBase i in icoll.Items) + items[i.ID.ToString()] = EncodeItem(i); + result["ITEMS"] = items; + } - Dictionary items = new Dictionary(); - foreach (InventoryItemBase i in icoll.Items) - items[i.ID.ToString()] = EncodeItem(i); - result["ITEMS"] = folders; - string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -293,7 +302,16 @@ namespace OpenSim.Server.Handlers.Asset byte[] HandleGetFolderItems(Dictionary request) { Dictionary result = new Dictionary(); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + UUID folderID = UUID.Zero; + UUID.TryParse(request["FOLDER"].ToString(), out folderID); + List items = m_InventoryService.GetFolderItems(principal, folderID); + if (items != null) + foreach (InventoryItemBase item in items) + result[item.ID.ToString()] = EncodeItem(item); + string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); @@ -303,96 +321,169 @@ namespace OpenSim.Server.Handlers.Asset byte[] HandleAddFolder(Dictionary request) { Dictionary result = new Dictionary(); + InventoryFolderBase folder = BuildFolder(request); - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); + if (m_InventoryService.AddFolder(folder)) + return SuccessResult(); + else + return FailureResult(); } byte[] HandleUpdateFolder(Dictionary request) { - Dictionary result = new Dictionary(); + Dictionary result = new Dictionary(); + InventoryFolderBase folder = BuildFolder(request); - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); + if (m_InventoryService.UpdateFolder(folder)) + return SuccessResult(); + else + return FailureResult(); } byte[] HandleMoveFolder(Dictionary request) { - Dictionary result = new Dictionary(); + Dictionary result = new Dictionary(); + UUID parentID = UUID.Zero; + UUID.TryParse(request["ParentID"].ToString(), out parentID); + UUID folderID = UUID.Zero; + UUID.TryParse(request["ID"].ToString(), out folderID); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + + InventoryFolderBase folder = new InventoryFolderBase(folderID, "", principal, parentID); + if (m_InventoryService.MoveFolder(folder)) + return SuccessResult(); + else + return FailureResult(); - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); } byte[] HandleDeleteFolders(Dictionary request) { Dictionary result = new Dictionary(); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + List slist = (List)request["FOLDERS"]; + List uuids = new List(); + foreach (string s in slist) + { + UUID u = UUID.Zero; + if (UUID.TryParse(s, out u)) + uuids.Add(u); + } - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); + if (m_InventoryService.DeleteFolders(principal, uuids)) + return SuccessResult(); + else + return + FailureResult(); } byte[] HandlePurgeFolder(Dictionary request) { Dictionary result = new Dictionary(); + UUID folderID = UUID.Zero; + UUID.TryParse(request["ID"].ToString(), out folderID); - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); + InventoryFolderBase folder = new InventoryFolderBase(folderID); + if (m_InventoryService.PurgeFolder(folder)) + return SuccessResult(); + else + return FailureResult(); } byte[] HandleAddItem(Dictionary request) { - Dictionary result = new Dictionary(); + Dictionary result = new Dictionary(); + InventoryItemBase item = BuildItem(request); - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); + if (m_InventoryService.AddItem(item)) + return SuccessResult(); + else + return FailureResult(); } byte[] HandleUpdateItem(Dictionary request) { - Dictionary result = new Dictionary(); + Dictionary result = new Dictionary(); + InventoryItemBase item = BuildItem(request); - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); + if (m_InventoryService.UpdateItem(item)) + return SuccessResult(); + else + return FailureResult(); } byte[] HandleMoveItems(Dictionary request) { Dictionary result = new Dictionary(); + List idlist = (List)request["IDLIST"]; + List destlist = (List)request["DESTLIST"]; + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); + List items = new List(); + int n = 0; + try + { + foreach (string s in idlist) + { + UUID u = UUID.Zero; + if (UUID.TryParse(s, out u)) + { + UUID fid = UUID.Zero; + if (UUID.TryParse(destlist[n++], out fid)) + { + InventoryItemBase item = new InventoryItemBase(u, principal); + item.Folder = fid; + items.Add(item); + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[XINVENTORY IN CONNECTOR]: Exception in HandleMoveItems: {0}", e.Message); + return FailureResult(); + } + + if (m_InventoryService.MoveItems(principal, items)) + return SuccessResult(); + else + return FailureResult(); } byte[] HandleDeleteItems(Dictionary request) { - Dictionary result = new Dictionary(); + Dictionary result = new Dictionary(); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + List slist = (List)request["ITEMS"]; + List uuids = new List(); + foreach (string s in slist) + { + UUID u = UUID.Zero; + if (UUID.TryParse(s, out u)) + uuids.Add(u); + } - string xmlString = ServerUtils.BuildXmlResponse(result); - m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); - UTF8Encoding encoding = new UTF8Encoding(); - return encoding.GetBytes(xmlString); + if (m_InventoryService.DeleteItems(principal, uuids)) + return SuccessResult(); + else + return + FailureResult(); } byte[] HandleGetItem(Dictionary request) { Dictionary result = new Dictionary(); + UUID id = UUID.Zero; + UUID.TryParse(request["ID"].ToString(), out id); + + InventoryItemBase item = new InventoryItemBase(id); + item = m_InventoryService.GetItem(item); + if (item != null) + result[item.ID.ToString()] = EncodeItem(item); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); @@ -402,7 +493,14 @@ namespace OpenSim.Server.Handlers.Asset byte[] HandleGetFolder(Dictionary request) { - Dictionary result = new Dictionary(); + Dictionary result = new Dictionary(); + UUID id = UUID.Zero; + UUID.TryParse(request["ID"].ToString(), out id); + + InventoryFolderBase folder = new InventoryFolderBase(id); + folder = m_InventoryService.GetFolder(folder); + if (folder != null) + result[folder.ID.ToString()] = EncodeFolder(folder); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); @@ -413,6 +511,13 @@ namespace OpenSim.Server.Handlers.Asset byte[] HandleGetActiveGestures(Dictionary request) { Dictionary result = new Dictionary(); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + + List gestures = m_InventoryService.GetActiveGestures(principal); + if (gestures != null) + foreach (InventoryItemBase item in gestures) + result[item.ID.ToString()] = EncodeItem(item); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); @@ -423,7 +528,14 @@ namespace OpenSim.Server.Handlers.Asset byte[] HandleGetAssetPermissions(Dictionary request) { Dictionary result = new Dictionary(); + UUID principal = UUID.Zero; + UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + UUID assetID = UUID.Zero; + UUID.TryParse(request["ASSET"].ToString(), out assetID); + + int perms = m_InventoryService.GetAssetPermissions(principal, assetID); + result["RESULT"] = perms.ToString(); string xmlString = ServerUtils.BuildXmlResponse(result); m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); -- cgit v1.1 From af265e001d3bf043590e480cd6574a14193f6de0 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 15 Feb 2010 19:15:03 +0900 Subject: Formatting cleanup. --- OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index c7d5ff1..03d4d7a 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -197,7 +197,7 @@ namespace OpenSim.Server.Handlers.Asset if (!request.ContainsKey("PRINCIPAL")) return FailureResult(); - if(m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString()))) + if (m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString()))) result["RESULT"] = "True"; else result["RESULT"] = "False"; -- cgit v1.1 From 845a390e9308f6b6823c85ac319ecb211f968d4b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sat, 20 Feb 2010 16:21:13 -0800 Subject: * Added a sanity check for missing asset data in LLClientView * Moved the SL asset type to content type conversion methods from ServerUtils to OpenSim.Framework.SLUtil * Linked content type to asset type in AssetMetadata --- OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs index fe0da0b..43c1693 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs @@ -91,7 +91,7 @@ namespace OpenSim.Server.Handlers.Asset httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.ContentType = - ServerUtils.SLAssetTypeToContentType(metadata.Type); + SLUtil.SLAssetTypeToContentType(metadata.Type); } else { @@ -111,7 +111,7 @@ namespace OpenSim.Server.Handlers.Asset httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.ContentType = - ServerUtils.SLAssetTypeToContentType(asset.Type); + SLUtil.SLAssetTypeToContentType(asset.Type); } else { -- cgit v1.1 From c745df007d1730e59fbdb4ebf8440654d1675ade Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 25 Feb 2010 17:42:51 -0800 Subject: Added server-side Friends in connector. Untested. --- .../Handlers/Friends/FriendServerConnector.cs | 61 ++++++ .../Handlers/Friends/FriendsServerPostHandler.cs | 238 +++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 OpenSim/Server/Handlers/Friends/FriendServerConnector.cs create mode 100644 OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs b/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs new file mode 100644 index 0000000..074f869 --- /dev/null +++ b/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs @@ -0,0 +1,61 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using Nini.Config; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +namespace OpenSim.Server.Handlers.Friends +{ + public class FriendsServiceConnector : ServiceConnector + { + private IFriendsService m_FriendsService; + private string m_ConfigName = "FriendsService"; + + public FriendsServiceConnector(IConfigSource config, IHttpServer server, string configName) : + base(config, server, configName) + { + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); + + string gridService = serverConfig.GetString("LocalServiceModule", + String.Empty); + + if (gridService == String.Empty) + throw new Exception("No LocalServiceModule in config file"); + + Object[] args = new Object[] { config }; + m_FriendsService = ServerUtils.LoadPlugin(gridService, args); + + server.AddStreamHandler(new FriendsServerPostHandler(m_FriendsService)); + } + } +} diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs new file mode 100644 index 0000000..fa655d2 --- /dev/null +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs @@ -0,0 +1,238 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using Nini.Config; +using log4net; +using System; +using System.Reflection; +using System.IO; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Serialization; +using System.Collections.Generic; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.Friends +{ + public class FriendsServerPostHandler : BaseStreamHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IFriendsService m_FriendsService; + + public FriendsServerPostHandler(IFriendsService service) : + base("POST", "/friends") + { + m_FriendsService = service; + } + + public override byte[] Handle(string path, Stream requestData, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + StreamReader sr = new StreamReader(requestData); + string body = sr.ReadToEnd(); + sr.Close(); + body = body.Trim(); + + //m_log.DebugFormat("[XXX]: query String: {0}", body); + + try + { + Dictionary request = + ServerUtils.ParseQueryString(body); + + if (!request.ContainsKey("METHOD")) + return FailureResult(); + + string method = request["METHOD"].ToString(); + + switch (method) + { + case "getfriends": + return GetFriends(request); + + case "storefriend": + return StoreFriend(request); + + case "deletefriend": + return DeleteFriend(request); + + } + m_log.DebugFormat("[FRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); + } + catch (Exception e) + { + m_log.DebugFormat("[FRIENDS HANDLER]: Exception {0}", e); + } + + return FailureResult(); + + } + + #region Method-specific handlers + + byte[] GetFriends(Dictionary request) + { + UUID principalID = UUID.Zero; + if (request.ContainsKey("PRINCIPALID")) + UUID.TryParse(request["PRINCIPALID"].ToString(), out principalID); + else + m_log.WarnFormat("[FRIENDS HANDLER]: no principalID in request to get friends"); + + FriendInfo[] finfos = m_FriendsService.GetFriends(principalID); + //m_log.DebugFormat("[FRIENDS HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if ((finfos == null) || ((finfos != null) && (finfos.Length == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (FriendInfo finfo in finfos) + { + Dictionary rinfoDict = finfo.ToKeyValuePairs(); + result["friend" + i] = rinfoDict; + i++; + } + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[FRIENDS HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + + } + + byte[] StoreFriend(Dictionary request) + { + FriendInfo friend = new FriendInfo(request); + + bool success = m_FriendsService.StoreFriend(friend.PrincipalID, friend.Friend, friend.TheirFlags); + + if (success) + return SuccessResult(); + else + return FailureResult(); + } + + byte[] DeleteFriend(Dictionary request) + { + UUID principalID = UUID.Zero; + if (request.ContainsKey("PRINCIPALID")) + UUID.TryParse(request["PRINCIPALID"].ToString(), out principalID); + else + m_log.WarnFormat("[FRIENDS HANDLER]: no principalID in request to delete friend"); + string friend = string.Empty; + if (request.ContainsKey("FRIEND")) + friend = request["FRIEND"].ToString(); + + bool success = m_FriendsService.Delete(principalID, friend); + if (success) + return SuccessResult(); + else + return FailureResult(); + } + + #endregion + + #region Misc + + private byte[] SuccessResult() + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + XmlElement result = doc.CreateElement("", "Result", ""); + result.AppendChild(doc.CreateTextNode("Success")); + + rootElement.AppendChild(result); + + return DocToBytes(doc); + } + + private byte[] FailureResult() + { + return FailureResult(String.Empty); + } + + private byte[] FailureResult(string msg) + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + XmlElement result = doc.CreateElement("", "Result", ""); + result.AppendChild(doc.CreateTextNode("Failure")); + + rootElement.AppendChild(result); + + XmlElement message = doc.CreateElement("", "Message", ""); + message.AppendChild(doc.CreateTextNode(msg)); + + rootElement.AppendChild(message); + + return DocToBytes(doc); + } + + private byte[] DocToBytes(XmlDocument doc) + { + MemoryStream ms = new MemoryStream(); + XmlTextWriter xw = new XmlTextWriter(ms, null); + xw.Formatting = Formatting.Indented; + doc.WriteTo(xw); + xw.Flush(); + + return ms.ToArray(); + } + + #endregion + } +} -- cgit v1.1 From 2af7577fab4707f26f4e8c680a263e25b7e415e9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Feb 2010 09:01:59 -0800 Subject: Flags on Store(Friend) are supposed to be MyFlags. --- OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index fa655d2..b168bb3 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs @@ -138,7 +138,7 @@ namespace OpenSim.Server.Handlers.Friends { FriendInfo friend = new FriendInfo(request); - bool success = m_FriendsService.StoreFriend(friend.PrincipalID, friend.Friend, friend.TheirFlags); + bool success = m_FriendsService.StoreFriend(friend.PrincipalID, friend.Friend, friend.MyFlags); if (success) return SuccessResult(); -- cgit v1.1 From bbb43f9bdeda4994653c72fac62f9023d6dbdcdc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Feb 2010 10:35:23 -0800 Subject: Now showing friends online upon grid login. --- OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index d180bbb..4ebf933 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -227,7 +227,10 @@ namespace OpenSim.Server.Handlers.Presence string[] userIDs; if (!request.ContainsKey("uuids")) + { + m_log.DebugFormat("[PRESENCE HANDLER]: GetAgents called without required uuids argument"); return FailureResult(); + } if (!(request["uuids"] is List)) { -- cgit v1.1 From 780ee4f99146a21f6d70bf9be4528a6dc39cfe14 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 1 Mar 2010 23:04:45 +0900 Subject: Fix a few compiler warnings. --- OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 03d4d7a..7e3e68b 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -44,8 +44,6 @@ namespace OpenSim.Server.Handlers.Asset { public class XInventoryInConnector : ServiceConnector { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private IInventoryService m_InventoryService; private string m_ConfigName = "InventoryService"; -- cgit v1.1