diff options
author | Justin Clark-Casey | 2014-05-27 23:29:54 +0100 |
---|---|---|
committer | Justin Clark-Casey | 2014-05-27 23:29:54 +0100 |
commit | 3f703ae1cb02cbcb0efaff061d495bacca941de0 (patch) | |
tree | 3221068b4bc4119023b3dfa621c19e126c2eb3f3 /OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs | |
parent | Merge branch 'master' into 0.8-post-fixes (diff) | |
parent | minor: Comment out 2 error level debugging message in authentication code (diff) | |
download | opensim-SC_OLD-3f703ae1cb02cbcb0efaff061d495bacca941de0.zip opensim-SC_OLD-3f703ae1cb02cbcb0efaff061d495bacca941de0.tar.gz opensim-SC_OLD-3f703ae1cb02cbcb0efaff061d495bacca941de0.tar.bz2 opensim-SC_OLD-3f703ae1cb02cbcb0efaff061d495bacca941de0.tar.xz |
Merge branch 'master' into 0.8-post-fixes
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs | 19 |
1 files changed, 18 insertions, 1 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 | ||