diff options
Diffstat (limited to 'OpenSim/Server/Handlers')
41 files changed, 1610 insertions, 301 deletions
diff --git a/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServerPostHandler.cs b/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServerPostHandler.cs new file mode 100644 index 0000000..713b755 --- /dev/null +++ b/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServerPostHandler.cs | |||
@@ -0,0 +1,206 @@ | |||
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 Nini.Config; | ||
29 | using log4net; | ||
30 | using System; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Net; | ||
34 | using System.Text; | ||
35 | using System.Text.RegularExpressions; | ||
36 | using System.Xml; | ||
37 | using System.Xml.Serialization; | ||
38 | using System.Collections.Generic; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.ServiceAuth; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | using OpenMetaverse; | ||
45 | |||
46 | namespace OpenSim.Server.Handlers.AgentPreferences | ||
47 | { | ||
48 | public class AgentPreferencesServerPostHandler : BaseStreamHandler | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private IAgentPreferencesService m_AgentPreferencesService; | ||
53 | |||
54 | public AgentPreferencesServerPostHandler(IAgentPreferencesService service, IServiceAuth auth) : | ||
55 | base("POST", "/agentprefs", auth) | ||
56 | { | ||
57 | m_AgentPreferencesService = service; | ||
58 | } | ||
59 | |||
60 | protected override byte[] ProcessRequest(string path, Stream requestData, | ||
61 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
62 | { | ||
63 | StreamReader sr = new StreamReader(requestData); | ||
64 | string body = sr.ReadToEnd(); | ||
65 | sr.Close(); | ||
66 | body = body.Trim(); | ||
67 | |||
68 | //m_log.DebugFormat("[XXX]: query String: {0}", body); | ||
69 | |||
70 | try | ||
71 | { | ||
72 | Dictionary<string, object> request = | ||
73 | ServerUtils.ParseQueryString(body); | ||
74 | |||
75 | if (!request.ContainsKey("METHOD")) | ||
76 | return FailureResult(); | ||
77 | |||
78 | string method = request["METHOD"].ToString(); | ||
79 | |||
80 | switch (method) | ||
81 | { | ||
82 | case "getagentprefs": | ||
83 | return GetAgentPrefs(request); | ||
84 | case "setagentprefs": | ||
85 | return SetAgentPrefs(request); | ||
86 | case "getagentlang": | ||
87 | return GetAgentLang(request); | ||
88 | } | ||
89 | m_log.DebugFormat("[AGENT PREFERENCES HANDLER]: unknown method request: {0}", method); | ||
90 | } | ||
91 | catch (Exception e) | ||
92 | { | ||
93 | m_log.DebugFormat("[AGENT PREFERENCES HANDLER]: Exception {0}", e); | ||
94 | } | ||
95 | |||
96 | return FailureResult(); | ||
97 | } | ||
98 | |||
99 | byte[] GetAgentPrefs(Dictionary<string, object> request) | ||
100 | { | ||
101 | if (!request.ContainsKey("UserID")) | ||
102 | return FailureResult(); | ||
103 | |||
104 | UUID userID; | ||
105 | if (!UUID.TryParse(request["UserID"].ToString(), out userID)) | ||
106 | return FailureResult(); | ||
107 | AgentPrefs prefs = m_AgentPreferencesService.GetAgentPreferences(userID); | ||
108 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
109 | result = prefs.ToKeyValuePairs(); | ||
110 | |||
111 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
112 | |||
113 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
114 | } | ||
115 | |||
116 | byte[] SetAgentPrefs(Dictionary<string, object> request) | ||
117 | { | ||
118 | if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("AccessPrefs") || !request.ContainsKey("HoverHeight") | ||
119 | || !request.ContainsKey("Language") || !request.ContainsKey("LanguageIsPublic") || !request.ContainsKey("PermEveryone") | ||
120 | || !request.ContainsKey("PermGroup") || !request.ContainsKey("PermNextOwner")) | ||
121 | { | ||
122 | return FailureResult(); | ||
123 | } | ||
124 | |||
125 | UUID userID; | ||
126 | if (!UUID.TryParse(request["PrincipalID"].ToString(), out userID)) | ||
127 | return FailureResult(); | ||
128 | |||
129 | AgentPrefs data = new AgentPrefs(userID); | ||
130 | data.AccessPrefs = request["AccessPrefs"].ToString(); | ||
131 | data.HoverHeight = double.Parse(request["HoverHeight"].ToString()); | ||
132 | data.Language = request["Language"].ToString(); | ||
133 | data.LanguageIsPublic = bool.Parse(request["LanguageIsPublic"].ToString()); | ||
134 | data.PermEveryone = int.Parse(request["PermEveryone"].ToString()); | ||
135 | data.PermGroup = int.Parse(request["PermGroup"].ToString()); | ||
136 | data.PermNextOwner = int.Parse(request["PermNextOwner"].ToString()); | ||
137 | |||
138 | return m_AgentPreferencesService.StoreAgentPreferences(data) ? SuccessResult() : FailureResult(); | ||
139 | } | ||
140 | |||
141 | byte[] GetAgentLang(Dictionary<string, object> request) | ||
142 | { | ||
143 | if (!request.ContainsKey("UserID")) | ||
144 | return FailureResult(); | ||
145 | UUID userID; | ||
146 | if (!UUID.TryParse(request["UserID"].ToString(), out userID)) | ||
147 | return FailureResult(); | ||
148 | |||
149 | string lang = "en-us"; | ||
150 | AgentPrefs prefs = m_AgentPreferencesService.GetAgentPreferences(userID); | ||
151 | if (prefs != null) | ||
152 | { | ||
153 | if (prefs.LanguageIsPublic) | ||
154 | lang = prefs.Language; | ||
155 | } | ||
156 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
157 | result["Language"] = lang; | ||
158 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
159 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
160 | } | ||
161 | |||
162 | private byte[] SuccessResult() | ||
163 | { | ||
164 | XmlDocument doc = new XmlDocument(); | ||
165 | |||
166 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
167 | "", ""); | ||
168 | |||
169 | doc.AppendChild(xmlnode); | ||
170 | |||
171 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
172 | ""); | ||
173 | |||
174 | doc.AppendChild(rootElement); | ||
175 | |||
176 | XmlElement result = doc.CreateElement("", "result", ""); | ||
177 | result.AppendChild(doc.CreateTextNode("Success")); | ||
178 | |||
179 | rootElement.AppendChild(result); | ||
180 | |||
181 | return Util.DocToBytes(doc); | ||
182 | } | ||
183 | |||
184 | private byte[] FailureResult() | ||
185 | { | ||
186 | XmlDocument doc = new XmlDocument(); | ||
187 | |||
188 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
189 | "", ""); | ||
190 | |||
191 | doc.AppendChild(xmlnode); | ||
192 | |||
193 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
194 | ""); | ||
195 | |||
196 | doc.AppendChild(rootElement); | ||
197 | |||
198 | XmlElement result = doc.CreateElement("", "result", ""); | ||
199 | result.AppendChild(doc.CreateTextNode("Failure")); | ||
200 | |||
201 | rootElement.AppendChild(result); | ||
202 | |||
203 | return Util.DocToBytes(doc); | ||
204 | } | ||
205 | } | ||
206 | } | ||
diff --git a/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServiceConnector.cs b/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServiceConnector.cs new file mode 100644 index 0000000..a581ea2 --- /dev/null +++ b/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServiceConnector.cs | |||
@@ -0,0 +1,64 @@ | |||
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 | |||
29 | using System; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Server.Base; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | using OpenSim.Framework.ServiceAuth; | ||
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Server.Handlers.Base; | ||
36 | |||
37 | namespace OpenSim.Server.Handlers.AgentPreferences | ||
38 | { | ||
39 | public class AgentPreferencesServiceConnector : ServiceConnector | ||
40 | { | ||
41 | private IAgentPreferencesService m_AgentPreferencesService; | ||
42 | private string m_ConfigName = "AgentPreferencesService"; | ||
43 | |||
44 | public AgentPreferencesServiceConnector(IConfigSource config, IHttpServer server, string configName) : | ||
45 | base(config, server, configName) | ||
46 | { | ||
47 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
48 | if (serverConfig == null) | ||
49 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); | ||
50 | |||
51 | string service = serverConfig.GetString("LocalServiceModule", String.Empty); | ||
52 | |||
53 | if (String.IsNullOrWhiteSpace(service)) | ||
54 | throw new Exception("No LocalServiceModule in config file"); | ||
55 | |||
56 | Object[] args = new Object[] { config }; | ||
57 | m_AgentPreferencesService = ServerUtils.LoadPlugin<IAgentPreferencesService>(service, args); | ||
58 | |||
59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); ; | ||
60 | |||
61 | server.AddStreamHandler(new AgentPreferencesServerPostHandler(m_AgentPreferencesService, auth)); | ||
62 | } | ||
63 | } | ||
64 | } | ||
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index cc4325a..ab81dd6 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.ServiceAuth; | ||
33 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
34 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
35 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
@@ -69,6 +70,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
69 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); | 70 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); |
70 | bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); | 71 | bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); |
71 | 72 | ||
73 | string redirectURL = serverConfig.GetString("RedirectURL", string.Empty); | ||
74 | |||
72 | AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; | 75 | AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; |
73 | 76 | ||
74 | if (!allowDelete) | 77 | if (!allowDelete) |
@@ -83,9 +86,12 @@ namespace OpenSim.Server.Handlers.Asset | |||
83 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; | 86 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; |
84 | } | 87 | } |
85 | 88 | ||
86 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); | 89 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
87 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); | 90 | |
88 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes)); | 91 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth, redirectURL)); |
92 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth)); | ||
93 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes, auth)); | ||
94 | server.AddStreamHandler(new AssetsExistHandler(m_AssetService)); | ||
89 | 95 | ||
90 | MainConsole.Instance.Commands.AddCommand("Assets", false, | 96 | MainConsole.Instance.Commands.AddCommand("Assets", false, |
91 | "show asset", | 97 | "show asset", |
@@ -212,4 +218,4 @@ namespace OpenSim.Server.Handlers.Asset | |||
212 | } | 218 | } |
213 | } | 219 | } |
214 | } | 220 | } |
215 | } \ No newline at end of file | 221 | } |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 941b97d..d85d471 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | |||
@@ -38,6 +38,7 @@ using System.Xml.Serialization; | |||
38 | using OpenSim.Server.Base; | 38 | using OpenSim.Server.Base; |
39 | using OpenSim.Services.Interfaces; | 39 | using OpenSim.Services.Interfaces; |
40 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Framework.ServiceAuth; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
42 | 43 | ||
43 | namespace OpenSim.Server.Handlers.Asset | 44 | namespace OpenSim.Server.Handlers.Asset |
@@ -70,6 +71,12 @@ namespace OpenSim.Server.Handlers.Asset | |||
70 | m_allowedTypes = allowedTypes; | 71 | m_allowedTypes = allowedTypes; |
71 | } | 72 | } |
72 | 73 | ||
74 | public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes, IServiceAuth auth) : | ||
75 | base("DELETE", "/assets", auth) | ||
76 | { | ||
77 | m_AssetService = service; | ||
78 | m_allowedTypes = allowedTypes; | ||
79 | } | ||
73 | protected override byte[] ProcessRequest(string path, Stream request, | 80 | protected override byte[] ProcessRequest(string path, Stream request, |
74 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 81 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
75 | { | 82 | { |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs index 8b23a83..91c5c54 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs | |||
@@ -38,20 +38,31 @@ using System.Xml.Serialization; | |||
38 | using OpenSim.Server.Base; | 38 | using OpenSim.Server.Base; |
39 | using OpenSim.Services.Interfaces; | 39 | using OpenSim.Services.Interfaces; |
40 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Framework.ServiceAuth; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
42 | 43 | ||
43 | namespace OpenSim.Server.Handlers.Asset | 44 | namespace OpenSim.Server.Handlers.Asset |
44 | { | 45 | { |
45 | public class AssetServerGetHandler : BaseStreamHandler | 46 | public class AssetServerGetHandler : BaseStreamHandler |
46 | { | 47 | { |
47 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 49 | ||
49 | private IAssetService m_AssetService; | 50 | private IAssetService m_AssetService; |
51 | private string m_RedirectURL; | ||
50 | 52 | ||
51 | public AssetServerGetHandler(IAssetService service) : | 53 | public AssetServerGetHandler(IAssetService service) : |
52 | base("GET", "/assets") | 54 | base("GET", "/assets") |
53 | { | 55 | { |
56 | m_AssetService = service; | ||
57 | } | ||
58 | |||
59 | public AssetServerGetHandler(IAssetService service, IServiceAuth auth, string redirectURL) : | ||
60 | base("GET", "/assets", auth) | ||
61 | { | ||
54 | m_AssetService = service; | 62 | m_AssetService = service; |
63 | m_RedirectURL = redirectURL; | ||
64 | if (!m_RedirectURL.EndsWith("/")) | ||
65 | m_RedirectURL = m_RedirectURL.TrimEnd('/'); | ||
55 | } | 66 | } |
56 | 67 | ||
57 | protected override byte[] ProcessRequest(string path, Stream request, | 68 | protected override byte[] ProcessRequest(string path, Stream request, |
@@ -64,45 +75,62 @@ namespace OpenSim.Server.Handlers.Asset | |||
64 | if (p.Length == 0) | 75 | if (p.Length == 0) |
65 | return result; | 76 | return result; |
66 | 77 | ||
67 | if (p.Length > 1 && p[1] == "data") | 78 | string id = string.Empty; |
79 | if (p.Length > 1) | ||
68 | { | 80 | { |
69 | result = m_AssetService.GetData(p[0]); | 81 | id = p[0]; |
70 | if (result == null) | 82 | string cmd = p[1]; |
83 | |||
84 | if (cmd == "data") | ||
71 | { | 85 | { |
72 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | 86 | result = m_AssetService.GetData(id); |
73 | httpResponse.ContentType = "text/plain"; | 87 | if (result == null) |
74 | result = new byte[0]; | 88 | { |
89 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
90 | httpResponse.ContentType = "text/plain"; | ||
91 | result = new byte[0]; | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
96 | httpResponse.ContentType = "application/octet-stream"; | ||
97 | } | ||
75 | } | 98 | } |
76 | else | 99 | else if (cmd == "metadata") |
77 | { | 100 | { |
78 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | 101 | AssetMetadata metadata = m_AssetService.GetMetadata(id); |
79 | httpResponse.ContentType = "application/octet-stream"; | ||
80 | } | ||
81 | } | ||
82 | else if (p.Length > 1 && p[1] == "metadata") | ||
83 | { | ||
84 | AssetMetadata metadata = m_AssetService.GetMetadata(p[0]); | ||
85 | 102 | ||
86 | if (metadata != null) | 103 | if (metadata != null) |
87 | { | 104 | { |
88 | XmlSerializer xs = | 105 | XmlSerializer xs = |
89 | new XmlSerializer(typeof(AssetMetadata)); | 106 | new XmlSerializer(typeof(AssetMetadata)); |
90 | result = ServerUtils.SerializeResult(xs, metadata); | 107 | result = ServerUtils.SerializeResult(xs, metadata); |
91 | 108 | ||
92 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | 109 | httpResponse.StatusCode = (int)HttpStatusCode.OK; |
93 | httpResponse.ContentType = | 110 | httpResponse.ContentType = |
94 | SLUtil.SLAssetTypeToContentType(metadata.Type); | 111 | SLUtil.SLAssetTypeToContentType(metadata.Type); |
112 | } | ||
113 | else | ||
114 | { | ||
115 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
116 | httpResponse.ContentType = "text/plain"; | ||
117 | result = new byte[0]; | ||
118 | } | ||
95 | } | 119 | } |
96 | else | 120 | else |
97 | { | 121 | { |
98 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | 122 | // Unknown request |
123 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | ||
99 | httpResponse.ContentType = "text/plain"; | 124 | httpResponse.ContentType = "text/plain"; |
100 | result = new byte[0]; | 125 | result = new byte[0]; |
101 | } | 126 | } |
102 | } | 127 | } |
103 | else | 128 | else if (p.Length == 1) |
104 | { | 129 | { |
105 | AssetBase asset = m_AssetService.Get(p[0]); | 130 | // Get the entire asset (metadata + data) |
131 | |||
132 | id = p[0]; | ||
133 | AssetBase asset = m_AssetService.Get(id); | ||
106 | 134 | ||
107 | if (asset != null) | 135 | if (asset != null) |
108 | { | 136 | { |
@@ -120,6 +148,24 @@ namespace OpenSim.Server.Handlers.Asset | |||
120 | result = new byte[0]; | 148 | result = new byte[0]; |
121 | } | 149 | } |
122 | } | 150 | } |
151 | else | ||
152 | { | ||
153 | // Unknown request | ||
154 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | ||
155 | httpResponse.ContentType = "text/plain"; | ||
156 | result = new byte[0]; | ||
157 | } | ||
158 | |||
159 | if (httpResponse.StatusCode == (int)HttpStatusCode.NotFound && !string.IsNullOrEmpty(m_RedirectURL) && !string.IsNullOrEmpty(id)) | ||
160 | { | ||
161 | httpResponse.StatusCode = (int)HttpStatusCode.Redirect; | ||
162 | string rurl = m_RedirectURL; | ||
163 | if (!path.StartsWith("/")) | ||
164 | rurl += "/"; | ||
165 | rurl += path; | ||
166 | httpResponse.AddHeader("Location", rurl); | ||
167 | m_log.DebugFormat("[ASSET GET HANDLER]: Asset not found, redirecting to {0} ({1})", rurl, httpResponse.StatusCode); | ||
168 | } | ||
123 | return result; | 169 | return result; |
124 | } | 170 | } |
125 | } | 171 | } |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs index 8eebc61..1c706a7 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs | |||
@@ -38,6 +38,7 @@ using System.Xml.Serialization; | |||
38 | using OpenSim.Server.Base; | 38 | using OpenSim.Server.Base; |
39 | using OpenSim.Services.Interfaces; | 39 | using OpenSim.Services.Interfaces; |
40 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Framework.ServiceAuth; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
42 | 43 | ||
43 | namespace OpenSim.Server.Handlers.Asset | 44 | namespace OpenSim.Server.Handlers.Asset |
@@ -54,35 +55,44 @@ namespace OpenSim.Server.Handlers.Asset | |||
54 | m_AssetService = service; | 55 | m_AssetService = service; |
55 | } | 56 | } |
56 | 57 | ||
58 | public AssetServerPostHandler(IAssetService service, IServiceAuth auth) : | ||
59 | base("POST", "/assets", auth) | ||
60 | { | ||
61 | m_AssetService = service; | ||
62 | } | ||
63 | |||
57 | protected override byte[] ProcessRequest(string path, Stream request, | 64 | protected override byte[] ProcessRequest(string path, Stream request, |
58 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 65 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
59 | { | 66 | { |
60 | AssetBase asset; | 67 | AssetBase asset; |
61 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); | 68 | XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); |
62 | 69 | ||
63 | try | 70 | try |
64 | { | 71 | { |
65 | asset = (AssetBase)xs.Deserialize(request); | 72 | asset = (AssetBase)xs.Deserialize(request); |
66 | } | 73 | } |
67 | catch (XmlException) | 74 | catch (Exception) |
68 | { | 75 | { |
69 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | 76 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; |
70 | return null; | 77 | return null; |
71 | } | 78 | } |
72 | 79 | ||
73 | string[] p = SplitParams(path); | 80 | string[] p = SplitParams(path); |
74 | if (p.Length > 1) | 81 | if (p.Length > 0) |
75 | { | 82 | { |
76 | bool result = m_AssetService.UpdateContent(p[1], asset.Data); | 83 | string id = p[0]; |
84 | bool result = m_AssetService.UpdateContent(id, asset.Data); | ||
77 | 85 | ||
78 | xs = new XmlSerializer(typeof(bool)); | 86 | xs = new XmlSerializer(typeof(bool)); |
79 | return ServerUtils.SerializeResult(xs, result); | 87 | return ServerUtils.SerializeResult(xs, result); |
80 | } | 88 | } |
89 | else | ||
90 | { | ||
91 | string id = m_AssetService.Store(asset); | ||
81 | 92 | ||
82 | string id = m_AssetService.Store(asset); | 93 | xs = new XmlSerializer(typeof(string)); |
83 | 94 | return ServerUtils.SerializeResult(xs, id); | |
84 | xs = new XmlSerializer(typeof(string)); | 95 | } |
85 | return ServerUtils.SerializeResult(xs, id); | ||
86 | } | 96 | } |
87 | } | 97 | } |
88 | } | 98 | } |
diff --git a/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs b/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs new file mode 100644 index 0000000..32901b3 --- /dev/null +++ b/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs | |||
@@ -0,0 +1,87 @@ | |||
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 Nini.Config; | ||
29 | using log4net; | ||
30 | using System; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Net; | ||
34 | using System.Text; | ||
35 | using System.Text.RegularExpressions; | ||
36 | using System.Xml; | ||
37 | using System.Xml.Serialization; | ||
38 | using OpenSim.Server.Base; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.ServiceAuth; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenMetaverse; | ||
44 | |||
45 | namespace OpenSim.Server.Handlers.Asset | ||
46 | { | ||
47 | public class AssetsExistHandler : BaseStreamHandler | ||
48 | { | ||
49 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private IAssetService m_AssetService; | ||
52 | |||
53 | public AssetsExistHandler(IAssetService service) : | ||
54 | base("POST", "/get_assets_exist") | ||
55 | { | ||
56 | m_AssetService = service; | ||
57 | } | ||
58 | |||
59 | public AssetsExistHandler(IAssetService service, IServiceAuth auth) : | ||
60 | base("POST", "/get_assets_exist", auth) | ||
61 | { | ||
62 | m_AssetService = service; | ||
63 | } | ||
64 | |||
65 | protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
66 | { | ||
67 | XmlSerializer xs; | ||
68 | |||
69 | string[] ids; | ||
70 | try | ||
71 | { | ||
72 | xs = new XmlSerializer(typeof(string[])); | ||
73 | ids = (string[])xs.Deserialize(request); | ||
74 | } | ||
75 | catch (Exception) | ||
76 | { | ||
77 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | ||
78 | return null; | ||
79 | } | ||
80 | |||
81 | bool[] exist = m_AssetService.AssetsExist(ids); | ||
82 | |||
83 | xs = new XmlSerializer(typeof(bool[])); | ||
84 | return ServerUtils.SerializeResult(xs, exist); | ||
85 | } | ||
86 | } | ||
87 | } | ||
diff --git a/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs b/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs index 427fa16..faa6fb7 100644 --- a/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs +++ b/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs | |||
@@ -39,7 +39,6 @@ using OpenSim.Server.Handlers.Asset; | |||
39 | using OpenSim.Services.AssetService; | 39 | using OpenSim.Services.AssetService; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSim.Tests.Common; | 41 | using OpenSim.Tests.Common; |
42 | using OpenSim.Tests.Common.Mock; | ||
43 | 42 | ||
44 | namespace OpenSim.Server.Handlers.Asset.Test | 43 | namespace OpenSim.Server.Handlers.Asset.Test |
45 | { | 44 | { |
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs index 848a037..c9a8dce 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using OpenSim.Server.Base; | 30 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.ServiceAuth; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Server.Handlers.Base; | 34 | using OpenSim.Server.Handlers.Base; |
34 | 35 | ||
@@ -58,7 +59,9 @@ namespace OpenSim.Server.Handlers.Authentication | |||
58 | Object[] args = new Object[] { config }; | 59 | Object[] args = new Object[] { config }; |
59 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args); | 60 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args); |
60 | 61 | ||
61 | server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService, serverConfig)); | 62 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
63 | |||
64 | server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService, serverConfig, auth)); | ||
62 | } | 65 | } |
63 | } | 66 | } |
64 | } | 67 | } |
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 16e011a..6ee98b3 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs | |||
@@ -39,6 +39,7 @@ using System.Collections.Generic; | |||
39 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Framework.ServiceAuth; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | 43 | using OpenSim.Framework.Servers.HttpServer; |
43 | using OpenMetaverse; | 44 | using OpenMetaverse; |
44 | 45 | ||
@@ -55,10 +56,10 @@ namespace OpenSim.Server.Handlers.Authentication | |||
55 | private bool m_AllowSetPassword = false; | 56 | private bool m_AllowSetPassword = false; |
56 | 57 | ||
57 | public AuthenticationServerPostHandler(IAuthenticationService service) : | 58 | public AuthenticationServerPostHandler(IAuthenticationService service) : |
58 | this(service, null) {} | 59 | this(service, null, null) {} |
59 | 60 | ||
60 | public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config) : | 61 | public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config, IServiceAuth auth) : |
61 | base("POST", "/auth") | 62 | base("POST", "/auth", auth) |
62 | { | 63 | { |
63 | m_AuthenticationService = service; | 64 | m_AuthenticationService = service; |
64 | 65 | ||
@@ -73,6 +74,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
73 | protected override byte[] ProcessRequest(string path, Stream request, | 74 | protected override byte[] ProcessRequest(string path, Stream request, |
74 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 75 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
75 | { | 76 | { |
77 | // m_log.Error("[XXX]: Authenticating..."); | ||
76 | string[] p = SplitParams(path); | 78 | string[] p = SplitParams(path); |
77 | 79 | ||
78 | if (p.Length > 0) | 80 | if (p.Length > 0) |
@@ -207,7 +209,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
207 | 209 | ||
208 | rootElement.AppendChild(result); | 210 | rootElement.AppendChild(result); |
209 | 211 | ||
210 | return DocToBytes(doc); | 212 | return Util.DocToBytes(doc); |
211 | } | 213 | } |
212 | 214 | ||
213 | byte[] GetAuthInfo(UUID principalID) | 215 | byte[] GetAuthInfo(UUID principalID) |
@@ -277,7 +279,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
277 | 279 | ||
278 | rootElement.AppendChild(result); | 280 | rootElement.AppendChild(result); |
279 | 281 | ||
280 | return DocToBytes(doc); | 282 | return Util.DocToBytes(doc); |
281 | } | 283 | } |
282 | 284 | ||
283 | private byte[] SuccessResult(string token) | 285 | private byte[] SuccessResult(string token) |
@@ -304,18 +306,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
304 | 306 | ||
305 | rootElement.AppendChild(t); | 307 | rootElement.AppendChild(t); |
306 | 308 | ||
307 | return DocToBytes(doc); | 309 | return Util.DocToBytes(doc); |
308 | } | ||
309 | |||
310 | private byte[] DocToBytes(XmlDocument doc) | ||
311 | { | ||
312 | MemoryStream ms = new MemoryStream(); | ||
313 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
314 | xw.Formatting = Formatting.Indented; | ||
315 | doc.WriteTo(xw); | ||
316 | xw.Flush(); | ||
317 | |||
318 | return ms.GetBuffer(); | ||
319 | } | 310 | } |
320 | 311 | ||
321 | private byte[] ResultToBytes(Dictionary<string, object> result) | 312 | private byte[] ResultToBytes(Dictionary<string, object> result) |
diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs index 66a26fc..b201dc7 100644 --- a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs | |||
@@ -147,7 +147,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
147 | #endregion | 147 | #endregion |
148 | } | 148 | } |
149 | 149 | ||
150 | public class OpenIdStreamHandler : BaseOutputStreamHandler | 150 | public class OpenIdStreamHandler : BaseOutputStreamHandler, IStreamHandler |
151 | { | 151 | { |
152 | #region HTML | 152 | #region HTML |
153 | 153 | ||
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs index 9a57cd9..1831e84 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using OpenSim.Server.Base; | 30 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.ServiceAuth; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Server.Handlers.Base; | 34 | using OpenSim.Server.Handlers.Base; |
34 | 35 | ||
@@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Avatar | |||
55 | Object[] args = new Object[] { config }; | 56 | Object[] args = new Object[] { config }; |
56 | m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args); | 57 | m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args); |
57 | 58 | ||
58 | server.AddStreamHandler(new AvatarServerPostHandler(m_AvatarService)); | 59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
60 | |||
61 | server.AddStreamHandler(new AvatarServerPostHandler(m_AvatarService, auth)); | ||
59 | } | 62 | } |
60 | } | 63 | } |
61 | } | 64 | } |
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs index d6bbb8f..ff8699f 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs | |||
@@ -39,6 +39,7 @@ using System.Collections.Generic; | |||
39 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Framework.ServiceAuth; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | 43 | using OpenSim.Framework.Servers.HttpServer; |
43 | using OpenMetaverse; | 44 | using OpenMetaverse; |
44 | 45 | ||
@@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.Avatar | |||
50 | 51 | ||
51 | private IAvatarService m_AvatarService; | 52 | private IAvatarService m_AvatarService; |
52 | 53 | ||
53 | public AvatarServerPostHandler(IAvatarService service) : | 54 | public AvatarServerPostHandler(IAvatarService service, IServiceAuth auth) : |
54 | base("POST", "/avatar") | 55 | base("POST", "/avatar", auth) |
55 | { | 56 | { |
56 | m_AvatarService = service; | 57 | m_AvatarService = service; |
57 | } | 58 | } |
@@ -246,7 +247,7 @@ namespace OpenSim.Server.Handlers.Avatar | |||
246 | 247 | ||
247 | rootElement.AppendChild(result); | 248 | rootElement.AppendChild(result); |
248 | 249 | ||
249 | return DocToBytes(doc); | 250 | return Util.DocToBytes(doc); |
250 | } | 251 | } |
251 | 252 | ||
252 | private byte[] FailureResult() | 253 | private byte[] FailureResult() |
@@ -268,18 +269,7 @@ namespace OpenSim.Server.Handlers.Avatar | |||
268 | 269 | ||
269 | rootElement.AppendChild(result); | 270 | rootElement.AppendChild(result); |
270 | 271 | ||
271 | return DocToBytes(doc); | 272 | return Util.DocToBytes(doc); |
272 | } | ||
273 | |||
274 | private byte[] DocToBytes(XmlDocument doc) | ||
275 | { | ||
276 | MemoryStream ms = new MemoryStream(); | ||
277 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
278 | xw.Formatting = Formatting.Indented; | ||
279 | doc.WriteTo(xw); | ||
280 | xw.Flush(); | ||
281 | |||
282 | return ms.ToArray(); | ||
283 | } | 273 | } |
284 | 274 | ||
285 | } | 275 | } |
diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakes.cs b/OpenSim/Server/Handlers/BakedTextures/XBakes.cs new file mode 100644 index 0000000..4e55433 --- /dev/null +++ b/OpenSim/Server/Handlers/BakedTextures/XBakes.cs | |||
@@ -0,0 +1,148 @@ | |||
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.Diagnostics; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Text; | ||
33 | using System.Threading; | ||
34 | using System.Reflection; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Console; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Services.Base; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using Nini.Config; | ||
41 | using log4net; | ||
42 | using OpenMetaverse; | ||
43 | |||
44 | namespace OpenSim.Server.Handlers.BakedTextures | ||
45 | { | ||
46 | public class XBakes : ServiceBase, IBakedTextureService | ||
47 | { | ||
48 | private static readonly ILog m_log = | ||
49 | LogManager.GetLogger( | ||
50 | MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | protected string m_FSBase; | ||
53 | |||
54 | private System.Text.UTF8Encoding utf8encoding = | ||
55 | new System.Text.UTF8Encoding(); | ||
56 | |||
57 | public XBakes(IConfigSource config) : base(config) | ||
58 | { | ||
59 | MainConsole.Instance.Commands.AddCommand("fs", false, | ||
60 | "delete bakes", "delete bakes <ID>", | ||
61 | "Delete agent's baked textures from server", | ||
62 | HandleDeleteBakes); | ||
63 | |||
64 | IConfig assetConfig = config.Configs["BakedTextureService"]; | ||
65 | if (assetConfig == null) | ||
66 | { | ||
67 | throw new Exception("No BakedTextureService configuration"); | ||
68 | } | ||
69 | |||
70 | m_FSBase = assetConfig.GetString("BaseDirectory", String.Empty); | ||
71 | if (m_FSBase == String.Empty) | ||
72 | { | ||
73 | m_log.ErrorFormat("[BAKES]: BaseDirectory not specified"); | ||
74 | throw new Exception("Configuration error"); | ||
75 | } | ||
76 | |||
77 | m_log.Info("[BAKES]: XBakes service enabled"); | ||
78 | } | ||
79 | |||
80 | public string Get(string id) | ||
81 | { | ||
82 | string file = HashToFile(id); | ||
83 | string diskFile = Path.Combine(m_FSBase, file); | ||
84 | |||
85 | if (File.Exists(diskFile)) | ||
86 | { | ||
87 | try | ||
88 | { | ||
89 | byte[] content = File.ReadAllBytes(diskFile); | ||
90 | |||
91 | return utf8encoding.GetString(content); | ||
92 | } | ||
93 | catch | ||
94 | { | ||
95 | } | ||
96 | } | ||
97 | return String.Empty; | ||
98 | } | ||
99 | |||
100 | public void Store(string id, string sdata) | ||
101 | { | ||
102 | string file = HashToFile(id); | ||
103 | string diskFile = Path.Combine(m_FSBase, file); | ||
104 | |||
105 | Directory.CreateDirectory(Path.GetDirectoryName(diskFile)); | ||
106 | |||
107 | File.Delete(diskFile); | ||
108 | |||
109 | byte[] data = utf8encoding.GetBytes(sdata); | ||
110 | |||
111 | using (FileStream fs = File.Create(diskFile)) | ||
112 | fs.Write(data, 0, data.Length); | ||
113 | } | ||
114 | |||
115 | private void HandleDeleteBakes(string module, string[] args) | ||
116 | { | ||
117 | if (args.Length < 3) | ||
118 | { | ||
119 | MainConsole.Instance.Output("Syntax: delete bakes <ID>"); | ||
120 | return; | ||
121 | } | ||
122 | |||
123 | string file = HashToFile(args[2]); | ||
124 | string diskFile = Path.Combine(m_FSBase, file); | ||
125 | |||
126 | if (File.Exists(diskFile)) | ||
127 | { | ||
128 | File.Delete(diskFile); | ||
129 | MainConsole.Instance.Output("Bakes deleted"); | ||
130 | return; | ||
131 | } | ||
132 | MainConsole.Instance.Output("Bakes not found"); | ||
133 | } | ||
134 | |||
135 | public string HashToPath(string hash) | ||
136 | { | ||
137 | return Path.Combine(hash.Substring(0, 2), | ||
138 | Path.Combine(hash.Substring(2, 2), | ||
139 | Path.Combine(hash.Substring(4, 2), | ||
140 | hash.Substring(6, 4)))); | ||
141 | } | ||
142 | |||
143 | public string HashToFile(string hash) | ||
144 | { | ||
145 | return Path.Combine(HashToPath(hash), hash); | ||
146 | } | ||
147 | } | ||
148 | } | ||
diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs new file mode 100644 index 0000000..3c61673 --- /dev/null +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs | |||
@@ -0,0 +1,71 @@ | |||
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 Nini.Config; | ||
29 | using log4net; | ||
30 | using System; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using System.Net; | ||
34 | using System.Text; | ||
35 | using System.Text.RegularExpressions; | ||
36 | using System.Xml; | ||
37 | using System.Xml.Serialization; | ||
38 | using OpenSim.Server.Base; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.ServiceAuth; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | |||
44 | namespace OpenSim.Server.Handlers.BakedTextures | ||
45 | { | ||
46 | public class BakesServerGetHandler : BaseStreamHandler | ||
47 | { | ||
48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private IBakedTextureService m_BakesService; | ||
51 | private System.Text.UTF8Encoding utf8 = | ||
52 | new System.Text.UTF8Encoding(); | ||
53 | |||
54 | public BakesServerGetHandler(IBakedTextureService service, IServiceAuth auth) : | ||
55 | base("GET", "/bakes", auth) | ||
56 | { | ||
57 | m_BakesService = service; | ||
58 | } | ||
59 | |||
60 | protected override byte[] ProcessRequest( | ||
61 | string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
62 | { | ||
63 | string[] p = SplitParams(path); | ||
64 | |||
65 | if (p.Length == 0) | ||
66 | return new byte[0]; | ||
67 | |||
68 | return utf8.GetBytes(m_BakesService.Get(p[0])); | ||
69 | } | ||
70 | } | ||
71 | } | ||
diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs new file mode 100644 index 0000000..4c12967 --- /dev/null +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs | |||
@@ -0,0 +1,69 @@ | |||
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 Nini.Config; | ||
30 | using OpenSim.Server.Base; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | using OpenSim.Framework.ServiceAuth; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | ||
34 | using OpenSim.Server.Handlers.Base; | ||
35 | |||
36 | namespace OpenSim.Server.Handlers.BakedTextures | ||
37 | { | ||
38 | public class XBakesConnector : ServiceConnector | ||
39 | { | ||
40 | private IBakedTextureService m_BakesService; | ||
41 | private string m_ConfigName = "BakedTextureService"; | ||
42 | |||
43 | public XBakesConnector(IConfigSource config, IHttpServer server, string configName) : | ||
44 | base(config, server, configName) | ||
45 | { | ||
46 | if (configName != String.Empty) | ||
47 | m_ConfigName = configName; | ||
48 | |||
49 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
50 | if (serverConfig == null) | ||
51 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); | ||
52 | |||
53 | string assetService = serverConfig.GetString("LocalServiceModule", | ||
54 | String.Empty); | ||
55 | |||
56 | if (assetService == String.Empty) | ||
57 | throw new Exception("No BakedTextureService in config file"); | ||
58 | |||
59 | Object[] args = new Object[] { config }; | ||
60 | m_BakesService = | ||
61 | ServerUtils.LoadPlugin<IBakedTextureService>(assetService, args); | ||
62 | |||
63 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); | ||
64 | |||
65 | server.AddStreamHandler(new BakesServerGetHandler(m_BakesService, auth)); | ||
66 | server.AddStreamHandler(new BakesServerPostHandler(m_BakesService, auth)); | ||
67 | } | ||
68 | } | ||
69 | } | ||
diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs new file mode 100644 index 0000000..502cecf --- /dev/null +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs | |||
@@ -0,0 +1,83 @@ | |||
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 Nini.Config; | ||
29 | using log4net; | ||
30 | using System; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Net; | ||
34 | using System.Text; | ||
35 | using System.Text.RegularExpressions; | ||
36 | using System.Xml; | ||
37 | using System.Xml.Serialization; | ||
38 | using OpenSim.Server.Base; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.ServiceAuth; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | |||
44 | namespace OpenSim.Server.Handlers.BakedTextures | ||
45 | { | ||
46 | public class BakesServerPostHandler : BaseStreamHandler | ||
47 | { | ||
48 | <<<<<<< HEAD:OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs | ||
49 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private IBakedTextureService m_BakesService; | ||
52 | |||
53 | public BakesServerPostHandler(IBakedTextureService service, IServiceAuth auth) : | ||
54 | base("POST", "/bakes", auth) | ||
55 | ======= | ||
56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
57 | |||
58 | public MSSQLAvatarData(string connectionString, string realm) : | ||
59 | base(connectionString, realm, "Avatar") | ||
60 | >>>>>>> avn/ubitvar:OpenSim/Data/MSSQL/MSSQLAvatarData.cs | ||
61 | { | ||
62 | m_BakesService = service; | ||
63 | } | ||
64 | |||
65 | protected override byte[] ProcessRequest( | ||
66 | string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
67 | { | ||
68 | string[] p = SplitParams(path); | ||
69 | |||
70 | if (p.Length == 0) | ||
71 | { | ||
72 | return new byte[0]; | ||
73 | } | ||
74 | |||
75 | StreamReader sr = new StreamReader(request); | ||
76 | |||
77 | m_BakesService.Store(p[0], sr.ReadToEnd()); | ||
78 | sr.Close(); | ||
79 | |||
80 | return new byte[0]; | ||
81 | } | ||
82 | } | ||
83 | } | ||
diff --git a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs new file mode 100644 index 0000000..e0c2810 --- /dev/null +++ b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs | |||
@@ -0,0 +1,343 @@ | |||
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 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Net; | ||
32 | |||
33 | using Nini.Config; | ||
34 | using log4net; | ||
35 | using OpenMetaverse; | ||
36 | |||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.ServiceAuth; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Server.Handlers.Base; | ||
43 | |||
44 | namespace OpenSim.Server.Handlers | ||
45 | { | ||
46 | public class EstateDataRobustConnector : ServiceConnector | ||
47 | { | ||
48 | private string m_ConfigName = "EstateService"; | ||
49 | |||
50 | public EstateDataRobustConnector(IConfigSource config, IHttpServer server, string configName) : | ||
51 | base(config, server, configName) | ||
52 | { | ||
53 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
54 | if (serverConfig == null) | ||
55 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); | ||
56 | |||
57 | string service = serverConfig.GetString("LocalServiceModule", | ||
58 | String.Empty); | ||
59 | |||
60 | if (service == String.Empty) | ||
61 | throw new Exception("No LocalServiceModule in config file"); | ||
62 | |||
63 | Object[] args = new Object[] { config }; | ||
64 | IEstateDataService e_service = ServerUtils.LoadPlugin<IEstateDataService>(service, args); | ||
65 | |||
66 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); ; | ||
67 | |||
68 | server.AddStreamHandler(new EstateServerGetHandler(e_service, auth)); | ||
69 | server.AddStreamHandler(new EstateServerPostHandler(e_service, auth)); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | |||
74 | public class EstateServerGetHandler : BaseStreamHandler | ||
75 | { | ||
76 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
77 | |||
78 | IEstateDataService m_EstateService; | ||
79 | |||
80 | // Possibilities | ||
81 | // /estates/estate/?region=uuid&create=[t|f] | ||
82 | // /estates/estate/?eid=int | ||
83 | // /estates/?name=string | ||
84 | // /estates/?owner=uuid | ||
85 | // /estates/ (all) | ||
86 | // /estates/regions/?eid=int | ||
87 | |||
88 | public EstateServerGetHandler(IEstateDataService service, IServiceAuth auth) : | ||
89 | base("GET", "/estates", auth) | ||
90 | { | ||
91 | m_EstateService = service; | ||
92 | } | ||
93 | |||
94 | protected override byte[] ProcessRequest(string path, Stream request, | ||
95 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
96 | { | ||
97 | Dictionary<string, object> data = null; | ||
98 | |||
99 | string[] p = SplitParams(path); | ||
100 | |||
101 | // /estates/ (all) | ||
102 | // /estates/?name=string | ||
103 | // /estates/?owner=uuid | ||
104 | if (p.Length == 0) | ||
105 | data = GetEstates(httpRequest, httpResponse); | ||
106 | else | ||
107 | { | ||
108 | string resource = p[0]; | ||
109 | |||
110 | // /estates/estate/?region=uuid&create=[t|f] | ||
111 | // /estates/estate/?eid=int | ||
112 | if ("estate".Equals(resource)) | ||
113 | data = GetEstate(httpRequest, httpResponse); | ||
114 | // /estates/regions/?eid=int | ||
115 | else if ("regions".Equals(resource)) | ||
116 | data = GetRegions(httpRequest, httpResponse); | ||
117 | } | ||
118 | |||
119 | if (data == null) | ||
120 | data = new Dictionary<string, object>(); | ||
121 | |||
122 | string xmlString = ServerUtils.BuildXmlResponse(data); | ||
123 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
124 | |||
125 | } | ||
126 | |||
127 | private Dictionary<string, object> GetEstates(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
128 | { | ||
129 | // /estates/ (all) | ||
130 | // /estates/?name=string | ||
131 | // /estates/?owner=uuid | ||
132 | |||
133 | Dictionary<string, object> data = null; | ||
134 | string name = (string)httpRequest.Query["name"]; | ||
135 | string owner = (string)httpRequest.Query["owner"]; | ||
136 | |||
137 | if (!string.IsNullOrEmpty(name) || !string.IsNullOrEmpty(owner)) | ||
138 | { | ||
139 | List<int> estateIDs = null; | ||
140 | if (!string.IsNullOrEmpty(name)) | ||
141 | { | ||
142 | estateIDs = m_EstateService.GetEstates(name); | ||
143 | } | ||
144 | else if (!string.IsNullOrEmpty(owner)) | ||
145 | { | ||
146 | UUID ownerID = UUID.Zero; | ||
147 | if (UUID.TryParse(owner, out ownerID)) | ||
148 | estateIDs = m_EstateService.GetEstatesByOwner(ownerID); | ||
149 | } | ||
150 | |||
151 | if (estateIDs == null || (estateIDs != null && estateIDs.Count == 0)) | ||
152 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
153 | else | ||
154 | { | ||
155 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
156 | httpResponse.ContentType = "text/xml"; | ||
157 | data = new Dictionary<string, object>(); | ||
158 | int i = 0; | ||
159 | foreach (int id in estateIDs) | ||
160 | data["estate" + i++] = id; | ||
161 | } | ||
162 | } | ||
163 | else | ||
164 | { | ||
165 | List<EstateSettings> estates = m_EstateService.LoadEstateSettingsAll(); | ||
166 | if (estates == null || estates.Count == 0) | ||
167 | { | ||
168 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
173 | httpResponse.ContentType = "text/xml"; | ||
174 | data = new Dictionary<string, object>(); | ||
175 | int i = 0; | ||
176 | foreach (EstateSettings es in estates) | ||
177 | data["estate" + i++] = es.ToMap(); | ||
178 | |||
179 | } | ||
180 | } | ||
181 | |||
182 | return data; | ||
183 | } | ||
184 | |||
185 | private Dictionary<string, object> GetEstate(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
186 | { | ||
187 | // /estates/estate/?region=uuid&create=[t|f] | ||
188 | // /estates/estate/?eid=int | ||
189 | Dictionary<string, object> data = null; | ||
190 | string region = (string)httpRequest.Query["region"]; | ||
191 | string eid = (string)httpRequest.Query["eid"]; | ||
192 | |||
193 | EstateSettings estate = null; | ||
194 | |||
195 | if (!string.IsNullOrEmpty(region)) | ||
196 | { | ||
197 | UUID regionID = UUID.Zero; | ||
198 | if (UUID.TryParse(region, out regionID)) | ||
199 | { | ||
200 | string create = (string)httpRequest.Query["create"]; | ||
201 | bool createYN = false; | ||
202 | Boolean.TryParse(create, out createYN); | ||
203 | estate = m_EstateService.LoadEstateSettings(regionID, createYN); | ||
204 | } | ||
205 | } | ||
206 | else if (!string.IsNullOrEmpty(eid)) | ||
207 | { | ||
208 | int id = 0; | ||
209 | if (Int32.TryParse(eid, out id)) | ||
210 | estate = m_EstateService.LoadEstateSettings(id); | ||
211 | } | ||
212 | |||
213 | if (estate != null) | ||
214 | { | ||
215 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
216 | httpResponse.ContentType = "text/xml"; | ||
217 | data = estate.ToMap(); | ||
218 | } | ||
219 | else | ||
220 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
221 | |||
222 | return data; | ||
223 | } | ||
224 | |||
225 | private Dictionary<string, object> GetRegions(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
226 | { | ||
227 | // /estates/regions/?eid=int | ||
228 | Dictionary<string, object> data = null; | ||
229 | string eid = (string)httpRequest.Query["eid"]; | ||
230 | |||
231 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
232 | if (!string.IsNullOrEmpty(eid)) | ||
233 | { | ||
234 | int id = 0; | ||
235 | if (Int32.TryParse(eid, out id)) | ||
236 | { | ||
237 | List<UUID> regions = m_EstateService.GetRegions(id); | ||
238 | if (regions != null && regions.Count > 0) | ||
239 | { | ||
240 | data = new Dictionary<string, object>(); | ||
241 | int i = 0; | ||
242 | foreach (UUID uuid in regions) | ||
243 | data["region" + i++] = uuid.ToString(); | ||
244 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
245 | httpResponse.ContentType = "text/xml"; | ||
246 | } | ||
247 | } | ||
248 | } | ||
249 | |||
250 | return data; | ||
251 | } | ||
252 | } | ||
253 | |||
254 | public class EstateServerPostHandler : BaseStreamHandler | ||
255 | { | ||
256 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
257 | |||
258 | IEstateDataService m_EstateService; | ||
259 | |||
260 | // Possibilities | ||
261 | // /estates/estate/ (post an estate) | ||
262 | // /estates/estate/?eid=int®ion=uuid (link a region to an estate) | ||
263 | |||
264 | public EstateServerPostHandler(IEstateDataService service, IServiceAuth auth) : | ||
265 | base("POST", "/estates", auth) | ||
266 | { | ||
267 | m_EstateService = service; | ||
268 | } | ||
269 | |||
270 | protected override byte[] ProcessRequest(string path, Stream request, | ||
271 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
272 | { | ||
273 | Dictionary<string, object> data = null; | ||
274 | |||
275 | string[] p = SplitParams(path); | ||
276 | |||
277 | if (p.Length > 0) | ||
278 | { | ||
279 | string resource = p[0]; | ||
280 | |||
281 | // /estates/estate/ | ||
282 | // /estates/estate/?eid=int®ion=uuid | ||
283 | if ("estate".Equals(resource)) | ||
284 | { | ||
285 | StreamReader sr = new StreamReader(request); | ||
286 | string body = sr.ReadToEnd(); | ||
287 | sr.Close(); | ||
288 | body = body.Trim(); | ||
289 | |||
290 | Dictionary<string, object> requestData = ServerUtils.ParseQueryString(body); | ||
291 | |||
292 | data = UpdateEstate(requestData, httpRequest, httpResponse); | ||
293 | } | ||
294 | } | ||
295 | |||
296 | if (data == null) | ||
297 | data = new Dictionary<string, object>(); | ||
298 | |||
299 | string xmlString = ServerUtils.BuildXmlResponse(data); | ||
300 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
301 | |||
302 | } | ||
303 | |||
304 | private Dictionary<string, object> UpdateEstate(Dictionary<string, object> requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
305 | { | ||
306 | // /estates/estate/ | ||
307 | // /estates/estate/?eid=int®ion=uuid | ||
308 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
309 | string eid = (string)httpRequest.Query["eid"]; | ||
310 | string region = (string)httpRequest.Query["region"]; | ||
311 | |||
312 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
313 | |||
314 | if (string.IsNullOrEmpty(eid) && string.IsNullOrEmpty(region) && | ||
315 | requestData.ContainsKey("OP") && requestData["OP"] != null && "STORE".Equals(requestData["OP"])) | ||
316 | { | ||
317 | // /estates/estate/ | ||
318 | EstateSettings es = new EstateSettings(requestData); | ||
319 | m_EstateService.StoreEstateSettings(es); | ||
320 | //m_log.DebugFormat("[EstateServerPostHandler]: Store estate {0}", es.ToString()); | ||
321 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
322 | result["Result"] = true; | ||
323 | } | ||
324 | else if (!string.IsNullOrEmpty(region) && !string.IsNullOrEmpty(eid) && | ||
325 | requestData.ContainsKey("OP") && requestData["OP"] != null && "LINK".Equals(requestData["OP"])) | ||
326 | { | ||
327 | int id = 0; | ||
328 | UUID regionID = UUID.Zero; | ||
329 | if (UUID.TryParse(region, out regionID) && Int32.TryParse(eid, out id)) | ||
330 | { | ||
331 | m_log.DebugFormat("[EstateServerPostHandler]: Link region {0} to estate {1}", regionID, id); | ||
332 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
333 | result["Result"] = m_EstateService.LinkRegion(regionID, id); | ||
334 | } | ||
335 | } | ||
336 | else | ||
337 | m_log.WarnFormat("[EstateServerPostHandler]: something wrong with POST request {0}", httpRequest.RawUrl); | ||
338 | |||
339 | return result; | ||
340 | } | ||
341 | |||
342 | } | ||
343 | } | ||
diff --git a/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs b/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs index 5784bdf..b0e6c7d 100644 --- a/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs +++ b/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using OpenSim.Server.Base; | 30 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.ServiceAuth; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Server.Handlers.Base; | 34 | using OpenSim.Server.Handlers.Base; |
34 | 35 | ||
@@ -55,7 +56,8 @@ namespace OpenSim.Server.Handlers.Friends | |||
55 | Object[] args = new Object[] { config }; | 56 | Object[] args = new Object[] { config }; |
56 | m_FriendsService = ServerUtils.LoadPlugin<IFriendsService>(theService, args); | 57 | m_FriendsService = ServerUtils.LoadPlugin<IFriendsService>(theService, args); |
57 | 58 | ||
58 | server.AddStreamHandler(new FriendsServerPostHandler(m_FriendsService)); | 59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
60 | server.AddStreamHandler(new FriendsServerPostHandler(m_FriendsService, auth)); | ||
59 | } | 61 | } |
60 | } | 62 | } |
61 | } | 63 | } |
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index ca0a24c..3aab30b 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Server.Base; | |||
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | 41 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; |
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.ServiceAuth; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | 44 | using OpenSim.Framework.Servers.HttpServer; |
44 | using OpenMetaverse; | 45 | using OpenMetaverse; |
45 | 46 | ||
@@ -51,8 +52,8 @@ namespace OpenSim.Server.Handlers.Friends | |||
51 | 52 | ||
52 | private IFriendsService m_FriendsService; | 53 | private IFriendsService m_FriendsService; |
53 | 54 | ||
54 | public FriendsServerPostHandler(IFriendsService service) : | 55 | public FriendsServerPostHandler(IFriendsService service, IServiceAuth auth) : |
55 | base("POST", "/friends") | 56 | base("POST", "/friends", auth) |
56 | { | 57 | { |
57 | m_FriendsService = service; | 58 | m_FriendsService = service; |
58 | } | 59 | } |
@@ -228,7 +229,7 @@ namespace OpenSim.Server.Handlers.Friends | |||
228 | 229 | ||
229 | rootElement.AppendChild(result); | 230 | rootElement.AppendChild(result); |
230 | 231 | ||
231 | return DocToBytes(doc); | 232 | return Util.DocToBytes(doc); |
232 | } | 233 | } |
233 | 234 | ||
234 | private byte[] FailureResult() | 235 | private byte[] FailureResult() |
@@ -260,18 +261,7 @@ namespace OpenSim.Server.Handlers.Friends | |||
260 | 261 | ||
261 | rootElement.AppendChild(message); | 262 | rootElement.AppendChild(message); |
262 | 263 | ||
263 | return DocToBytes(doc); | 264 | return Util.DocToBytes(doc); |
264 | } | ||
265 | |||
266 | private byte[] DocToBytes(XmlDocument doc) | ||
267 | { | ||
268 | MemoryStream ms = new MemoryStream(); | ||
269 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
270 | xw.Formatting = Formatting.Indented; | ||
271 | doc.WriteTo(xw); | ||
272 | xw.Flush(); | ||
273 | |||
274 | return ms.ToArray(); | ||
275 | } | 265 | } |
276 | 266 | ||
277 | void FromKeyValuePairs(Dictionary<string, object> kvp, out string principalID, out string friend, out int flags) | 267 | void FromKeyValuePairs(Dictionary<string, object> kvp, out string principalID, out string friend, out int flags) |
diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs index 14daf12..6eb6a79 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using OpenSim.Server.Base; | 30 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.ServiceAuth; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Server.Handlers.Base; | 34 | using OpenSim.Server.Handlers.Base; |
34 | 35 | ||
@@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Grid | |||
55 | Object[] args = new Object[] { config }; | 56 | Object[] args = new Object[] { config }; |
56 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | 57 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); |
57 | 58 | ||
58 | server.AddStreamHandler(new GridServerPostHandler(m_GridService)); | 59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
60 | |||
61 | server.AddStreamHandler(new GridServerPostHandler(m_GridService, auth)); | ||
59 | } | 62 | } |
60 | } | 63 | } |
61 | } | 64 | } |
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index c63b409..849fa94 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Server.Base; | |||
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.ServiceAuth; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | 44 | using OpenSim.Framework.Servers.HttpServer; |
44 | using OpenMetaverse; | 45 | using OpenMetaverse; |
45 | 46 | ||
@@ -49,10 +50,14 @@ namespace OpenSim.Server.Handlers.Grid | |||
49 | { | 50 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 52 | ||
53 | #pragma warning disable 414 | ||
54 | private static string LogHeader = "[GRID HANDLER]"; | ||
55 | #pragma warning restore 414 | ||
56 | |||
52 | private IGridService m_GridService; | 57 | private IGridService m_GridService; |
53 | 58 | ||
54 | public GridServerPostHandler(IGridService service) : | 59 | public GridServerPostHandler(IGridService service, IServiceAuth auth) : |
55 | base("POST", "/grid") | 60 | base("POST", "/grid", auth) |
56 | { | 61 | { |
57 | m_GridService = service; | 62 | m_GridService = service; |
58 | } | 63 | } |
@@ -117,6 +122,9 @@ namespace OpenSim.Server.Handlers.Grid | |||
117 | 122 | ||
118 | case "get_region_flags": | 123 | case "get_region_flags": |
119 | return GetRegionFlags(request); | 124 | return GetRegionFlags(request); |
125 | |||
126 | case "get_grid_extra_features": | ||
127 | return GetGridExtraFeatures(request); | ||
120 | } | 128 | } |
121 | 129 | ||
122 | m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method); | 130 | m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method); |
@@ -281,8 +289,8 @@ namespace OpenSim.Server.Handlers.Grid | |||
281 | else | 289 | else |
282 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); | 290 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); |
283 | 291 | ||
292 | // m_log.DebugFormat("{0} GetRegionByPosition: loc=<{1},{2}>", LogHeader, x, y); | ||
284 | GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); | 293 | GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); |
285 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
286 | 294 | ||
287 | Dictionary<string, object> result = new Dictionary<string, object>(); | 295 | Dictionary<string, object> result = new Dictionary<string, object>(); |
288 | if (rinfo == null) | 296 | if (rinfo == null) |
@@ -573,6 +581,22 @@ namespace OpenSim.Server.Handlers.Grid | |||
573 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | 581 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); |
574 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 582 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
575 | } | 583 | } |
584 | |||
585 | byte[] GetGridExtraFeatures(Dictionary<string, object> request) | ||
586 | { | ||
587 | |||
588 | Dictionary<string, object> result = new Dictionary<string, object> (); | ||
589 | Dictionary<string, object> extraFeatures = m_GridService.GetExtraFeatures (); | ||
590 | |||
591 | foreach (string key in extraFeatures.Keys) | ||
592 | { | ||
593 | result [key] = extraFeatures [key]; | ||
594 | } | ||
595 | |||
596 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
597 | |||
598 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
599 | } | ||
576 | 600 | ||
577 | #endregion | 601 | #endregion |
578 | 602 | ||
@@ -597,7 +621,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
597 | 621 | ||
598 | rootElement.AppendChild(result); | 622 | rootElement.AppendChild(result); |
599 | 623 | ||
600 | return DocToBytes(doc); | 624 | return Util.DocToBytes(doc); |
601 | } | 625 | } |
602 | 626 | ||
603 | private byte[] FailureResult() | 627 | private byte[] FailureResult() |
@@ -629,18 +653,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
629 | 653 | ||
630 | rootElement.AppendChild(message); | 654 | rootElement.AppendChild(message); |
631 | 655 | ||
632 | return DocToBytes(doc); | 656 | return Util.DocToBytes(doc); |
633 | } | ||
634 | |||
635 | private byte[] DocToBytes(XmlDocument doc) | ||
636 | { | ||
637 | MemoryStream ms = new MemoryStream(); | ||
638 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
639 | xw.Formatting = Formatting.Indented; | ||
640 | doc.WriteTo(xw); | ||
641 | xw.Flush(); | ||
642 | |||
643 | return ms.ToArray(); | ||
644 | } | 657 | } |
645 | 658 | ||
646 | #endregion | 659 | #endregion |
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs index 66f35e3..1e29378 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using OpenSim.Server.Base; | 30 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.ServiceAuth; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Server.Handlers.Base; | 34 | using OpenSim.Server.Handlers.Base; |
34 | 35 | ||
@@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.GridUser | |||
55 | Object[] args = new Object[] { config }; | 56 | Object[] args = new Object[] { config }; |
56 | m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(service, args); | 57 | m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(service, args); |
57 | 58 | ||
58 | server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService)); | 59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); ; |
60 | |||
61 | server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService, auth)); | ||
59 | } | 62 | } |
60 | } | 63 | } |
61 | } | 64 | } |
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index 9199c68..b63b594 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs | |||
@@ -39,6 +39,7 @@ using System.Collections.Generic; | |||
39 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Framework.ServiceAuth; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | 43 | using OpenSim.Framework.Servers.HttpServer; |
43 | using OpenMetaverse; | 44 | using OpenMetaverse; |
44 | 45 | ||
@@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.GridUser | |||
50 | 51 | ||
51 | private IGridUserService m_GridUserService; | 52 | private IGridUserService m_GridUserService; |
52 | 53 | ||
53 | public GridUserServerPostHandler(IGridUserService service) : | 54 | public GridUserServerPostHandler(IGridUserService service, IServiceAuth auth) : |
54 | base("POST", "/griduser") | 55 | base("POST", "/griduser", auth) |
55 | { | 56 | { |
56 | m_GridUserService = service; | 57 | m_GridUserService = service; |
57 | } | 58 | } |
@@ -281,7 +282,7 @@ namespace OpenSim.Server.Handlers.GridUser | |||
281 | 282 | ||
282 | rootElement.AppendChild(result); | 283 | rootElement.AppendChild(result); |
283 | 284 | ||
284 | return DocToBytes(doc); | 285 | return Util.DocToBytes(doc); |
285 | } | 286 | } |
286 | 287 | ||
287 | private byte[] FailureResult() | 288 | private byte[] FailureResult() |
@@ -303,20 +304,8 @@ namespace OpenSim.Server.Handlers.GridUser | |||
303 | 304 | ||
304 | rootElement.AppendChild(result); | 305 | rootElement.AppendChild(result); |
305 | 306 | ||
306 | return DocToBytes(doc); | 307 | return Util.DocToBytes(doc); |
307 | } | 308 | } |
308 | 309 | ||
309 | private byte[] DocToBytes(XmlDocument doc) | ||
310 | { | ||
311 | MemoryStream ms = new MemoryStream(); | ||
312 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
313 | xw.Formatting = Formatting.Indented; | ||
314 | doc.WriteTo(xw); | ||
315 | xw.Flush(); | ||
316 | |||
317 | return ms.ToArray(); | ||
318 | } | ||
319 | |||
320 | |||
321 | } | 310 | } |
322 | } | 311 | } |
diff --git a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs index adc2fbc..95a0510 100644 --- a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs | |||
@@ -61,9 +61,10 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
61 | m_Proxy = proxy; | 61 | m_Proxy = proxy; |
62 | } | 62 | } |
63 | 63 | ||
64 | protected override bool CreateAgent(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason) | 64 | protected override bool CreateAgent(GridRegion source, GridRegion gatekeeper, GridRegion destination, |
65 | AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason) | ||
65 | { | 66 | { |
66 | return m_GatekeeperService.LoginAgent(aCircuit, destination, out reason); | 67 | return m_GatekeeperService.LoginAgent(source, aCircuit, destination, out reason); |
67 | } | 68 | } |
68 | } | 69 | } |
69 | } | 70 | } |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs index a2bdadb..37b47ed 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs | |||
@@ -335,7 +335,7 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
335 | 335 | ||
336 | rootElement.AppendChild(result); | 336 | rootElement.AppendChild(result); |
337 | 337 | ||
338 | return DocToBytes(doc); | 338 | return Util.DocToBytes(doc); |
339 | } | 339 | } |
340 | 340 | ||
341 | private byte[] SuccessResult(string value) | 341 | private byte[] SuccessResult(string value) |
@@ -362,7 +362,7 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
362 | 362 | ||
363 | rootElement.AppendChild(message); | 363 | rootElement.AppendChild(message); |
364 | 364 | ||
365 | return DocToBytes(doc); | 365 | return Util.DocToBytes(doc); |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
@@ -395,7 +395,7 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
395 | 395 | ||
396 | rootElement.AppendChild(message); | 396 | rootElement.AppendChild(message); |
397 | 397 | ||
398 | return DocToBytes(doc); | 398 | return Util.DocToBytes(doc); |
399 | } | 399 | } |
400 | 400 | ||
401 | private byte[] BoolResult(bool value) | 401 | private byte[] BoolResult(bool value) |
@@ -417,21 +417,9 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
417 | 417 | ||
418 | rootElement.AppendChild(result); | 418 | rootElement.AppendChild(result); |
419 | 419 | ||
420 | return DocToBytes(doc); | 420 | return Util.DocToBytes(doc); |
421 | } | 421 | } |
422 | 422 | ||
423 | private byte[] DocToBytes(XmlDocument doc) | ||
424 | { | ||
425 | MemoryStream ms = new MemoryStream(); | ||
426 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
427 | xw.Formatting = Formatting.Indented; | ||
428 | doc.WriteTo(xw); | ||
429 | xw.Flush(); | ||
430 | |||
431 | return ms.ToArray(); | ||
432 | } | ||
433 | |||
434 | |||
435 | #endregion | 423 | #endregion |
436 | } | 424 | } |
437 | } | 425 | } |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs index 06eaf2e..dac4ca8 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs | |||
@@ -44,7 +44,9 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
44 | public HeloServiceInConnector(IConfigSource config, IHttpServer server, string configName) : | 44 | public HeloServiceInConnector(IConfigSource config, IHttpServer server, string configName) : |
45 | base(config, server, configName) | 45 | base(config, server, configName) |
46 | { | 46 | { |
47 | #pragma warning disable 0612 | ||
47 | server.AddStreamHandler(new HeloServerGetHandler("opensim-robust")); | 48 | server.AddStreamHandler(new HeloServerGetHandler("opensim-robust")); |
49 | #pragma warning restore 0612 | ||
48 | server.AddStreamHandler(new HeloServerHeadHandler("opensim-robust")); | 50 | server.AddStreamHandler(new HeloServerHeadHandler("opensim-robust")); |
49 | } | 51 | } |
50 | } | 52 | } |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs index 04bb9e8..e787f7c 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs | |||
@@ -117,9 +117,10 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | protected override bool CreateAgent(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason) | 120 | protected override bool CreateAgent(GridRegion source, GridRegion gatekeeper, GridRegion destination, |
121 | AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason) | ||
121 | { | 122 | { |
122 | return m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, fromLogin, out reason); | 123 | return m_UserAgentService.LoginAgentToGrid(source, aCircuit, gatekeeper, destination, fromLogin, out reason); |
123 | } | 124 | } |
124 | 125 | ||
125 | } | 126 | } |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index 5d03097..c7ac9be 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -94,22 +94,38 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
94 | UUID regionID = UUID.Zero; | 94 | UUID regionID = UUID.Zero; |
95 | UUID.TryParse(regionID_str, out regionID); | 95 | UUID.TryParse(regionID_str, out regionID); |
96 | 96 | ||
97 | GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID); | 97 | UUID agentID = UUID.Zero; |
98 | string agentHomeURI = null; | ||
99 | if (requestData.ContainsKey("agent_id")) | ||
100 | agentID = UUID.Parse((string)requestData["agent_id"]); | ||
101 | if (requestData.ContainsKey("agent_home_uri")) | ||
102 | agentHomeURI = (string)requestData["agent_home_uri"]; | ||
103 | |||
104 | string message; | ||
105 | GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID, agentID, agentHomeURI, out message); | ||
98 | 106 | ||
99 | Hashtable hash = new Hashtable(); | 107 | Hashtable hash = new Hashtable(); |
100 | if (regInfo == null) | 108 | if (regInfo == null) |
109 | { | ||
101 | hash["result"] = "false"; | 110 | hash["result"] = "false"; |
111 | } | ||
102 | else | 112 | else |
103 | { | 113 | { |
104 | hash["result"] = "true"; | 114 | hash["result"] = "true"; |
105 | hash["uuid"] = regInfo.RegionID.ToString(); | 115 | hash["uuid"] = regInfo.RegionID.ToString(); |
106 | hash["x"] = regInfo.RegionLocX.ToString(); | 116 | hash["x"] = regInfo.RegionLocX.ToString(); |
107 | hash["y"] = regInfo.RegionLocY.ToString(); | 117 | hash["y"] = regInfo.RegionLocY.ToString(); |
118 | hash["size_x"] = regInfo.RegionSizeX.ToString(); | ||
119 | hash["size_y"] = regInfo.RegionSizeY.ToString(); | ||
108 | hash["region_name"] = regInfo.RegionName; | 120 | hash["region_name"] = regInfo.RegionName; |
109 | hash["hostname"] = regInfo.ExternalHostName; | 121 | hash["hostname"] = regInfo.ExternalHostName; |
110 | hash["http_port"] = regInfo.HttpPort.ToString(); | 122 | hash["http_port"] = regInfo.HttpPort.ToString(); |
111 | hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); | 123 | hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); |
112 | } | 124 | } |
125 | |||
126 | if (message != null) | ||
127 | hash["message"] = message; | ||
128 | |||
113 | XmlRpcResponse response = new XmlRpcResponse(); | 129 | XmlRpcResponse response = new XmlRpcResponse(); |
114 | response.Value = hash; | 130 | response.Value = hash; |
115 | return response; | 131 | return response; |
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs index 7137836..e112e0e 100644 --- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs | |||
@@ -99,8 +99,10 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
99 | server.AddXmlRPCHandler("verify_client", VerifyClient, false); | 99 | server.AddXmlRPCHandler("verify_client", VerifyClient, false); |
100 | server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); | 100 | server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); |
101 | 101 | ||
102 | #pragma warning disable 0612 | ||
102 | server.AddXmlRPCHandler("status_notification", StatusNotification, false); | 103 | server.AddXmlRPCHandler("status_notification", StatusNotification, false); |
103 | server.AddXmlRPCHandler("get_online_friends", GetOnlineFriends, false); | 104 | server.AddXmlRPCHandler("get_online_friends", GetOnlineFriends, false); |
105 | #pragma warning restore 0612 | ||
104 | server.AddXmlRPCHandler("get_user_info", GetUserInfo, false); | 106 | server.AddXmlRPCHandler("get_user_info", GetUserInfo, false); |
105 | server.AddXmlRPCHandler("get_server_urls", GetServerURLs, false); | 107 | server.AddXmlRPCHandler("get_server_urls", GetServerURLs, false); |
106 | 108 | ||
@@ -132,6 +134,8 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
132 | hash["uuid"] = regInfo.RegionID.ToString(); | 134 | hash["uuid"] = regInfo.RegionID.ToString(); |
133 | hash["x"] = regInfo.RegionLocX.ToString(); | 135 | hash["x"] = regInfo.RegionLocX.ToString(); |
134 | hash["y"] = regInfo.RegionLocY.ToString(); | 136 | hash["y"] = regInfo.RegionLocY.ToString(); |
137 | hash["size_x"] = regInfo.RegionSizeX.ToString(); | ||
138 | hash["size_y"] = regInfo.RegionSizeY.ToString(); | ||
135 | hash["region_name"] = regInfo.RegionName; | 139 | hash["region_name"] = regInfo.RegionName; |
136 | hash["hostname"] = regInfo.ExternalHostName; | 140 | hash["hostname"] = regInfo.ExternalHostName; |
137 | hash["http_port"] = regInfo.HttpPort.ToString(); | 141 | hash["http_port"] = regInfo.HttpPort.ToString(); |
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index 1d422a7..b295446 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs | |||
@@ -86,10 +86,6 @@ namespace OpenSim.Server.Handlers.Inventory | |||
86 | protected virtual void AddHttpHandlers(IHttpServer m_httpServer) | 86 | protected virtual void AddHttpHandlers(IHttpServer m_httpServer) |
87 | { | 87 | { |
88 | m_httpServer.AddStreamHandler( | 88 | m_httpServer.AddStreamHandler( |
89 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | ||
90 | "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); | ||
91 | |||
92 | m_httpServer.AddStreamHandler( | ||
93 | new RestDeserialiseSecureHandler<Guid, List<InventoryFolderBase>>( | 89 | new RestDeserialiseSecureHandler<Guid, List<InventoryFolderBase>>( |
94 | "POST", "/SystemFolders/", GetSystemFolders, CheckAuthSession)); | 90 | "POST", "/SystemFolders/", GetSystemFolders, CheckAuthSession)); |
95 | 91 | ||
@@ -178,12 +174,6 @@ namespace OpenSim.Server.Handlers.Inventory | |||
178 | 174 | ||
179 | #region Wrappers for converting the Guid parameter | 175 | #region Wrappers for converting the Guid parameter |
180 | 176 | ||
181 | public InventoryCollection GetUserInventory(Guid guid) | ||
182 | { | ||
183 | UUID userID = new UUID(guid); | ||
184 | return m_InventoryService.GetUserInventory(userID); | ||
185 | } | ||
186 | |||
187 | public List<InventoryFolderBase> GetSystemFolders(Guid guid) | 177 | public List<InventoryFolderBase> GetSystemFolders(Guid guid) |
188 | { | 178 | { |
189 | UUID userID = new UUID(guid); | 179 | UUID userID = new UUID(guid); |
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 0d7c136..5c4e7a9 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -33,6 +33,7 @@ using System.Collections.Generic; | |||
33 | using System.IO; | 33 | using System.IO; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.ServiceAuth; | ||
36 | using OpenSim.Server.Base; | 37 | using OpenSim.Server.Base; |
37 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
38 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
@@ -40,7 +41,9 @@ using OpenSim.Server.Handlers.Base; | |||
40 | using log4net; | 41 | using log4net; |
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
42 | 43 | ||
43 | namespace OpenSim.Server.Handlers.Asset | 44 | using System.Threading; |
45 | |||
46 | namespace OpenSim.Server.Handlers.Inventory | ||
44 | { | 47 | { |
45 | public class XInventoryInConnector : ServiceConnector | 48 | public class XInventoryInConnector : ServiceConnector |
46 | { | 49 | { |
@@ -71,7 +74,9 @@ namespace OpenSim.Server.Handlers.Asset | |||
71 | m_InventoryService = | 74 | m_InventoryService = |
72 | ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args); | 75 | ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args); |
73 | 76 | ||
74 | server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService)); | 77 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
78 | |||
79 | server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService, auth)); | ||
75 | } | 80 | } |
76 | } | 81 | } |
77 | 82 | ||
@@ -81,8 +86,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
81 | 86 | ||
82 | private IInventoryService m_InventoryService; | 87 | private IInventoryService m_InventoryService; |
83 | 88 | ||
84 | public XInventoryConnectorPostHandler(IInventoryService service) : | 89 | public XInventoryConnectorPostHandler(IInventoryService service, IServiceAuth auth) : |
85 | base("POST", "/xinventory") | 90 | base("POST", "/xinventory", auth) |
86 | { | 91 | { |
87 | m_InventoryService = service; | 92 | m_InventoryService = service; |
88 | } | 93 | } |
@@ -114,14 +119,14 @@ namespace OpenSim.Server.Handlers.Asset | |||
114 | return HandleCreateUserInventory(request); | 119 | return HandleCreateUserInventory(request); |
115 | case "GETINVENTORYSKELETON": | 120 | case "GETINVENTORYSKELETON": |
116 | return HandleGetInventorySkeleton(request); | 121 | return HandleGetInventorySkeleton(request); |
117 | case "GETUSERINVENTORY": | ||
118 | return HandleGetUserInventory(request); | ||
119 | case "GETROOTFOLDER": | 122 | case "GETROOTFOLDER": |
120 | return HandleGetRootFolder(request); | 123 | return HandleGetRootFolder(request); |
121 | case "GETFOLDERFORTYPE": | 124 | case "GETFOLDERFORTYPE": |
122 | return HandleGetFolderForType(request); | 125 | return HandleGetFolderForType(request); |
123 | case "GETFOLDERCONTENT": | 126 | case "GETFOLDERCONTENT": |
124 | return HandleGetFolderContent(request); | 127 | return HandleGetFolderContent(request); |
128 | case "GETMULTIPLEFOLDERSCONTENT": | ||
129 | return HandleGetMultipleFoldersContent(request); | ||
125 | case "GETFOLDERITEMS": | 130 | case "GETFOLDERITEMS": |
126 | return HandleGetFolderItems(request); | 131 | return HandleGetFolderItems(request); |
127 | case "ADDFOLDER": | 132 | case "ADDFOLDER": |
@@ -144,6 +149,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
144 | return HandleDeleteItems(request); | 149 | return HandleDeleteItems(request); |
145 | case "GETITEM": | 150 | case "GETITEM": |
146 | return HandleGetItem(request); | 151 | return HandleGetItem(request); |
152 | case "GETMULTIPLEITEMS": | ||
153 | return HandleGetMultipleItems(request); | ||
147 | case "GETFOLDER": | 154 | case "GETFOLDER": |
148 | return HandleGetFolder(request); | 155 | return HandleGetFolder(request); |
149 | case "GETACTIVEGESTURES": | 156 | case "GETACTIVEGESTURES": |
@@ -155,7 +162,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
155 | } | 162 | } |
156 | catch (Exception e) | 163 | catch (Exception e) |
157 | { | 164 | { |
158 | m_log.ErrorFormat("[XINVENTORY HANDLER]: Exception {0}", e.StackTrace); | 165 | m_log.Error(string.Format("[XINVENTORY HANDLER]: Exception {0} ", e.Message), e); |
159 | } | 166 | } |
160 | 167 | ||
161 | return FailureResult(); | 168 | return FailureResult(); |
@@ -190,18 +197,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
190 | 197 | ||
191 | rootElement.AppendChild(result); | 198 | rootElement.AppendChild(result); |
192 | 199 | ||
193 | return DocToBytes(doc); | 200 | return Util.DocToBytes(doc); |
194 | } | ||
195 | |||
196 | private byte[] DocToBytes(XmlDocument doc) | ||
197 | { | ||
198 | MemoryStream ms = new MemoryStream(); | ||
199 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
200 | xw.Formatting = Formatting.Indented; | ||
201 | doc.WriteTo(xw); | ||
202 | xw.Flush(); | ||
203 | |||
204 | return ms.ToArray(); | ||
205 | } | 201 | } |
206 | 202 | ||
207 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) | 203 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) |
@@ -250,45 +246,6 @@ namespace OpenSim.Server.Handlers.Asset | |||
250 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 246 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
251 | } | 247 | } |
252 | 248 | ||
253 | byte[] HandleGetUserInventory(Dictionary<string, object> request) | ||
254 | { | ||
255 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
256 | UUID principal = UUID.Zero; | ||
257 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
258 | |||
259 | InventoryCollection icoll = m_InventoryService.GetUserInventory(principal); | ||
260 | if (icoll != null) | ||
261 | { | ||
262 | Dictionary<string, object> folders = new Dictionary<string, object>(); | ||
263 | int i = 0; | ||
264 | if (icoll.Folders != null) | ||
265 | { | ||
266 | foreach (InventoryFolderBase f in icoll.Folders) | ||
267 | { | ||
268 | folders["folder_" + i.ToString()] = EncodeFolder(f); | ||
269 | i++; | ||
270 | } | ||
271 | result["FOLDERS"] = folders; | ||
272 | } | ||
273 | if (icoll.Items != null) | ||
274 | { | ||
275 | i = 0; | ||
276 | Dictionary<string, object> items = new Dictionary<string, object>(); | ||
277 | foreach (InventoryItemBase it in icoll.Items) | ||
278 | { | ||
279 | items["item_" + i.ToString()] = EncodeItem(it); | ||
280 | i++; | ||
281 | } | ||
282 | result["ITEMS"] = items; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
287 | |||
288 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
289 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
290 | } | ||
291 | |||
292 | byte[] HandleGetRootFolder(Dictionary<string,object> request) | 249 | byte[] HandleGetRootFolder(Dictionary<string,object> request) |
293 | { | 250 | { |
294 | Dictionary<string,object> result = new Dictionary<string,object>(); | 251 | Dictionary<string,object> result = new Dictionary<string,object>(); |
@@ -312,7 +269,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
312 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | 269 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); |
313 | int type = 0; | 270 | int type = 0; |
314 | Int32.TryParse(request["TYPE"].ToString(), out type); | 271 | Int32.TryParse(request["TYPE"].ToString(), out type); |
315 | InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type); | 272 | InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (FolderType)type); |
316 | if (folder != null) | 273 | if (folder != null) |
317 | result["folder"] = EncodeFolder(folder); | 274 | result["folder"] = EncodeFolder(folder); |
318 | 275 | ||
@@ -333,6 +290,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
333 | InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID); | 290 | InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID); |
334 | if (icoll != null) | 291 | if (icoll != null) |
335 | { | 292 | { |
293 | result["FID"] = icoll.FolderID.ToString(); | ||
294 | result["VERSION"] = icoll.Version.ToString(); | ||
336 | Dictionary<string, object> folders = new Dictionary<string, object>(); | 295 | Dictionary<string, object> folders = new Dictionary<string, object>(); |
337 | int i = 0; | 296 | int i = 0; |
338 | if (icoll.Folders != null) | 297 | if (icoll.Folders != null) |
@@ -363,7 +322,71 @@ namespace OpenSim.Server.Handlers.Asset | |||
363 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 322 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
364 | } | 323 | } |
365 | 324 | ||
366 | byte[] HandleGetFolderItems(Dictionary<string,object> request) | 325 | byte[] HandleGetMultipleFoldersContent(Dictionary<string, object> request) |
326 | { | ||
327 | Dictionary<string, object> resultSet = new Dictionary<string, object>(); | ||
328 | UUID principal = UUID.Zero; | ||
329 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
330 | string folderIDstr = request["FOLDERS"].ToString(); | ||
331 | int count = 0; | ||
332 | Int32.TryParse(request["COUNT"].ToString(), out count); | ||
333 | |||
334 | UUID[] fids = new UUID[count]; | ||
335 | string[] uuids = folderIDstr.Split(','); | ||
336 | int i = 0; | ||
337 | foreach (string id in uuids) | ||
338 | { | ||
339 | UUID fid = UUID.Zero; | ||
340 | if (UUID.TryParse(id, out fid)) | ||
341 | fids[i] = fid; | ||
342 | i += 1; | ||
343 | } | ||
344 | |||
345 | count = 0; | ||
346 | InventoryCollection[] icollList = m_InventoryService.GetMultipleFoldersContent(principal, fids); | ||
347 | if (icollList != null && icollList.Length > 0) | ||
348 | { | ||
349 | foreach (InventoryCollection icoll in icollList) | ||
350 | { | ||
351 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
352 | result["FID"] = icoll.FolderID.ToString(); | ||
353 | result["VERSION"] = icoll.Version.ToString(); | ||
354 | result["OWNER"] = icoll.OwnerID.ToString(); | ||
355 | Dictionary<string, object> folders = new Dictionary<string, object>(); | ||
356 | i = 0; | ||
357 | if (icoll.Folders != null) | ||
358 | { | ||
359 | foreach (InventoryFolderBase f in icoll.Folders) | ||
360 | { | ||
361 | folders["folder_" + i.ToString()] = EncodeFolder(f); | ||
362 | i++; | ||
363 | } | ||
364 | result["FOLDERS"] = folders; | ||
365 | } | ||
366 | i = 0; | ||
367 | if (icoll.Items != null) | ||
368 | { | ||
369 | Dictionary<string, object> items = new Dictionary<string, object>(); | ||
370 | foreach (InventoryItemBase it in icoll.Items) | ||
371 | { | ||
372 | items["item_" + i.ToString()] = EncodeItem(it); | ||
373 | i++; | ||
374 | } | ||
375 | result["ITEMS"] = items; | ||
376 | } | ||
377 | |||
378 | resultSet["F_" + fids[count++]] = result; | ||
379 | //m_log.DebugFormat("[XXX]: Sending {0} {1}", fids[count-1], icoll.FolderID); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | string xmlString = ServerUtils.BuildXmlResponse(resultSet); | ||
384 | |||
385 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
386 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
387 | } | ||
388 | |||
389 | byte[] HandleGetFolderItems(Dictionary<string, object> request) | ||
367 | { | 390 | { |
368 | Dictionary<string,object> result = new Dictionary<string,object>(); | 391 | Dictionary<string,object> result = new Dictionary<string,object>(); |
369 | UUID principal = UUID.Zero; | 392 | UUID principal = UUID.Zero; |
@@ -555,6 +578,40 @@ namespace OpenSim.Server.Handlers.Asset | |||
555 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 578 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
556 | } | 579 | } |
557 | 580 | ||
581 | byte[] HandleGetMultipleItems(Dictionary<string, object> request) | ||
582 | { | ||
583 | Dictionary<string, object> resultSet = new Dictionary<string, object>(); | ||
584 | UUID principal = UUID.Zero; | ||
585 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
586 | string itemIDstr = request["ITEMS"].ToString(); | ||
587 | int count = 0; | ||
588 | Int32.TryParse(request["COUNT"].ToString(), out count); | ||
589 | |||
590 | UUID[] fids = new UUID[count]; | ||
591 | string[] uuids = itemIDstr.Split(','); | ||
592 | int i = 0; | ||
593 | foreach (string id in uuids) | ||
594 | { | ||
595 | UUID fid = UUID.Zero; | ||
596 | if (UUID.TryParse(id, out fid)) | ||
597 | fids[i] = fid; | ||
598 | i += 1; | ||
599 | } | ||
600 | |||
601 | InventoryItemBase[] itemsList = m_InventoryService.GetMultipleItems(principal, fids); | ||
602 | if (itemsList != null && itemsList.Length > 0) | ||
603 | { | ||
604 | count = 0; | ||
605 | foreach (InventoryItemBase item in itemsList) | ||
606 | resultSet["item_" + count++] = (item == null) ? (object)"NULL" : EncodeItem(item); | ||
607 | } | ||
608 | |||
609 | string xmlString = ServerUtils.BuildXmlResponse(resultSet); | ||
610 | |||
611 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
612 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
613 | } | ||
614 | |||
558 | byte[] HandleGetFolder(Dictionary<string,object> request) | 615 | byte[] HandleGetFolder(Dictionary<string,object> request) |
559 | { | 616 | { |
560 | Dictionary<string, object> result = new Dictionary<string, object>(); | 617 | Dictionary<string, object> result = new Dictionary<string, object>(); |
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index ea68114..083a628 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | |||
@@ -38,6 +38,7 @@ using OpenMetaverse; | |||
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSim.Framework.ServiceAuth; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
42 | using OpenSim.Server.Handlers.Base; | 43 | using OpenSim.Server.Handlers.Base; |
43 | 44 | ||
@@ -79,7 +80,8 @@ namespace OpenSim.Server.Handlers.MapImage | |||
79 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); | 80 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); |
80 | 81 | ||
81 | bool proxy = serverConfig.GetBoolean("HasProxy", false); | 82 | bool proxy = serverConfig.GetBoolean("HasProxy", false); |
82 | server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy)); | 83 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
84 | server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy, auth)); | ||
83 | 85 | ||
84 | } | 86 | } |
85 | } | 87 | } |
@@ -91,8 +93,8 @@ namespace OpenSim.Server.Handlers.MapImage | |||
91 | private IGridService m_GridService; | 93 | private IGridService m_GridService; |
92 | bool m_Proxy; | 94 | bool m_Proxy; |
93 | 95 | ||
94 | public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy) : | 96 | public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy, IServiceAuth auth) : |
95 | base("POST", "/map") | 97 | base("POST", "/map", auth) |
96 | { | 98 | { |
97 | m_MapService = service; | 99 | m_MapService = service; |
98 | m_GridService = grid; | 100 | m_GridService = grid; |
@@ -116,6 +118,11 @@ namespace OpenSim.Server.Handlers.MapImage | |||
116 | httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest; | 118 | httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest; |
117 | return FailureResult("Bad request."); | 119 | return FailureResult("Bad request."); |
118 | } | 120 | } |
121 | <<<<<<< HEAD | ||
122 | uint x = 0, y = 0; | ||
123 | UInt32.TryParse(request["X"].ToString(), out x); | ||
124 | UInt32.TryParse(request["Y"].ToString(), out y); | ||
125 | ======= | ||
119 | int x = 0, y = 0; | 126 | int x = 0, y = 0; |
120 | // UUID scopeID = new UUID("07f8d88e-cd5e-4239-a0ed-843f75d09992"); | 127 | // UUID scopeID = new UUID("07f8d88e-cd5e-4239-a0ed-843f75d09992"); |
121 | UUID scopeID = UUID.Zero; | 128 | UUID scopeID = UUID.Zero; |
@@ -123,6 +130,7 @@ namespace OpenSim.Server.Handlers.MapImage | |||
123 | Int32.TryParse(request["Y"].ToString(), out y); | 130 | Int32.TryParse(request["Y"].ToString(), out y); |
124 | if (request.ContainsKey("SCOPE")) | 131 | if (request.ContainsKey("SCOPE")) |
125 | UUID.TryParse(request["SCOPE"].ToString(), out scopeID); | 132 | UUID.TryParse(request["SCOPE"].ToString(), out scopeID); |
133 | >>>>>>> avn/ubitvar | ||
126 | 134 | ||
127 | m_log.DebugFormat("[MAP ADD SERVER CONNECTOR]: Received map data for region at {0}-{1}", x, y); | 135 | m_log.DebugFormat("[MAP ADD SERVER CONNECTOR]: Received map data for region at {0}-{1}", x, y); |
128 | 136 | ||
@@ -134,7 +142,11 @@ namespace OpenSim.Server.Handlers.MapImage | |||
134 | if (m_GridService != null) | 142 | if (m_GridService != null) |
135 | { | 143 | { |
136 | System.Net.IPAddress ipAddr = GetCallerIP(httpRequest); | 144 | System.Net.IPAddress ipAddr = GetCallerIP(httpRequest); |
145 | <<<<<<< HEAD | ||
146 | GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y)); | ||
147 | ======= | ||
137 | GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc((uint)x), (int)Util.RegionToWorldLoc((uint)y)); | 148 | GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc((uint)x), (int)Util.RegionToWorldLoc((uint)y)); |
149 | >>>>>>> avn/ubitvar | ||
138 | if (r != null) | 150 | if (r != null) |
139 | { | 151 | { |
140 | if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString()) | 152 | if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString()) |
@@ -155,7 +167,11 @@ namespace OpenSim.Server.Handlers.MapImage | |||
155 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); | 167 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); |
156 | 168 | ||
157 | string reason = string.Empty; | 169 | string reason = string.Empty; |
170 | <<<<<<< HEAD | ||
171 | bool result = m_MapService.AddMapTile((int)x, (int)y, data, out reason); | ||
172 | ======= | ||
158 | bool result = m_MapService.AddMapTile(x, y, data, scopeID, out reason); | 173 | bool result = m_MapService.AddMapTile(x, y, data, scopeID, out reason); |
174 | >>>>>>> avn/ubitvar | ||
159 | 175 | ||
160 | if (result) | 176 | if (result) |
161 | return SuccessResult(); | 177 | return SuccessResult(); |
@@ -190,7 +206,7 @@ namespace OpenSim.Server.Handlers.MapImage | |||
190 | 206 | ||
191 | rootElement.AppendChild(result); | 207 | rootElement.AppendChild(result); |
192 | 208 | ||
193 | return DocToBytes(doc); | 209 | return Util.DocToBytes(doc); |
194 | } | 210 | } |
195 | 211 | ||
196 | private byte[] FailureResult(string msg) | 212 | private byte[] FailureResult(string msg) |
@@ -217,18 +233,7 @@ namespace OpenSim.Server.Handlers.MapImage | |||
217 | 233 | ||
218 | rootElement.AppendChild(message); | 234 | rootElement.AppendChild(message); |
219 | 235 | ||
220 | return DocToBytes(doc); | 236 | return Util.DocToBytes(doc); |
221 | } | ||
222 | |||
223 | private byte[] DocToBytes(XmlDocument doc) | ||
224 | { | ||
225 | MemoryStream ms = new MemoryStream(); | ||
226 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
227 | xw.Formatting = Formatting.Indented; | ||
228 | doc.WriteTo(xw); | ||
229 | xw.Flush(); | ||
230 | |||
231 | return ms.ToArray(); | ||
232 | } | 237 | } |
233 | 238 | ||
234 | private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) | 239 | private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) |
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs b/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs index 899cd8f..7a63c36 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs | |||
@@ -30,6 +30,7 @@ using Nini.Config; | |||
30 | using OpenSim.Server.Base; | 30 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.Servers.HttpServer; | 32 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Framework.ServiceAuth; | ||
33 | using OpenSim.Server.Handlers.Base; | 34 | using OpenSim.Server.Handlers.Base; |
34 | 35 | ||
35 | namespace OpenSim.Server.Handlers.Presence | 36 | namespace OpenSim.Server.Handlers.Presence |
@@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Presence | |||
55 | Object[] args = new Object[] { config }; | 56 | Object[] args = new Object[] { config }; |
56 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(gridService, args); | 57 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(gridService, args); |
57 | 58 | ||
58 | server.AddStreamHandler(new PresenceServerPostHandler(m_PresenceService)); | 59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
60 | |||
61 | server.AddStreamHandler(new PresenceServerPostHandler(m_PresenceService, auth)); | ||
59 | } | 62 | } |
60 | } | 63 | } |
61 | } | 64 | } |
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index abb4b19..49dbcb5 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Server.Base; | |||
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
43 | using OpenSim.Framework.ServiceAuth; | ||
43 | using OpenMetaverse; | 44 | using OpenMetaverse; |
44 | 45 | ||
45 | namespace OpenSim.Server.Handlers.Presence | 46 | namespace OpenSim.Server.Handlers.Presence |
@@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.Presence | |||
50 | 51 | ||
51 | private IPresenceService m_PresenceService; | 52 | private IPresenceService m_PresenceService; |
52 | 53 | ||
53 | public PresenceServerPostHandler(IPresenceService service) : | 54 | public PresenceServerPostHandler(IPresenceService service, IServiceAuth auth) : |
54 | base("POST", "/presence") | 55 | base("POST", "/presence", auth) |
55 | { | 56 | { |
56 | m_PresenceService = service; | 57 | m_PresenceService = service; |
57 | } | 58 | } |
@@ -264,7 +265,7 @@ namespace OpenSim.Server.Handlers.Presence | |||
264 | 265 | ||
265 | rootElement.AppendChild(result); | 266 | rootElement.AppendChild(result); |
266 | 267 | ||
267 | return DocToBytes(doc); | 268 | return Util.DocToBytes(doc); |
268 | } | 269 | } |
269 | 270 | ||
270 | private byte[] FailureResult() | 271 | private byte[] FailureResult() |
@@ -286,18 +287,7 @@ namespace OpenSim.Server.Handlers.Presence | |||
286 | 287 | ||
287 | rootElement.AppendChild(result); | 288 | rootElement.AppendChild(result); |
288 | 289 | ||
289 | return DocToBytes(doc); | 290 | return Util.DocToBytes(doc); |
290 | } | ||
291 | |||
292 | private byte[] DocToBytes(XmlDocument doc) | ||
293 | { | ||
294 | MemoryStream ms = new MemoryStream(); | ||
295 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
296 | xw.Formatting = Formatting.Indented; | ||
297 | doc.WriteTo(xw); | ||
298 | xw.Flush(); | ||
299 | |||
300 | return ms.ToArray(); | ||
301 | } | 291 | } |
302 | 292 | ||
303 | } | 293 | } |
diff --git a/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs b/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs index 28dbbc2..9afe953 100644 --- a/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs +++ b/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs | |||
@@ -53,11 +53,6 @@ namespace OpenSim.Server.Handlers.Profiles | |||
53 | get; private set; | 53 | get; private set; |
54 | } | 54 | } |
55 | 55 | ||
56 | public string ConfigName | ||
57 | { | ||
58 | get; private set; | ||
59 | } | ||
60 | |||
61 | public bool Enabled | 56 | public bool Enabled |
62 | { | 57 | { |
63 | get; private set; | 58 | get; private set; |
diff --git a/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs b/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs index f5f0794..bc88184 100644 --- a/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs +++ b/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs | |||
@@ -126,14 +126,14 @@ namespace OpenSim.Server.Handlers | |||
126 | } | 126 | } |
127 | 127 | ||
128 | OSDMap request = (OSDMap)json["params"]; | 128 | OSDMap request = (OSDMap)json["params"]; |
129 | UUID classifiedId = new UUID(request["classifiedID"].AsString()); | 129 | UUID classifiedId = new UUID(request["classifiedId"].AsString()); |
130 | |||
131 | OSDMap res = new OSDMap(); | ||
132 | res["result"] = OSD.FromString("success"); | ||
133 | response.Result = res; | ||
134 | |||
135 | return true; | ||
136 | 130 | ||
131 | if (Service.ClassifiedDelete(classifiedId)) | ||
132 | return true; | ||
133 | |||
134 | response.Error.Code = ErrorCode.InternalError; | ||
135 | response.Error.Message = "data error removing record"; | ||
136 | return false; | ||
137 | } | 137 | } |
138 | 138 | ||
139 | public bool ClassifiedInfoRequest(OSDMap json, ref JsonRpcResponse response) | 139 | public bool ClassifiedInfoRequest(OSDMap json, ref JsonRpcResponse response) |
@@ -263,8 +263,7 @@ namespace OpenSim.Server.Handlers | |||
263 | m_log.DebugFormat ("Avatar Notes Request"); | 263 | m_log.DebugFormat ("Avatar Notes Request"); |
264 | return false; | 264 | return false; |
265 | } | 265 | } |
266 | 266 | ||
267 | string result = string.Empty; | ||
268 | UserProfileNotes note = new UserProfileNotes(); | 267 | UserProfileNotes note = new UserProfileNotes(); |
269 | object Note = (object)note; | 268 | object Note = (object)note; |
270 | OSD.DeserializeMembers(ref Note, (OSDMap)json["params"]); | 269 | OSD.DeserializeMembers(ref Note, (OSDMap)json["params"]); |
@@ -273,10 +272,10 @@ namespace OpenSim.Server.Handlers | |||
273 | response.Result = OSD.SerializeMembers(note); | 272 | response.Result = OSD.SerializeMembers(note); |
274 | return true; | 273 | return true; |
275 | } | 274 | } |
276 | 275 | ||
277 | object Notes = (object) note; | 276 | response.Error.Code = ErrorCode.InternalError; |
278 | OSD.DeserializeMembers(ref Notes, (OSDMap)json["params"]); | 277 | response.Error.Message = "Error reading notes"; |
279 | return true; | 278 | return false; |
280 | } | 279 | } |
281 | 280 | ||
282 | public bool NotesUpdate(OSDMap json, ref JsonRpcResponse response) | 281 | public bool NotesUpdate(OSDMap json, ref JsonRpcResponse response) |
@@ -381,6 +380,62 @@ namespace OpenSim.Server.Handlers | |||
381 | } | 380 | } |
382 | #endregion Interests | 381 | #endregion Interests |
383 | 382 | ||
383 | <<<<<<< HEAD | ||
384 | #region User Preferences | ||
385 | public bool UserPreferencesRequest(OSDMap json, ref JsonRpcResponse response) | ||
386 | { | ||
387 | if(!json.ContainsKey("params")) | ||
388 | { | ||
389 | response.Error.Code = ErrorCode.ParseError; | ||
390 | m_log.DebugFormat ("User Preferences Request"); | ||
391 | return false; | ||
392 | } | ||
393 | |||
394 | string result = string.Empty; | ||
395 | UserPreferences prefs = new UserPreferences(); | ||
396 | object Prefs = (object)prefs; | ||
397 | OSD.DeserializeMembers(ref Prefs, (OSDMap)json["params"]); | ||
398 | if(Service.UserPreferencesRequest(ref prefs, ref result)) | ||
399 | { | ||
400 | response.Result = OSD.SerializeMembers(prefs); | ||
401 | return true; | ||
402 | } | ||
403 | |||
404 | response.Error.Code = ErrorCode.InternalError; | ||
405 | response.Error.Message = string.Format("{0}", result); | ||
406 | // m_log.InfoFormat("[PROFILES]: User preferences request error - {0}", response.Error.Message); | ||
407 | return false; | ||
408 | } | ||
409 | |||
410 | public bool UserPreferenecesUpdate(OSDMap json, ref JsonRpcResponse response) | ||
411 | { | ||
412 | if(!json.ContainsKey("params")) | ||
413 | { | ||
414 | response.Error.Code = ErrorCode.ParseError; | ||
415 | response.Error.Message = "no parameters supplied"; | ||
416 | m_log.DebugFormat ("User Preferences Update Request"); | ||
417 | return false; | ||
418 | } | ||
419 | |||
420 | string result = string.Empty; | ||
421 | UserPreferences prefs = new UserPreferences(); | ||
422 | object Prefs = (object)prefs; | ||
423 | OSD.DeserializeMembers(ref Prefs, (OSDMap)json["params"]); | ||
424 | if(Service.UserPreferencesUpdate(ref prefs, ref result)) | ||
425 | { | ||
426 | response.Result = OSD.SerializeMembers(prefs); | ||
427 | return true; | ||
428 | } | ||
429 | |||
430 | response.Error.Code = ErrorCode.InternalError; | ||
431 | response.Error.Message = string.Format("{0}", result); | ||
432 | m_log.InfoFormat("[PROFILES]: User preferences update error - {0}", response.Error.Message); | ||
433 | return false; | ||
434 | } | ||
435 | #endregion User Preferences | ||
436 | |||
437 | ======= | ||
438 | >>>>>>> avn/ubitvar | ||
384 | #region Utility | 439 | #region Utility |
385 | public bool AvatarImageAssetsRequest(OSDMap json, ref JsonRpcResponse response) | 440 | public bool AvatarImageAssetsRequest(OSDMap json, ref JsonRpcResponse response) |
386 | { | 441 | { |
diff --git a/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs b/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs index 04cd798..780e454 100644 --- a/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs +++ b/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs | |||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices; | |||
29 | // Build Number | 29 | // Build Number |
30 | // Revision | 30 | // Revision |
31 | // | 31 | // |
32 | [assembly: AssemblyVersion("0.8.0.*")] | 32 | [assembly: AssemblyVersion("0.8.2.*")] |
33 | 33 | ||
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 76b593a..8780a49 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Collections.Specialized; | 31 | using System.Collections.Specialized; |
31 | using System.IO; | 32 | using System.IO; |
32 | using System.IO.Compression; | 33 | using System.IO.Compression; |
@@ -148,12 +149,29 @@ namespace OpenSim.Server.Handlers.Simulation | |||
148 | if (args.ContainsKey("my_version")) | 149 | if (args.ContainsKey("my_version")) |
149 | theirVersion = args["my_version"].AsString(); | 150 | theirVersion = args["my_version"].AsString(); |
150 | 151 | ||
152 | <<<<<<< HEAD | ||
153 | List<UUID> features = new List<UUID>(); | ||
154 | |||
155 | if (args.ContainsKey("features")) | ||
156 | { | ||
157 | OSDArray array = (OSDArray)args["features"]; | ||
158 | |||
159 | foreach (OSD o in array) | ||
160 | features.Add(new UUID(o.AsString())); | ||
161 | } | ||
162 | |||
163 | ======= | ||
164 | >>>>>>> avn/ubitvar | ||
151 | GridRegion destination = new GridRegion(); | 165 | GridRegion destination = new GridRegion(); |
152 | destination.RegionID = regionID; | 166 | destination.RegionID = regionID; |
153 | 167 | ||
154 | string reason; | 168 | string reason; |
155 | string version; | 169 | string version; |
170 | <<<<<<< HEAD | ||
171 | bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, theirVersion, features, out version, out reason); | ||
172 | ======= | ||
156 | bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, theirVersion, out version, out reason); | 173 | bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, theirVersion, out version, out reason); |
174 | >>>>>>> avn/ubitvar | ||
157 | 175 | ||
158 | responsedata["int_response_code"] = HttpStatusCode.OK; | 176 | responsedata["int_response_code"] = HttpStatusCode.OK; |
159 | 177 | ||
@@ -163,6 +181,12 @@ namespace OpenSim.Server.Handlers.Simulation | |||
163 | resp["reason"] = OSD.FromString(reason); | 181 | resp["reason"] = OSD.FromString(reason); |
164 | resp["version"] = OSD.FromString(version); | 182 | resp["version"] = OSD.FromString(version); |
165 | 183 | ||
184 | OSDArray featuresWanted = new OSDArray(); | ||
185 | foreach (UUID feature in features) | ||
186 | featuresWanted.Add(OSD.FromString(feature.ToString())); | ||
187 | |||
188 | resp["features"] = featuresWanted; | ||
189 | |||
166 | // We must preserve defaults here, otherwise a false "success" will not be put into the JSON map! | 190 | // We must preserve defaults here, otherwise a false "success" will not be put into the JSON map! |
167 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); | 191 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); |
168 | 192 | ||
@@ -182,7 +206,8 @@ namespace OpenSim.Server.Handlers.Simulation | |||
182 | if (action.Equals("release")) | 206 | if (action.Equals("release")) |
183 | ReleaseAgent(regionID, id); | 207 | ReleaseAgent(regionID, id); |
184 | else | 208 | else |
185 | Util.FireAndForget(delegate { m_SimulationService.CloseAgent(destination, id, auth_token); }); | 209 | Util.FireAndForget( |
210 | o => m_SimulationService.CloseAgent(destination, id, auth_token), null, "AgentHandler.DoAgentDelete"); | ||
186 | 211 | ||
187 | responsedata["int_response_code"] = HttpStatusCode.OK; | 212 | responsedata["int_response_code"] = HttpStatusCode.OK; |
188 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); | 213 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); |
@@ -244,21 +269,45 @@ namespace OpenSim.Server.Handlers.Simulation | |||
244 | httpResponse.KeepAlive = false; | 269 | httpResponse.KeepAlive = false; |
245 | Encoding encoding = Encoding.UTF8; | 270 | Encoding encoding = Encoding.UTF8; |
246 | 271 | ||
272 | <<<<<<< HEAD | ||
273 | if (httpRequest.ContentType != "application/json") | ||
274 | ======= | ||
247 | Stream inputStream = null; | 275 | Stream inputStream = null; |
248 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | 276 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) |
249 | inputStream = new GZipStream(request, CompressionMode.Decompress); | 277 | inputStream = new GZipStream(request, CompressionMode.Decompress); |
250 | else if (httpRequest.ContentType == "application/json") | 278 | else if (httpRequest.ContentType == "application/json") |
251 | inputStream = request; | 279 | inputStream = request; |
252 | else // no go | 280 | else // no go |
281 | >>>>>>> avn/ubitvar | ||
253 | { | 282 | { |
254 | httpResponse.StatusCode = 406; | 283 | httpResponse.StatusCode = 406; |
255 | return encoding.GetBytes("false"); | 284 | return encoding.GetBytes("false"); |
256 | } | 285 | } |
257 | 286 | ||
258 | StreamReader reader = new StreamReader(inputStream, encoding); | 287 | string requestBody; |
288 | |||
289 | Stream inputStream = request; | ||
290 | Stream innerStream = null; | ||
291 | try | ||
292 | { | ||
293 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | ||
294 | { | ||
295 | innerStream = inputStream; | ||
296 | inputStream = new GZipStream(innerStream, CompressionMode.Decompress); | ||
297 | } | ||
298 | |||
299 | using (StreamReader reader = new StreamReader(inputStream, encoding)) | ||
300 | { | ||
301 | requestBody = reader.ReadToEnd(); | ||
302 | } | ||
303 | } | ||
304 | finally | ||
305 | { | ||
306 | if (innerStream != null) | ||
307 | innerStream.Dispose(); | ||
308 | inputStream.Dispose(); | ||
309 | } | ||
259 | 310 | ||
260 | string requestBody = reader.ReadToEnd(); | ||
261 | reader.Close(); | ||
262 | keysvals.Add("body", requestBody); | 311 | keysvals.Add("body", requestBody); |
263 | 312 | ||
264 | Hashtable responsedata = new Hashtable(); | 313 | Hashtable responsedata = new Hashtable(); |
@@ -316,13 +365,29 @@ namespace OpenSim.Server.Handlers.Simulation | |||
316 | return; | 365 | return; |
317 | } | 366 | } |
318 | 367 | ||
368 | GridRegion source = null; | ||
369 | |||
370 | if (args.ContainsKey("source_uuid")) | ||
371 | { | ||
372 | source = new GridRegion(); | ||
373 | source.RegionLocX = Int32.Parse(args["source_x"].AsString()); | ||
374 | source.RegionLocY = Int32.Parse(args["source_y"].AsString()); | ||
375 | source.RegionName = args["source_name"].AsString(); | ||
376 | source.RegionID = UUID.Parse(args["source_uuid"].AsString()); | ||
377 | |||
378 | if (args.ContainsKey("source_server_uri")) | ||
379 | source.RawServerURI = args["source_server_uri"].AsString(); | ||
380 | else | ||
381 | source.RawServerURI = null; | ||
382 | } | ||
383 | |||
319 | OSDMap resp = new OSDMap(2); | 384 | OSDMap resp = new OSDMap(2); |
320 | string reason = String.Empty; | 385 | string reason = String.Empty; |
321 | 386 | ||
322 | // This is the meaning of POST agent | 387 | // This is the meaning of POST agent |
323 | //m_regionClient.AdjustUserInformation(aCircuit); | 388 | //m_regionClient.AdjustUserInformation(aCircuit); |
324 | //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); | 389 | //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); |
325 | bool result = CreateAgent(gatekeeper, destination, aCircuit, data.flags, data.fromLogin, out reason); | 390 | bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, out reason); |
326 | 391 | ||
327 | resp["reason"] = OSD.FromString(reason); | 392 | resp["reason"] = OSD.FromString(reason); |
328 | resp["success"] = OSD.FromBoolean(result); | 393 | resp["success"] = OSD.FromBoolean(result); |
@@ -396,8 +461,12 @@ namespace OpenSim.Server.Handlers.Simulation | |||
396 | } | 461 | } |
397 | 462 | ||
398 | // subclasses can override this | 463 | // subclasses can override this |
399 | protected virtual bool CreateAgent(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason) | 464 | protected virtual bool CreateAgent(GridRegion source, GridRegion gatekeeper, GridRegion destination, |
465 | AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason) | ||
400 | { | 466 | { |
467 | <<<<<<< HEAD | ||
468 | return m_SimulationService.CreateAgent(source, destination, aCircuit, teleportFlags, out reason); | ||
469 | ======= | ||
401 | reason = String.Empty; | 470 | reason = String.Empty; |
402 | if ((teleportFlags & (uint)TeleportFlags.ViaLogin) == 0) | 471 | if ((teleportFlags & (uint)TeleportFlags.ViaLogin) == 0) |
403 | { | 472 | { |
@@ -418,6 +487,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
418 | return ret; | 487 | return ret; |
419 | } | 488 | } |
420 | 489 | ||
490 | >>>>>>> avn/ubitvar | ||
421 | } | 491 | } |
422 | } | 492 | } |
423 | 493 | ||
@@ -464,17 +534,31 @@ namespace OpenSim.Server.Handlers.Simulation | |||
464 | keysvals.Add("headers", headervals); | 534 | keysvals.Add("headers", headervals); |
465 | keysvals.Add("querystringkeys", querystringkeys); | 535 | keysvals.Add("querystringkeys", querystringkeys); |
466 | 536 | ||
467 | Stream inputStream; | 537 | String requestBody; |
468 | if (httpRequest.ContentType == "application/x-gzip") | ||
469 | inputStream = new GZipStream(request, CompressionMode.Decompress); | ||
470 | else | ||
471 | inputStream = request; | ||
472 | |||
473 | Encoding encoding = Encoding.UTF8; | 538 | Encoding encoding = Encoding.UTF8; |
474 | StreamReader reader = new StreamReader(inputStream, encoding); | ||
475 | 539 | ||
476 | string requestBody = reader.ReadToEnd(); | 540 | Stream inputStream = request; |
477 | reader.Close(); | 541 | Stream innerStream = null; |
542 | try | ||
543 | { | ||
544 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | ||
545 | { | ||
546 | innerStream = inputStream; | ||
547 | inputStream = new GZipStream(innerStream, CompressionMode.Decompress); | ||
548 | } | ||
549 | |||
550 | using (StreamReader reader = new StreamReader(inputStream, encoding)) | ||
551 | { | ||
552 | requestBody = reader.ReadToEnd(); | ||
553 | } | ||
554 | } | ||
555 | finally | ||
556 | { | ||
557 | if (innerStream != null) | ||
558 | innerStream.Dispose(); | ||
559 | inputStream.Dispose(); | ||
560 | } | ||
561 | |||
478 | keysvals.Add("body", requestBody); | 562 | keysvals.Add("body", requestBody); |
479 | 563 | ||
480 | httpResponse.StatusCode = 200; | 564 | httpResponse.StatusCode = 200; |
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs index 344b513..e95e3dc 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs | |||
@@ -30,6 +30,7 @@ using Nini.Config; | |||
30 | using OpenSim.Server.Base; | 30 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.Servers.HttpServer; | 32 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Framework.ServiceAuth; | ||
33 | using OpenSim.Server.Handlers.Base; | 34 | using OpenSim.Server.Handlers.Base; |
34 | 35 | ||
35 | namespace OpenSim.Server.Handlers.UserAccounts | 36 | namespace OpenSim.Server.Handlers.UserAccounts |
@@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
55 | Object[] args = new Object[] { config }; | 56 | Object[] args = new Object[] { config }; |
56 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(service, args); | 57 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(service, args); |
57 | 58 | ||
58 | server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService, serverConfig)); | 59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
60 | |||
61 | server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService, serverConfig, auth)); | ||
59 | } | 62 | } |
60 | } | 63 | } |
61 | } | 64 | } |
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index 24c9de6..21eb790 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Services.Interfaces; | |||
41 | using OpenSim.Services.UserAccountService; | 41 | using OpenSim.Services.UserAccountService; |
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.Servers.HttpServer; | 43 | using OpenSim.Framework.Servers.HttpServer; |
44 | using OpenSim.Framework.ServiceAuth; | ||
44 | using OpenMetaverse; | 45 | using OpenMetaverse; |
45 | 46 | ||
46 | namespace OpenSim.Server.Handlers.UserAccounts | 47 | namespace OpenSim.Server.Handlers.UserAccounts |
@@ -54,10 +55,10 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
54 | private bool m_AllowSetAccount = false; | 55 | private bool m_AllowSetAccount = false; |
55 | 56 | ||
56 | public UserAccountServerPostHandler(IUserAccountService service) | 57 | public UserAccountServerPostHandler(IUserAccountService service) |
57 | : this(service, null) {} | 58 | : this(service, null, null) {} |
58 | 59 | ||
59 | public UserAccountServerPostHandler(IUserAccountService service, IConfig config) : | 60 | public UserAccountServerPostHandler(IUserAccountService service, IConfig config, IServiceAuth auth) : |
60 | base("POST", "/accounts") | 61 | base("POST", "/accounts", auth) |
61 | { | 62 | { |
62 | m_UserAccountService = service; | 63 | m_UserAccountService = service; |
63 | 64 | ||
@@ -256,8 +257,7 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
256 | 257 | ||
257 | byte[] CreateUser(Dictionary<string, object> request) | 258 | byte[] CreateUser(Dictionary<string, object> request) |
258 | { | 259 | { |
259 | if (! | 260 | if (! request.ContainsKey("FirstName") |
260 | request.ContainsKey("FirstName") | ||
261 | && request.ContainsKey("LastName") | 261 | && request.ContainsKey("LastName") |
262 | && request.ContainsKey("Password")) | 262 | && request.ContainsKey("Password")) |
263 | return FailureResult(); | 263 | return FailureResult(); |
@@ -314,7 +314,7 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
314 | 314 | ||
315 | rootElement.AppendChild(result); | 315 | rootElement.AppendChild(result); |
316 | 316 | ||
317 | return DocToBytes(doc); | 317 | return Util.DocToBytes(doc); |
318 | } | 318 | } |
319 | 319 | ||
320 | private byte[] FailureResult() | 320 | private byte[] FailureResult() |
@@ -336,18 +336,7 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
336 | 336 | ||
337 | rootElement.AppendChild(result); | 337 | rootElement.AppendChild(result); |
338 | 338 | ||
339 | return DocToBytes(doc); | 339 | return Util.DocToBytes(doc); |
340 | } | ||
341 | |||
342 | private byte[] DocToBytes(XmlDocument doc) | ||
343 | { | ||
344 | MemoryStream ms = new MemoryStream(); | ||
345 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
346 | xw.Formatting = Formatting.Indented; | ||
347 | doc.WriteTo(xw); | ||
348 | xw.Flush(); | ||
349 | |||
350 | return ms.ToArray(); | ||
351 | } | 340 | } |
352 | 341 | ||
353 | private byte[] ResultToBytes(Dictionary<string, object> result) | 342 | private byte[] ResultToBytes(Dictionary<string, object> result) |