From a53cea6b7e4094ea51339c80ab5fe160a19a9f6b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 20 May 2008 16:51:45 +0000 Subject: i'm extending the RestStreamHandler.Handler(...) signature to actually provide OSHttpRequest and OSHttpResponse to our REST handler. also, this adds proper RestPlugin.IsGod() checking against the X-OpenSim-Godkey HTTP request header. last, i added XML doc comments to RestPlugin.cs --- OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | 58 +++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'OpenSim/ApplicationPlugins/Rest/RestPlugin.cs') diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs index 8c370ed..4b8cdc1 100644 --- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs +++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs @@ -240,9 +240,15 @@ namespace OpenSim.ApplicationPlugins.Rest } } - private List _handlers = new List(); + /// + /// Add a REST stream handler to the underlying HTTP server. + /// + /// GET/PUT/POST/DELETE or + /// similar + /// URL prefix + /// RestMethod handler doing the actual work public virtual void AddRestStreamHandler(string httpMethod, string path, RestMethod method) { if (!IsEnabled) return; @@ -259,20 +265,50 @@ namespace OpenSim.ApplicationPlugins.Rest m_log.DebugFormat("{0} Added REST handler {1} {2}", MsgID, httpMethod, path); } - public bool AddAgentHandler(string agentname, IHttpAgentHandler handler) + /// + /// Add a powerful Agent handler to the underlying HTTP + /// server. + /// + /// name of agent handler + /// agent handler method + /// true when the plugin is disabled or the agent + /// handler could not be added.. + public bool AddAgentHandler(string agentName, IHttpAgentHandler handler) { if (!IsEnabled) return false; - return _httpd.AddAgentHandler(agentname, handler); + return _httpd.AddAgentHandler(agentName, handler); } + /// + /// Check whether the HTTP request came from god; that is, is + /// the god_key as configured in the config section supplied + /// via X-OpenSim-Godkey? + /// + /// HTTP request header + /// true when the HTTP request came from god. protected bool IsGod(OSHttpRequest request) { - string[] keys = request.Headers.GetValues("x-opensim-godkey"); + string[] keys = request.Headers.GetValues("X-OpenSim-Godkey"); if (null == keys) return false; + // we take the last key supplied return keys[keys.Length-1] == _godkey; } + /// + /// Checks wether the X-OpenSim-Password value provided in the + /// HTTP header is indeed the password on file for the avatar + /// specified by the UUID + /// + protected bool IsVerifiedUser(OSHttpRequest request, LLUUID uuid) + { + // XXX under construction + return false; + } + + /// + /// Clean up and remove all handlers that were added earlier. + /// public virtual void Close() { foreach (RestStreamHandler h in _handlers) @@ -282,12 +318,26 @@ namespace OpenSim.ApplicationPlugins.Rest _handlers = null; } + /// + /// Return a failure message. + /// + /// origin of the failure message + /// {0}", message); } + /// + /// Return a failure message. + /// + /// origin of the failure message + /// exception causing the failure message + /// This should probably set a return code as + /// well. (?) public string Failure(string method, Exception e) { m_log.DebugFormat("{0} {1} failed: {2}", MsgID, method, e.ToString()); -- cgit v1.1