diff options
author | Diva Canto | 2014-05-23 16:19:43 -0700 |
---|---|---|
committer | Diva Canto | 2014-05-23 16:19:43 -0700 |
commit | 20f20895cf1444071d5edc42e11a1fb94b1b1079 (patch) | |
tree | 0c7547590a89eec47886e0a8646f86ebbf449e63 /OpenSim/Framework/Servers | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-20f20895cf1444071d5edc42e11a1fb94b1b1079.zip opensim-SC_OLD-20f20895cf1444071d5edc42e11a1fb94b1b1079.tar.gz opensim-SC_OLD-20f20895cf1444071d5edc42e11a1fb94b1b1079.tar.bz2 opensim-SC_OLD-20f20895cf1444071d5edc42e11a1fb94b1b1079.tar.xz |
Adds optional HTTP Basic Authentication to Robust service connectors.
Diffstat (limited to 'OpenSim/Framework/Servers')
-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 | ||