diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs index 6b802d3..1b94741 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs | |||
@@ -23,7 +23,6 @@ | |||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | ||
27 | */ | 26 | */ |
28 | 27 | ||
29 | using libsecondlife; | 28 | using libsecondlife; |
@@ -40,10 +39,8 @@ using OpenSim.Framework.Communications.Cache; | |||
40 | 39 | ||
41 | namespace OpenSim.ApplicationPlugins.Rest.Inventory | 40 | namespace OpenSim.ApplicationPlugins.Rest.Inventory |
42 | { | 41 | { |
43 | |||
44 | public class RestAssetServices : IRest | 42 | public class RestAssetServices : IRest |
45 | { | 43 | { |
46 | |||
47 | private bool enabled = false; | 44 | private bool enabled = false; |
48 | private string qPrefix = "assets"; | 45 | private string qPrefix = "assets"; |
49 | 46 | ||
@@ -52,7 +49,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
52 | 49 | ||
53 | public RestAssetServices() | 50 | public RestAssetServices() |
54 | { | 51 | { |
55 | |||
56 | Rest.Log.InfoFormat("{0} Asset services initializing", MsgId); | 52 | Rest.Log.InfoFormat("{0} Asset services initializing", MsgId); |
57 | Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version); | 53 | Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version); |
58 | 54 | ||
@@ -73,7 +69,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
73 | enabled = true; | 69 | enabled = true; |
74 | 70 | ||
75 | Rest.Log.InfoFormat("{0} Asset services initialization complete", MsgId); | 71 | Rest.Log.InfoFormat("{0} Asset services initialization complete", MsgId); |
76 | |||
77 | } | 72 | } |
78 | 73 | ||
79 | // Post-construction, pre-enabled initialization opportunity | 74 | // Post-construction, pre-enabled initialization opportunity |
@@ -84,7 +79,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
84 | } | 79 | } |
85 | 80 | ||
86 | // Called by the plug-in to halt REST processing. Local processing is | 81 | // Called by the plug-in to halt REST processing. Local processing is |
87 | // disabled, and control blocks until all current processing has | 82 | // disabled, and control blocks until all current processing has |
88 | // completed. No new processing will be started | 83 | // completed. No new processing will be started |
89 | 84 | ||
90 | public void Close() | 85 | public void Close() |
@@ -111,14 +106,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
111 | 106 | ||
112 | private void DoAsset(RequestData rparm) | 107 | private void DoAsset(RequestData rparm) |
113 | { | 108 | { |
114 | |||
115 | if (!enabled) return; | 109 | if (!enabled) return; |
116 | 110 | ||
117 | AssetRequestData rdata = (AssetRequestData) rparm; | 111 | AssetRequestData rdata = (AssetRequestData) rparm; |
118 | 112 | ||
119 | Rest.Log.DebugFormat("{0} REST Asset handler ENTRY", MsgId); | 113 | Rest.Log.DebugFormat("{0} REST Asset handler ENTRY", MsgId); |
120 | 114 | ||
121 | // Now that we know this is a serious attempt to | 115 | // Now that we know this is a serious attempt to |
122 | // access inventory data, we should find out who | 116 | // access inventory data, we should find out who |
123 | // is asking, and make sure they are authorized | 117 | // is asking, and make sure they are authorized |
124 | // to do so. We need to validate the caller's | 118 | // to do so. We need to validate the caller's |
@@ -129,9 +123,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
129 | // With the present HTTP server we can't use the | 123 | // With the present HTTP server we can't use the |
130 | // builtin authentication mechanisms because they | 124 | // builtin authentication mechanisms because they |
131 | // would be enforced for all in-bound requests. | 125 | // would be enforced for all in-bound requests. |
132 | // Instead we look at the headers ourselves and | 126 | // Instead we look at the headers ourselves and |
133 | // handle authentication directly. | 127 | // handle authentication directly. |
134 | 128 | ||
135 | try | 129 | try |
136 | { | 130 | { |
137 | if (!rdata.IsAuthenticated) | 131 | if (!rdata.IsAuthenticated) |
@@ -144,13 +138,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
144 | if (e.statusCode == Rest.HttpStatusCodeNotAuthorized) | 138 | if (e.statusCode == Rest.HttpStatusCodeNotAuthorized) |
145 | { | 139 | { |
146 | Rest.Log.WarnFormat("{0} User not authenticated", MsgId); | 140 | Rest.Log.WarnFormat("{0} User not authenticated", MsgId); |
147 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, | 141 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, |
148 | rdata.request.Headers.Get("Authorization")); | 142 | rdata.request.Headers.Get("Authorization")); |
149 | } | 143 | } |
150 | else | 144 | else |
151 | { | 145 | { |
152 | Rest.Log.ErrorFormat("{0} User authentication failed", MsgId); | 146 | Rest.Log.ErrorFormat("{0} User authentication failed", MsgId); |
153 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, | 147 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, |
154 | rdata.request.Headers.Get("Authorization")); | 148 | rdata.request.Headers.Get("Authorization")); |
155 | } | 149 | } |
156 | throw (e); | 150 | throw (e); |
@@ -173,7 +167,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
173 | case "post" : | 167 | case "post" : |
174 | case "delete" : | 168 | case "delete" : |
175 | default : | 169 | default : |
176 | Rest.Log.WarnFormat("{0} Asset: Method not supported: {1}", | 170 | Rest.Log.WarnFormat("{0} Asset: Method not supported: {1}", |
177 | MsgId, rdata.method); | 171 | MsgId, rdata.method); |
178 | rdata.Fail(Rest.HttpStatusCodeBadRequest,String.Format("method <{0}> not supported", rdata.method)); | 172 | rdata.Fail(Rest.HttpStatusCodeBadRequest,String.Format("method <{0}> not supported", rdata.method)); |
179 | break; | 173 | break; |
@@ -186,14 +180,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
186 | } | 180 | } |
187 | 181 | ||
188 | Rest.Log.DebugFormat("{0} REST Asset handler EXIT", MsgId); | 182 | Rest.Log.DebugFormat("{0} REST Asset handler EXIT", MsgId); |
189 | |||
190 | } | 183 | } |
191 | 184 | ||
192 | #endregion Interface | 185 | #endregion Interface |
193 | 186 | ||
194 | private void DoGet(AssetRequestData rdata) | 187 | private void DoGet(AssetRequestData rdata) |
195 | { | 188 | { |
196 | |||
197 | bool istexture = false; | 189 | bool istexture = false; |
198 | 190 | ||
199 | Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method); | 191 | Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method); |
@@ -203,13 +195,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
203 | 195 | ||
204 | if (rdata.Parameters.Length == 1) | 196 | if (rdata.Parameters.Length == 1) |
205 | { | 197 | { |
206 | |||
207 | LLUUID uuid = new LLUUID(rdata.Parameters[0]); | 198 | LLUUID uuid = new LLUUID(rdata.Parameters[0]); |
208 | AssetBase asset = Rest.AssetServices.GetAsset(uuid, istexture); | 199 | AssetBase asset = Rest.AssetServices.GetAsset(uuid, istexture); |
209 | 200 | ||
210 | if (asset != null) | 201 | if (asset != null) |
211 | { | 202 | { |
212 | |||
213 | Rest.Log.DebugFormat("{0} Asset located <{1}>", MsgId, rdata.Parameters[0]); | 203 | Rest.Log.DebugFormat("{0} Asset located <{1}>", MsgId, rdata.Parameters[0]); |
214 | 204 | ||
215 | rdata.initXmlWriter(); | 205 | rdata.initXmlWriter(); |
@@ -237,7 +227,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
237 | 227 | ||
238 | rdata.Complete(); | 228 | rdata.Complete(); |
239 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); | 229 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); |
240 | |||
241 | } | 230 | } |
242 | 231 | ||
243 | private void DoPut(AssetRequestData rdata) | 232 | private void DoPut(AssetRequestData rdata) |
@@ -255,7 +244,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
255 | if (!xml.ReadToFollowing("Asset")) | 244 | if (!xml.ReadToFollowing("Asset")) |
256 | { | 245 | { |
257 | Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path); | 246 | Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path); |
258 | rdata.Fail(Rest.HttpStatusCodeBadRequest,"invalid request data"); | 247 | rdata.Fail(Rest.HttpStatusCodeBadRequest,"invalid request data"); |
259 | } | 248 | } |
260 | 249 | ||
261 | AssetBase asset = new AssetBase(); | 250 | AssetBase asset = new AssetBase(); |
@@ -272,12 +261,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
272 | else | 261 | else |
273 | { | 262 | { |
274 | Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path); | 263 | Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path); |
275 | rdata.Fail(Rest.HttpStatusCodeNotFound, "invalid parameters"); | 264 | rdata.Fail(Rest.HttpStatusCodeNotFound, "invalid parameters"); |
276 | } | 265 | } |
277 | 266 | ||
278 | rdata.Complete(); | 267 | rdata.Complete(); |
279 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); | 268 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); |
280 | |||
281 | } | 269 | } |
282 | 270 | ||
283 | internal class AssetRequestData : RequestData | 271 | internal class AssetRequestData : RequestData |
@@ -287,6 +275,5 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
287 | { | 275 | { |
288 | } | 276 | } |
289 | } | 277 | } |
290 | |||
291 | } | 278 | } |
292 | } | 279 | } |