diff options
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs | 19 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs | 24 |
2 files changed, 30 insertions, 13 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs index 252cc2a..f160734 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs | |||
@@ -26,6 +26,8 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.IO; | 28 | using System.IO; |
29 | using System.Net; | ||
30 | using OpenSim.Framework.ServiceAuth; | ||
29 | 31 | ||
30 | namespace OpenSim.Framework.Servers.HttpServer | 32 | namespace OpenSim.Framework.Servers.HttpServer |
31 | { | 33 | { |
@@ -37,15 +39,30 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
37 | /// </remarks> | 39 | /// </remarks> |
38 | public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler | 40 | public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler |
39 | { | 41 | { |
40 | protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} | 42 | protected IServiceAuth m_Auth; |
43 | |||
44 | protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) { } | ||
41 | 45 | ||
42 | protected BaseStreamHandler(string httpMethod, string path, string name, string description) | 46 | protected BaseStreamHandler(string httpMethod, string path, string name, string description) |
43 | : base(httpMethod, path, name, description) {} | 47 | : base(httpMethod, path, name, description) {} |
44 | 48 | ||
49 | protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth) | ||
50 | : base(httpMethod, path, null, null) | ||
51 | { | ||
52 | m_Auth = auth; | ||
53 | } | ||
54 | |||
45 | public virtual byte[] Handle( | 55 | public virtual byte[] Handle( |
46 | string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 56 | string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
47 | { | 57 | { |
48 | RequestsReceived++; | 58 | RequestsReceived++; |
59 | if (m_Auth != null && !m_Auth.Authenticate(httpRequest.Headers, httpResponse.AddHeader)) | ||
60 | { | ||
61 | |||
62 | httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; | ||
63 | httpResponse.ContentType = "text/plain"; | ||
64 | return new byte[0]; | ||
65 | } | ||
49 | 66 | ||
50 | byte[] result = ProcessRequest(path, request, httpRequest, httpResponse); | 67 | byte[] result = ProcessRequest(path, request, httpRequest, httpResponse); |
51 | 68 | ||
diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs index ed6a14c..2fe1a7d 100644 --- a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs | |||
@@ -90,14 +90,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
90 | } | 90 | } |
91 | catch (Exception e) | 91 | catch (Exception e) |
92 | { | 92 | { |
93 | m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); | 93 | m_log.Debug(string.Format("JsonRpc request '{0}' to {1} failed", method, uri), e); |
94 | return false; | 94 | return false; |
95 | } | 95 | } |
96 | 96 | ||
97 | if (!response.ContainsKey("_Result")) | 97 | if (!response.ContainsKey("_Result")) |
98 | { | 98 | { |
99 | m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", | 99 | m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", |
100 | method, OSDParser.SerializeJsonString(response)); | 100 | method, uri, OSDParser.SerializeJsonString(response)); |
101 | return false; | 101 | return false; |
102 | } | 102 | } |
103 | response = (OSDMap)response["_Result"]; | 103 | response = (OSDMap)response["_Result"]; |
@@ -107,15 +107,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
107 | if (response.ContainsKey("error")) | 107 | if (response.ContainsKey("error")) |
108 | { | 108 | { |
109 | data = response["error"]; | 109 | data = response["error"]; |
110 | m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", | 110 | m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", |
111 | method, OSDParser.SerializeJsonString(data)); | 111 | method, uri, OSDParser.SerializeJsonString(data)); |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | 114 | ||
115 | if (!response.ContainsKey("result")) | 115 | if (!response.ContainsKey("result")) |
116 | { | 116 | { |
117 | m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", | 117 | m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", |
118 | method, OSDParser.SerializeJsonString(response)); | 118 | method, uri, OSDParser.SerializeJsonString(response)); |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | 121 | ||
@@ -161,14 +161,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
161 | } | 161 | } |
162 | catch (Exception e) | 162 | catch (Exception e) |
163 | { | 163 | { |
164 | m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); | 164 | m_log.Debug(string.Format("JsonRpc request '{0}' to {1} failed", method, uri), e); |
165 | return false; | 165 | return false; |
166 | } | 166 | } |
167 | 167 | ||
168 | if (!response.ContainsKey("_Result")) | 168 | if (!response.ContainsKey("_Result")) |
169 | { | 169 | { |
170 | m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", | 170 | m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", |
171 | method, OSDParser.SerializeJsonString(response)); | 171 | method, uri, OSDParser.SerializeJsonString(response)); |
172 | return false; | 172 | return false; |
173 | } | 173 | } |
174 | response = (OSDMap)response["_Result"]; | 174 | response = (OSDMap)response["_Result"]; |
@@ -176,8 +176,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
176 | if (response.ContainsKey("error")) | 176 | if (response.ContainsKey("error")) |
177 | { | 177 | { |
178 | data = response["error"]; | 178 | data = response["error"]; |
179 | m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", | 179 | m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", |
180 | method, OSDParser.SerializeJsonString(data)); | 180 | method, uri, OSDParser.SerializeJsonString(data)); |
181 | return false; | 181 | return false; |
182 | } | 182 | } |
183 | 183 | ||