diff options
author | Diva Canto | 2010-01-31 11:10:57 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-31 11:10:57 -0800 |
commit | 40d8e91008b7d76ce6b9398484c591eb51c85bdb (patch) | |
tree | 7851807bee519bcae508f77e11107c7ed1e99ae9 /OpenSim/Server/Handlers | |
parent | Added missing file. (diff) | |
download | opensim-SC_OLD-40d8e91008b7d76ce6b9398484c591eb51c85bdb.zip opensim-SC_OLD-40d8e91008b7d76ce6b9398484c591eb51c85bdb.tar.gz opensim-SC_OLD-40d8e91008b7d76ce6b9398484c591eb51c85bdb.tar.bz2 opensim-SC_OLD-40d8e91008b7d76ce6b9398484c591eb51c85bdb.tar.xz |
* Added a few files that were missing in the repo.
* New HGInventoryService which allows restricted access to inventory while outside
Diffstat (limited to 'OpenSim/Server/Handlers')
3 files changed, 290 insertions, 41 deletions
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 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using Nwc.XmlRpc; | ||
36 | using OpenSim.Server.Base; | ||
37 | using OpenSim.Server.Handlers.Inventory; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Server.Handlers.Base; | ||
42 | using OpenMetaverse; | ||
43 | |||
44 | namespace OpenSim.Server.Handlers.Hypergrid | ||
45 | { | ||
46 | public class HGInventoryServiceInConnector : InventoryServiceInConnector | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | //private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs | ||
51 | //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); | ||
52 | |||
53 | private IUserAgentService m_UserAgentService; | ||
54 | |||
55 | public HGInventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) : | ||
56 | base(config, server, configName) | ||
57 | { | ||
58 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
59 | if (serverConfig == null) | ||
60 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); | ||
61 | |||
62 | string userAgentService = serverConfig.GetString("UserAgentService", string.Empty); | ||
63 | string m_userserver_url = serverConfig.GetString("UserAgentURI", String.Empty); | ||
64 | if (m_userserver_url != string.Empty) | ||
65 | { | ||
66 | Object[] args = new Object[] { m_userserver_url }; | ||
67 | m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(userAgentService, args); | ||
68 | } | ||
69 | |||
70 | AddHttpHandlers(server); | ||
71 | m_log.Debug("[HG HG INVENTORY HANDLER]: handlers initialized"); | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | ||
76 | /// that agent. | ||
77 | /// </summary> | ||
78 | /// <param name="session_id"></param> | ||
79 | /// <param name="avatar_id"></param> | ||
80 | /// <returns></returns> | ||
81 | public override bool CheckAuthSession(string session_id, string avatar_id) | ||
82 | { | ||
83 | m_log.InfoFormat("[HG INVENTORY IN CONNECTOR]: checking authed session {0} {1}", session_id, avatar_id); | ||
84 | // This doesn't work | ||
85 | |||
86 | // if (m_session_cache.getCachedSession(session_id, avatar_id) == null) | ||
87 | // { | ||
88 | // //cache miss, ask userserver | ||
89 | // m_UserAgentService.VerifyAgent(session_id, ???); | ||
90 | // } | ||
91 | // else | ||
92 | // { | ||
93 | // // cache hits | ||
94 | // m_log.Info("[HG INVENTORY IN CONNECTOR]: got authed session from cache"); | ||
95 | // return true; | ||
96 | // } | ||
97 | |||
98 | // m_log.Warn("[HG INVENTORY IN CONNECTOR]: unknown session_id, request rejected"); | ||
99 | // return false; | ||
100 | |||
101 | return true; | ||
102 | } | ||
103 | } | ||
104 | } | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Net; | ||
33 | using System.Text; | ||
34 | |||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Server.Handlers.Base; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Server.Handlers.Simulation; | ||
42 | using Utils = OpenSim.Server.Handlers.Simulation.Utils; | ||
43 | |||
44 | using OpenMetaverse; | ||
45 | using OpenMetaverse.StructuredData; | ||
46 | using Nini.Config; | ||
47 | using log4net; | ||
48 | |||
49 | |||
50 | namespace OpenSim.Server.Handlers.Hypergrid | ||
51 | { | ||
52 | public class HomeAgentHandler | ||
53 | { | ||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | private IUserAgentService m_UserAgentService; | ||
56 | |||
57 | public HomeAgentHandler(IUserAgentService userAgentService) | ||
58 | { | ||
59 | m_UserAgentService = userAgentService; | ||
60 | } | ||
61 | |||
62 | public Hashtable Handler(Hashtable request) | ||
63 | { | ||
64 | m_log.Debug("[CONNECTION DEBUGGING]: HomeAgentHandler Called"); | ||
65 | |||
66 | m_log.Debug("---------------------------"); | ||
67 | m_log.Debug(" >> uri=" + request["uri"]); | ||
68 | m_log.Debug(" >> content-type=" + request["content-type"]); | ||
69 | m_log.Debug(" >> http-method=" + request["http-method"]); | ||
70 | m_log.Debug("---------------------------\n"); | ||
71 | |||
72 | Hashtable responsedata = new Hashtable(); | ||
73 | responsedata["content_type"] = "text/html"; | ||
74 | responsedata["keepalive"] = false; | ||
75 | |||
76 | |||
77 | UUID agentID; | ||
78 | UUID regionID; | ||
79 | string action; | ||
80 | if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action)) | ||
81 | { | ||
82 | m_log.InfoFormat("[HOME AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]); | ||
83 | responsedata["int_response_code"] = 404; | ||
84 | responsedata["str_response_string"] = "false"; | ||
85 | |||
86 | return responsedata; | ||
87 | } | ||
88 | |||
89 | // Next, let's parse the verb | ||
90 | string method = (string)request["http-method"]; | ||
91 | if (method.Equals("POST")) | ||
92 | { | ||
93 | DoAgentPost(request, responsedata, agentID); | ||
94 | return responsedata; | ||
95 | } | ||
96 | else | ||
97 | { | ||
98 | m_log.InfoFormat("[HOME AGENT HANDLER]: method {0} not supported in agent message", method); | ||
99 | responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; | ||
100 | responsedata["str_response_string"] = "Method not allowed"; | ||
101 | |||
102 | return responsedata; | ||
103 | } | ||
104 | |||
105 | } | ||
106 | |||
107 | protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) | ||
108 | { | ||
109 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | ||
110 | if (args == null) | ||
111 | { | ||
112 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
113 | responsedata["str_response_string"] = "Bad request"; | ||
114 | return; | ||
115 | } | ||
116 | |||
117 | // retrieve the input arguments | ||
118 | int x = 0, y = 0; | ||
119 | UUID uuid = UUID.Zero; | ||
120 | string regionname = string.Empty; | ||
121 | string gatekeeper_host = string.Empty; | ||
122 | int gatekeeper_port = 0; | ||
123 | |||
124 | if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null) | ||
125 | gatekeeper_host = args["gatekeeper_host"].AsString(); | ||
126 | if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null) | ||
127 | Int32.TryParse(args["gatekeeper_port"].AsString(), out gatekeeper_port); | ||
128 | |||
129 | GridRegion gatekeeper = new GridRegion(); | ||
130 | gatekeeper.ExternalHostName = gatekeeper_host; | ||
131 | gatekeeper.HttpPort = (uint)gatekeeper_port; | ||
132 | gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | ||
133 | |||
134 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
135 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
136 | else | ||
137 | m_log.WarnFormat(" -- request didn't have destination_x"); | ||
138 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
139 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
140 | else | ||
141 | m_log.WarnFormat(" -- request didn't have destination_y"); | ||
142 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
143 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
144 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
145 | regionname = args["destination_name"].ToString(); | ||
146 | |||
147 | GridRegion destination = new GridRegion(); | ||
148 | destination.RegionID = uuid; | ||
149 | destination.RegionLocX = x; | ||
150 | destination.RegionLocY = y; | ||
151 | destination.RegionName = regionname; | ||
152 | |||
153 | AgentCircuitData aCircuit = new AgentCircuitData(); | ||
154 | try | ||
155 | { | ||
156 | aCircuit.UnpackAgentCircuitData(args); | ||
157 | } | ||
158 | catch (Exception ex) | ||
159 | { | ||
160 | m_log.InfoFormat("[HOME AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); | ||
161 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
162 | responsedata["str_response_string"] = "Bad request"; | ||
163 | return; | ||
164 | } | ||
165 | |||
166 | OSDMap resp = new OSDMap(2); | ||
167 | string reason = String.Empty; | ||
168 | |||
169 | bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason); | ||
170 | |||
171 | resp["reason"] = OSD.FromString(reason); | ||
172 | resp["success"] = OSD.FromBoolean(result); | ||
173 | |||
174 | // TODO: add reason if not String.Empty? | ||
175 | responsedata["int_response_code"] = HttpStatusCode.OK; | ||
176 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); | ||
177 | } | ||
178 | |||
179 | } | ||
180 | |||
181 | } | ||
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 | |||
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private IInventoryService m_InventoryService; | 49 | protected IInventoryService m_InventoryService; |
50 | 50 | ||
51 | private bool m_doLookup = false; | 51 | private bool m_doLookup = false; |
52 | 52 | ||
@@ -54,11 +54,12 @@ namespace OpenSim.Server.Handlers.Inventory | |||
54 | //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); | 54 | //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); |
55 | 55 | ||
56 | private string m_userserver_url; | 56 | private string m_userserver_url; |
57 | private string m_ConfigName = "InventoryService"; | 57 | protected string m_ConfigName = "InventoryService"; |
58 | 58 | ||
59 | public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) : | 59 | public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) : |
60 | base(config, server, configName) | 60 | base(config, server, configName) |
61 | { | 61 | { |
62 | m_ConfigName = configName; | ||
62 | IConfig serverConfig = config.Configs[m_ConfigName]; | 63 | IConfig serverConfig = config.Configs[m_ConfigName]; |
63 | if (serverConfig == null) | 64 | if (serverConfig == null) |
64 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); | 65 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); |
@@ -328,46 +329,9 @@ namespace OpenSim.Server.Handlers.Inventory | |||
328 | /// <param name="session_id"></param> | 329 | /// <param name="session_id"></param> |
329 | /// <param name="avatar_id"></param> | 330 | /// <param name="avatar_id"></param> |
330 | /// <returns></returns> | 331 | /// <returns></returns> |
331 | public bool CheckAuthSession(string session_id, string avatar_id) | 332 | public virtual bool CheckAuthSession(string session_id, string avatar_id) |
332 | { | 333 | { |
333 | if (m_doLookup) | 334 | return true; |
334 | { | ||
335 | m_log.InfoFormat("[INVENTORY IN CONNECTOR]: checking authed session {0} {1}", session_id, avatar_id); | ||
336 | |||
337 | //if (m_session_cache.getCachedSession(session_id, avatar_id) == null) | ||
338 | //{ | ||
339 | // cache miss, ask userserver | ||
340 | Hashtable requestData = new Hashtable(); | ||
341 | requestData["avatar_uuid"] = avatar_id; | ||
342 | requestData["session_id"] = session_id; | ||
343 | ArrayList SendParams = new ArrayList(); | ||
344 | SendParams.Add(requestData); | ||
345 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); | ||
346 | XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); | ||
347 | |||
348 | Hashtable responseData = (Hashtable)UserResp.Value; | ||
349 | if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") | ||
350 | { | ||
351 | m_log.Info("[INVENTORY IN CONNECTOR]: got authed session from userserver"); | ||
352 | //// add to cache; the session time will be automatically renewed | ||
353 | //m_session_cache.Add(session_id, avatar_id); | ||
354 | return true; | ||
355 | } | ||
356 | //} | ||
357 | //else | ||
358 | //{ | ||
359 | // // cache hits | ||
360 | // m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache"); | ||
361 | // return true; | ||
362 | //} | ||
363 | |||
364 | m_log.Warn("[INVENTORY IN CONNECTOR]: unknown session_id, request rejected"); | ||
365 | return false; | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | return true; | ||
370 | } | ||
371 | } | 335 | } |
372 | 336 | ||
373 | } | 337 | } |