diff options
Diffstat (limited to 'OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs')
-rw-r--r-- | OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs index 828965f..55ae6db 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs | |||
@@ -36,6 +36,7 @@ using OpenSim.Framework; | |||
36 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
39 | using OpenSim.Framework.ServiceAuth; | ||
39 | using OpenSim.Server.Handlers.Base; | 40 | using OpenSim.Server.Handlers.Base; |
40 | using log4net; | 41 | using log4net; |
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
@@ -64,12 +65,14 @@ namespace OpenSim.Groups | |||
64 | key = groupsConfig.GetString("SecretKey", string.Empty); | 65 | key = groupsConfig.GetString("SecretKey", string.Empty); |
65 | m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key); | 66 | m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key); |
66 | } | 67 | } |
67 | else | 68 | // else |
68 | m_log.WarnFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName); | 69 | // m_log.DebugFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName); |
69 | 70 | ||
70 | m_GroupsService = new GroupsService(config); | 71 | m_GroupsService = new GroupsService(config); |
71 | 72 | ||
72 | server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, key)); | 73 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
74 | |||
75 | server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, auth)); | ||
73 | } | 76 | } |
74 | } | 77 | } |
75 | 78 | ||
@@ -78,13 +81,11 @@ namespace OpenSim.Groups | |||
78 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 81 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
79 | 82 | ||
80 | private GroupsService m_GroupsService; | 83 | private GroupsService m_GroupsService; |
81 | private string m_SecretKey = String.Empty; | ||
82 | 84 | ||
83 | public GroupsServicePostHandler(GroupsService service, string key) : | 85 | public GroupsServicePostHandler(GroupsService service, IServiceAuth auth) : |
84 | base("POST", "/groups") | 86 | base("POST", "/groups", auth) |
85 | { | 87 | { |
86 | m_GroupsService = service; | 88 | m_GroupsService = service; |
87 | m_SecretKey = key; | ||
88 | } | 89 | } |
89 | 90 | ||
90 | protected override byte[] ProcessRequest(string path, Stream requestData, | 91 | protected override byte[] ProcessRequest(string path, Stream requestData, |
@@ -108,20 +109,6 @@ namespace OpenSim.Groups | |||
108 | string method = request["METHOD"].ToString(); | 109 | string method = request["METHOD"].ToString(); |
109 | request.Remove("METHOD"); | 110 | request.Remove("METHOD"); |
110 | 111 | ||
111 | if (!String.IsNullOrEmpty(m_SecretKey)) // Verification required | ||
112 | { | ||
113 | // Sender didn't send key | ||
114 | if (!request.ContainsKey("KEY") || (request["KEY"] == null)) | ||
115 | return FailureResult("This service requires a secret key"); | ||
116 | |||
117 | // Sender sent wrong key | ||
118 | if (!m_SecretKey.Equals(request["KEY"])) | ||
119 | return FailureResult("Provided key does not match existing one"); | ||
120 | |||
121 | // OK, key matches. Remove it. | ||
122 | request.Remove("KEY"); | ||
123 | } | ||
124 | |||
125 | m_log.DebugFormat("[Groups.Handler]: {0}", method); | 112 | m_log.DebugFormat("[Groups.Handler]: {0}", method); |
126 | switch (method) | 113 | switch (method) |
127 | { | 114 | { |