You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2013/04/26 18:53:49 UTC

svn commit: r1476288 - in /qpid/trunk/qpid/java: ./ broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/ broker-plugins/management-http/src/main/java/resources/ broker-plugins/management-http/src/main/java/resources/js...

Author: orudyy
Date: Fri Apr 26 16:53:46 2013
New Revision: 1476288

URL: http://svn.apache.org/r1476288
Log:
QPID-4777: Add UI to view and edit web management configuration

Added:
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementHttp.html
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementJmx.html
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPlugin.html
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java
Modified:
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
    qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java
    qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java
    qpid/trunk/qpid/java/build.xml
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java Fri Apr 26 16:53:46 2013
@@ -138,15 +138,11 @@ public class HttpManagement extends Abst
         put(PluginFactory.PLUGIN_TYPE, String.class);
     }});
 
-    private final Broker _broker;
-
     private Server _server;
 
     public HttpManagement(UUID id, Broker broker, Map<String, Object> attributes)
     {
-        super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), broker.getTaskExecutor());
-        _broker = broker;
-        addParent(Broker.class, broker);
+        super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), broker);
     }
 
     @Override
@@ -169,7 +165,7 @@ public class HttpManagement extends Abst
     {
         CurrentActor.get().message(ManagementConsoleMessages.STARTUP(OPERATIONAL_LOGGING_NAME));
 
-        Collection<Port> httpPorts = getHttpPorts(_broker.getPorts());
+        Collection<Port> httpPorts = getHttpPorts(getBroker().getPorts());
         _server = createServer(httpPorts);
         try
         {
@@ -195,7 +191,7 @@ public class HttpManagement extends Abst
             }
             catch (Exception e)
             {
-                throw new RuntimeException("Failed to stop http management on port " + getHttpPorts(_broker.getPorts()));
+                throw new RuntimeException("Failed to stop http management on port " + getHttpPorts(getBroker().getPorts()));
             }
         }
 
@@ -203,12 +199,6 @@ public class HttpManagement extends Abst
     }
 
     /** Added for testing purposes */
-    Broker getBroker()
-    {
-        return _broker;
-    }
-
-    /** Added for testing purposes */
     int getSessionTimeout()
     {
         return (Integer)getAttribute(TIME_OUT);
@@ -272,7 +262,7 @@ public class HttpManagement extends Abst
         server.setHandler(root);
 
         // set servlet context attributes for broker and configuration
-        root.getServletContext().setAttribute(HttpManagementUtil.ATTR_BROKER, _broker);
+        root.getServletContext().setAttribute(HttpManagementUtil.ATTR_BROKER, getBroker());
         root.getServletContext().setAttribute(HttpManagementUtil.ATTR_MANAGEMENT_CONFIGURATION, this);
 
         FilterHolder restAuthorizationFilter = new FilterHolder(new ForbiddingAuthorisationFilter());
@@ -297,6 +287,7 @@ public class HttpManagement extends Abst
         addRestServlet(root, "session", VirtualHost.class, Connection.class, Session.class);
         addRestServlet(root, "keystore", KeyStore.class);
         addRestServlet(root, "truststore", TrustStore.class);
+        addRestServlet(root, "plugin", Plugin.class);
 
         root.addServlet(new ServletHolder(new StructureServlet()), "/rest/structure");
         root.addServlet(new ServletHolder(new MessageServlet()), "/rest/message/*");
@@ -438,7 +429,7 @@ public class HttpManagement extends Abst
     @Override
     public SubjectCreator getSubjectCreator(SocketAddress localAddress)
     {
-        return _broker.getSubjectCreator(localAddress);
+        return getBroker().getSubjectCreator(localAddress);
     }
 
 }

Added: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js?rev=1476288&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js (added)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js Fri Apr 26 16:53:46 2013
@@ -0,0 +1,96 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+define(["dojo/_base/xhr",
+        "dojo/parser",
+        "dojo/query",
+        "dojo/_base/connect",
+        "qpid/common/properties",
+        "qpid/common/updater",
+        "qpid/common/util",
+        "dijit/registry",
+        "dojo/_base/event",
+        "dojo/domReady!"],
+       function (xhr, parser, query, connect, properties, updater, util, registry, event) {
+
+           function Plugin(name, parent, controller) {
+               this.name = name;
+               this.controller = controller;
+               this.modelObj = { type: "plugin", name: name };
+               if(parent) {
+                    this.modelObj.parent = {};
+                    this.modelObj.parent[ parent.type] = parent;
+                }
+           }
+
+           Plugin.prototype.getTitle = function() {
+               return "Plugin: " + this.name ;
+           };
+
+           Plugin.prototype.open = function(contentPane) {
+               var that = this;
+               this.contentPane = contentPane;
+               xhr.get({url: "showPlugin.html",
+                        sync: true,
+                        load:  function(data) {
+                            contentPane.containerNode.innerHTML = data;
+                            parser.parse(contentPane.containerNode);
+
+                            that.pluginUpdater = new PluginUpdater(contentPane.containerNode, that.modelObj, that.controller);
+                        }});
+           };
+
+           Plugin.prototype.close = function() {
+               updater.remove( this.pluginUpdater );
+           };
+
+           function PluginUpdater(node, pluginObject, controller)
+           {
+               this.controller = controller;
+               this.name = query(".name", node)[0];
+               this.type = query(".type", node)[0];
+               this.query = "rest/plugin/"+encodeURIComponent(pluginObject.name);
+
+               var that = this;
+
+               xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"})
+                   .then(function(data)
+                         {
+                             that.pluginData = data[0];
+
+                             that.updateHeader();
+
+                             require(["qpid/management/plugin/"+ that.pluginData.pluginType.toLowerCase().replace('-','')],
+                                 function(SpecificPlugin) {
+                                 that.details = new SpecificPlugin(query(".pluginDetails", node)[0], pluginObject, controller);
+                             });
+
+                         });
+
+           }
+
+           PluginUpdater.prototype.updateHeader = function()
+           {
+               this.name.innerHTML = this.pluginData[ "name" ];
+               this.type.innerHTML = this.pluginData[ "pluginType" ];
+           };
+
+           return Plugin;
+       });

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js Fri Apr 26 16:53:46 2013
@@ -33,16 +33,19 @@ define(["dojo/dom",
         "qpid/management/TrustStore",
         "qpid/management/AccessControlProvider",
         "qpid/management/Port",
+        "qpid/management/Plugin",
         "dojo/ready",
         "dojo/domReady!"],
-       function (dom, registry, ContentPane, Broker, VirtualHost, Exchange, Queue, Connection, AuthProvider, GroupProvider, Group, KeyStore, TrustStore, AccessControlProvider, Port, ready) {
+       function (dom, registry, ContentPane, Broker, VirtualHost, Exchange, Queue, Connection, AuthProvider,
+                 GroupProvider, Group, KeyStore, TrustStore, AccessControlProvider, Port, Plugin, ready) {
            var controller = {};
 
            var constructors = { broker: Broker, virtualhost: VirtualHost, exchange: Exchange,
                                 queue: Queue, connection: Connection,
                                 authenticationprovider: AuthProvider, groupprovider: GroupProvider,
                                 group: Group, keystore: KeyStore, truststore: TrustStore,
-                                accesscontrolprovider: AccessControlProvider, port: Port};
+                                accesscontrolprovider: AccessControlProvider, port: Port,
+                                plugin: Plugin};
 
            var tabDiv = dom.byId("managedViews");
 

Added: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js?rev=1476288&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js (added)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js Fri Apr 26 16:53:46 2013
@@ -0,0 +1,170 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+define(["dojo/_base/xhr",
+        "dojo/dom",
+        "dojo/parser",
+        "dojo/query",
+        "dojo/dom-construct",
+        "dojo/_base/connect",
+        "dojo/_base/window",
+        "dojo/_base/event",
+        "dojo/_base/json",
+        "dijit/registry",
+        "qpid/common/util",
+        "qpid/common/properties",
+        "qpid/common/updater",
+        "dijit/form/Button",
+        "dijit/form/ValidationTextBox",
+        "dijit/form/CheckBox",
+        "dijit/form/NumberSpinner",
+        "dojo/domReady!"],
+    function (xhr, dom, parser, query, construct, connect, win, event, json, registry, util, properties, updater) {
+
+        function ManagementHttp(containerNode, pluginObject, controller) {
+            var node = construct.create("div", null, containerNode, "last");
+            var that = this;
+            this.name = pluginObject.name;
+            xhr.get({
+                      url: "plugin/showManagementHttp.html",
+                      sync: true,
+                      load:  function(data) {
+                          node.innerHTML = data;
+                          parser.parse(node);
+
+                          that.managementHttpUpdater= new ManagementHttpUpdater(node, pluginObject, controller);
+                          that.managementHttpUpdater.update(true);
+                          updater.add( that.managementHttpUpdater);
+
+                          var editButton = query(".editPluginButton", node)[0];
+                          connect.connect(registry.byNode(editButton), "onClick", function(evt){ that.edit(); });
+                      }});
+        }
+
+        ManagementHttp.prototype.close = function() {
+            updater.remove( this.managementHttpUpdater );
+        };
+
+        ManagementHttp.prototype.edit = function() {
+          var widgetFactories = [{
+                  name: "name",
+                  createWidget: function(plugin) {
+                      return new dijit.form.ValidationTextBox({
+                        required: true,
+                        value: plugin.name,
+                        disabled: true,
+                        label: "Name:",
+                        regexp: "^[\x20-\x2e\x30-\x7F]{1,255}$",
+                        name: "name"});
+                  }
+              }, {
+                    name: "httpBasicAuthenticationEnabled",
+                    createWidget: function(plugin) {
+                        return new dijit.form.CheckBox({
+                          required: false,
+                          checked: plugin.httpBasicAuthenticationEnabled,
+                          label: "HTTP Basic Authentication Enabled:",
+                          name: "httpBasicAuthenticationEnabled"});
+                }
+              }, {
+                    name: "httpsBasicAuthenticationEnabled",
+                    createWidget: function(plugin) {
+                        return new dijit.form.CheckBox({
+                          required: false,
+                          checked: plugin.httpsBasicAuthenticationEnabled,
+                          label: "HTTPS Basic Authentication Enabled:",
+                          name: "httpsBasicAuthenticationEnabled"});
+                    }
+              }, {
+                    name: "httpSaslAuthenticationEnabled",
+                    createWidget: function(plugin) {
+                        return new dijit.form.CheckBox({
+                          required: false,
+                          checked: plugin.httpSaslAuthenticationEnabled,
+                          label: "HTTP SASL Authentication Enabled:",
+                          name: "httpSaslAuthenticationEnabled"});
+                    }
+              }, {
+                    name: "httpsSaslAuthenticationEnabled",
+                    createWidget: function(plugin) {
+                        return new dijit.form.CheckBox({
+                          required: false,
+                          checked: plugin.httpsSaslAuthenticationEnabled,
+                          label: "HTTPS SASL Authentication Enabled:",
+                          name: "httpsSaslAuthenticationEnabled"});
+                    }
+              }, {
+                    name: "sessionTimeout",
+                    createWidget: function(plugin) {
+                        return new dijit.form.NumberSpinner({
+                          invalidMessage: "Invalid value",
+                          required: false,
+                          value: plugin.sessionTimeout,
+                          smallDelta: 1,
+                          constraints: {min:1,places:0, pattern: "#####"},
+                          label: "Session timeout (s):",
+                          name: "sessionTimeout"
+                        });
+                    }
+              }
+          ];
+          var data = this.managementHttpUpdater.pluginData;
+          util.showSetAttributesDialog(
+              widgetFactories,
+              data,
+              "rest/plugin/" + encodeURIComponent(data.name),
+              "Edit plugin - " + data.name);
+        };
+
+        function ManagementHttpUpdater(node, pluginObject, controller)
+        {
+            this.controller = controller;
+            this.query = "rest/plugin/"+encodeURIComponent(pluginObject.name);
+            this.name = pluginObject.name;
+            this.httpBasicAuthenticationEnabled = query(".httpBasicAuthenticationEnabled", node)[0];
+            this.httpsBasicAuthenticationEnabled = query(".httpsBasicAuthenticationEnabled", node)[0];
+            this.sessionTimeout = query(".sessionTimeout", node)[0];
+            this.httpsSaslAuthenticationEnabled = query(".httpsSaslAuthenticationEnabled", node)[0];
+            this.httpSaslAuthenticationEnabled = query(".httpSaslAuthenticationEnabled", node)[0];
+        }
+
+        ManagementHttpUpdater.prototype.update = function(syncRequest)
+        {
+            var that = this;
+
+            function showBoolean(val)
+            {
+              return "<input type='checkbox' disabled='disabled' "+(val ? "checked='checked'": "")+" />" ;
+            }
+
+            xhr.get({url: this.query, sync: syncRequest ? syncRequest : properties.useSyncGet, handleAs: "json"})
+                .then(function(data) {
+                    that.pluginData = data[0];
+                    that.httpBasicAuthenticationEnabled.innerHTML = showBoolean(that.pluginData.httpBasicAuthenticationEnabled);
+                    that.httpsBasicAuthenticationEnabled.innerHTML = showBoolean(that.pluginData.httpsBasicAuthenticationEnabled);
+                    that.httpsSaslAuthenticationEnabled.innerHTML = showBoolean(that.pluginData.httpsSaslAuthenticationEnabled);
+                    that.httpSaslAuthenticationEnabled.innerHTML = showBoolean(that.pluginData.httpSaslAuthenticationEnabled);
+                    that.sessionTimeout.innerHTML = that.pluginData.sessionTimeout;
+                });
+
+        };
+
+        return ManagementHttp;
+    });

Added: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js?rev=1476288&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js (added)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js Fri Apr 26 16:53:46 2013
@@ -0,0 +1,84 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+define(["dojo/_base/xhr",
+        "dojo/dom",
+        "dojo/parser",
+        "dojo/query",
+        "dojo/dom-construct",
+        "dojo/_base/connect",
+        "dojo/_base/window",
+        "dojo/_base/event",
+        "dojo/_base/json",
+        "dijit/registry",
+        "qpid/common/util",
+        "qpid/common/properties",
+        "qpid/common/updater",
+        "dojo/domReady!"],
+    function (xhr, dom, parser, query, construct, connect, win, event, json, registry, util, properties, updater) {
+
+        function ManagementJmx(containerNode, pluginObject, controller) {
+            var node = construct.create("div", null, containerNode, "last");
+            var that = this;
+            this.name = pluginObject.name;
+            xhr.get({
+                      url: "plugin/showManagementJmx.html",
+                      sync: true,
+                      load:  function(data) {
+                          node.innerHTML = data;
+                          parser.parse(node);
+
+                          that.managementJmxUpdater= new ManagementJmxUpdater(node, pluginObject, controller);
+                          that.managementJmxUpdater.update(true);
+                          updater.add( that.managementJmxUpdater);
+                      }});
+        }
+
+        ManagementJmx.prototype.close = function() {
+            updater.remove( this.managementJmxUpdater );
+        };
+
+        function ManagementJmxUpdater(node, pluginObject, controller)
+        {
+            this.controller = controller;
+            this.query = "rest/plugin/"+encodeURIComponent(pluginObject.name);
+            this.name = pluginObject.name;
+            this.usePlatformMBeanServer = query(".usePlatformMBeanServer", node)[0];
+        }
+
+        ManagementJmxUpdater.prototype.update = function(syncRequest)
+        {
+            var that = this;
+
+            function showBoolean(val)
+            {
+              return "<input type='checkbox' disabled='disabled' "+(val ? "checked='checked'": "")+" />" ;
+            }
+
+            xhr.get({url: this.query, sync: syncRequest ? syncRequest : properties.useSyncGet, handleAs: "json"})
+                .then(function(data) {
+                    that.pluginData = data[0];
+                    that.usePlatformMBeanServer.innerHTML = showBoolean(that.pluginData.usePlatformMBeanServer);
+                });
+
+        };
+
+        return ManagementJmx;
+    });

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js Fri Apr 26 16:53:46 2013
@@ -282,6 +282,8 @@ define(["dojo/_base/xhr",
                  controller.show("truststore", details.truststore, {broker: {type:"broker", name:""}});
                } else if (details.type == 'accesscontrolprovider') {
                  controller.show("accesscontrolprovider", details.accesscontrolprovider, {broker: {type:"broker", name:""}});
+               } else if (details.type == 'plugin') {
+                 controller.show("plugin", details.plugin, {broker: {type:"broker", name:""}});
                }
            };
 

Added: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementHttp.html
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementHttp.html?rev=1476288&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementHttp.html (added)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementHttp.html Fri Apr 26 16:53:46 2013
@@ -0,0 +1,48 @@
+<!--
+ -
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements.  See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership.  The ASF licenses this file
+ - to you under the Apache License, Version 2.0 (the
+ - "License"); you may not use this file except in compliance
+ - with the License.  You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing,
+ - software distributed under the License is distributed on an
+ - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ - KIND, either express or implied.  See the License for the
+ - specific language governing permissions and limitations
+ - under the License.
+ -
+ -->
+<div>
+    <div>
+        <div style="clear:both">
+           <div class="formLabel-labelCell" style="float:left; width: 260px;">Basic Authentication for HTTP enabled:</div>
+           <div class="httpBasicAuthenticationEnabled" style="float:left;"></div><br/>
+        </div>
+        <div style="clear:both">
+           <div class="formLabel-labelCell" style="float:left; width: 260px;">Basic Authentication for HTTPS enabled:</div>
+           <div class="httpsBasicAuthenticationEnabled" style="float:left;"></div><br/>
+        </div>
+        <div style="clear:both">
+           <div class="formLabel-labelCell" style="float:left; width: 260px;">SASL Authentication for HTTP enabled:</div>
+           <div class="httpSaslAuthenticationEnabled" style="float:left;"></div><br/>
+        </div>
+        <div style="clear:both">
+           <div class="formLabel-labelCell" style="float:left; width: 260px;">SASL Authentication for HTTPS enabled:</div>
+           <div class="httpsSaslAuthenticationEnabled" style="float:left;"></div><br/>
+        </div>
+        <div style="clear:both">
+           <div class="formLabel-labelCell" style="float:left; width: 260px;">Session timeout (s):</div>
+           <div class="sessionTimeout" style="float:left;"></div><br/>
+        </div>
+    </div>
+    <br/>
+    <div class="dijitDialogPaneActionBar">
+        <button data-dojo-type="dijit.form.Button" class="editPluginButton" type="button">Edit</button>
+    </div>
+</div>

Added: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementJmx.html
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementJmx.html?rev=1476288&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementJmx.html (added)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/plugin/showManagementJmx.html Fri Apr 26 16:53:46 2013
@@ -0,0 +1,28 @@
+<!--
+ -
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements.  See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership.  The ASF licenses this file
+ - to you under the Apache License, Version 2.0 (the
+ - "License"); you may not use this file except in compliance
+ - with the License.  You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing,
+ - software distributed under the License is distributed on an
+ - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ - KIND, either express or implied.  See the License for the
+ - specific language governing permissions and limitations
+ - under the License.
+ -
+ -->
+<div>
+    <div>
+        <div style="clear:both">
+           <div class="formLabel-labelCell" style="float:left; width: 260px;">Use Platform MBean Server:</div>
+           <div class="usePlatformMBeanServer" style="float:left;"></div><br/>
+        </div>
+    </div>
+</div>

Added: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPlugin.html
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPlugin.html?rev=1476288&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPlugin.html (added)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPlugin.html Fri Apr 26 16:53:46 2013
@@ -0,0 +1,33 @@
+<!--
+ -
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements.  See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership.  The ASF licenses this file
+ - to you under the Apache License, Version 2.0 (the
+ - "License"); you may not use this file except in compliance
+ - with the License.  You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing,
+ - software distributed under the License is distributed on an
+ - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ - KIND, either express or implied.  See the License for the
+ - specific language governing permissions and limitations
+ - under the License.
+ -
+ -->
+<div class="plugin">
+    <div>
+        <div style="both:clear">
+           <div class="formLabel-labelCell" style="float:left; width: 260px;">Name:</div>
+           <div class="name" style="float:left;"></div><br/>
+        </div>
+        <div style="both:clear">
+           <div class="formLabel-labelCell" style="float:left; width: 260px;">Type:</div>
+           <div class="type" style="float:left;"></div><br/>
+        </div>
+    </div>
+    <div class="pluginDetails"></div>
+</div>

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java Fri Apr 26 16:53:46 2013
@@ -54,7 +54,7 @@ public class HttpManagementFactoryTest e
 
         HttpManagement management = (HttpManagement) _pluginFactory.createInstance(_id, _attributes, _broker);
 
-        assertEquals(_broker, management.getBroker());
+        assertEquals(_broker, management.getParent(Broker.class));
         assertEquals(SESSION_TIMEOUT, management.getSessionTimeout());
     }
 

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java Fri Apr 26 16:53:46 2013
@@ -55,11 +55,6 @@ public class HttpManagementTest extends 
         _management = new HttpManagement(_id, _broker, attributes);
     }
 
-    public void testGetBroker()
-    {
-        assertEquals("Unexpected broker", _broker, _management.getBroker());
-    }
-
     public void testGetSessionTimeout()
     {
         assertEquals("Unexpected session timeout", 10000l, _management.getSessionTimeout());

Modified: qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java Fri Apr 26 16:53:46 2013
@@ -89,16 +89,13 @@ public class JMXManagement extends Abstr
         put(PluginFactory.PLUGIN_TYPE, String.class);
     }};
 
-    private final Broker _broker;
     private JMXManagedObjectRegistry _objectRegistry;
 
     private final Map<ConfiguredObject, AMQManagedObject> _children = new HashMap<ConfiguredObject, AMQManagedObject>();
 
     public JMXManagement(UUID id, Broker broker, Map<String, Object> attributes)
     {
-        super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), broker.getTaskExecutor());
-        _broker = broker;
-        addParent(Broker.class, broker);
+        super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), broker);
     }
 
     @Override
@@ -130,9 +127,10 @@ public class JMXManagement extends Abstr
 
     private void start() throws JMException, IOException
     {
+        Broker broker = getBroker();
         Port connectorPort = null;
         Port registryPort = null;
-        Collection<Port> ports = _broker.getPorts();
+        Collection<Port> ports = broker.getPorts();
         for (Port port : ports)
         {
             if (State.QUIESCED.equals(port.getActualState()))
@@ -158,13 +156,13 @@ public class JMXManagement extends Abstr
             throw new IllegalStateException("No JMX RMI port found supporting protocol " + Protocol.RMI);
         }
 
-        _objectRegistry = new JMXManagedObjectRegistry(_broker, connectorPort, registryPort, this);
+        _objectRegistry = new JMXManagedObjectRegistry(broker, connectorPort, registryPort, this);
 
-        _broker.addChangeListener(this);
+        broker.addChangeListener(this);
 
         synchronized (_children)
         {
-            for(VirtualHost virtualHost : _broker.getVirtualHosts())
+            for(VirtualHost virtualHost : broker.getVirtualHosts())
             {
                 if(!_children.containsKey(virtualHost))
                 {
@@ -181,7 +179,7 @@ public class JMXManagement extends Abstr
                     createAdditionalMBeansFromProviders(virtualHost, mbean);
                 }
             }
-            Collection<AuthenticationProvider> authenticationProviders = _broker.getAuthenticationProviders();
+            Collection<AuthenticationProvider> authenticationProviders = broker.getAuthenticationProviders();
             for (AuthenticationProvider authenticationProvider : authenticationProviders)
             {
                 if(authenticationProvider instanceof PasswordCredentialManagingAuthenticationProvider)
@@ -194,7 +192,7 @@ public class JMXManagement extends Abstr
             }
         }
         new Shutdown(_objectRegistry);
-        new ServerInformationMBean(_objectRegistry, _broker);
+        new ServerInformationMBean(_objectRegistry, broker);
         if (LoggingManagementFacade.getCurrentInstance() != null)
         {
             new LoggingManagementMBean(LoggingManagementFacade.getCurrentInstance(), _objectRegistry);
@@ -234,7 +232,7 @@ public class JMXManagement extends Abstr
             }
             _children.clear();
         }
-        _broker.removeChangeListener(this);
+        getBroker().removeChangeListener(this);
         _objectRegistry.close();
     }
 
@@ -352,12 +350,6 @@ public class JMXManagement extends Abstr
         }
     }
 
-    /** Added for testing purposes */
-    Broker getBroker()
-    {
-        return _broker;
-    }
-
     @Override
     public String getName()
     {

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java Fri Apr 26 16:53:46 2013
@@ -26,19 +26,23 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.server.model.Plugin;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.Statistics;
+import org.apache.qpid.server.security.access.Operation;
 
 public abstract class AbstractPluginAdapter extends AbstractAdapter implements Plugin
 {
+    private Broker _broker;
 
-    protected AbstractPluginAdapter(UUID id, Map<String, Object> defaults, Map<String, Object> attributes, TaskExecutor taskExecutor)
+    protected AbstractPluginAdapter(UUID id, Map<String, Object> defaults, Map<String, Object> attributes, Broker broker)
     {
-        super(id, defaults, attributes, taskExecutor);
+        super(id, defaults, attributes, broker.getTaskExecutor());
+        _broker = broker;
+        addParent(Broker.class, broker);
     }
 
     @Override
@@ -104,13 +108,6 @@ public abstract class AbstractPluginAdap
     }
 
     @Override
-    public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes,
-            ConfiguredObject... otherParents)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public Collection<String> getAttributeNames()
     {
         return AVAILABLE_ATTRIBUTES;
@@ -149,4 +146,46 @@ public abstract class AbstractPluginAdap
         }
         return super.getAttribute(name);
     }
+
+    @Override
+    public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes,
+            ConfiguredObject... otherParents)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    protected void authoriseSetDesiredState(State currentState, State desiredState) throws AccessControlException
+    {
+        if(desiredState == State.DELETED)
+        {
+            if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), Plugin.class, Operation.DELETE))
+            {
+                throw new AccessControlException("Deletion of plugin is denied");
+            }
+        }
+    }
+
+    @Override
+    protected void authoriseSetAttribute(String name, Object expected, Object desired) throws AccessControlException
+    {
+        if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), Plugin.class, Operation.UPDATE))
+        {
+            throw new AccessControlException("Setting of plugin attribute is denied");
+        }
+    }
+
+    @Override
+    protected void authoriseSetAttributes(Map<String, Object> attributes) throws AccessControlException
+    {
+        if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), Plugin.class, Operation.UPDATE))
+        {
+            throw new AccessControlException("Setting of plugin attributes is denied");
+        }
+    }
+
+    protected Broker getBroker()
+    {
+        return _broker;
+    }
 }

Modified: qpid/trunk/qpid/java/build.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/build.xml?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/build.xml (original)
+++ qpid/trunk/qpid/java/build.xml Fri Apr 26 16:53:46 2013
@@ -37,7 +37,7 @@
   <property name="modules.plugin"     value="${broker-plugins} ${client-plugins}"/>
   <property name="modules.jca"        value="jca"/>
   <property name="modules"            value="${modules.core} ${modules.examples}
-   ${modules.jca} ${modules.tests} ${modules.plugin} ${modules.opt}"/>
+   ${modules.jca} ${modules.plugin} ${modules.tests} ${modules.opt}"/>
 
   <property name="qpid.jar"           location="${build.lib}/qpid-all.jar"/>
   <basename property="qpid.jar.name"  file="${qpid.jar}"/>

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java Fri Apr 26 16:53:46 2013
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
 import org.apache.qpid.server.model.AccessControlProvider;
 import org.apache.qpid.server.security.access.FileAccessControlProviderConstants;
 import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -56,7 +57,7 @@ public class AccessControlProviderRestTe
         getRestTestHelper().configureTemporaryPasswordFile(this, ALLOWED_USER, DENIED_USER, OTHER_USER);
 
         getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT,
-                "httpBasicAuthenticationEnabled", true);
+                HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
     }
 
     public void testCreateAccessControlProvider() throws Exception

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java Fri Apr 26 16:53:46 2013
@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.Port;
@@ -39,7 +40,7 @@ public class AnonymousAccessRestTest ext
         // set anonymous authentication provider on http port for the tests
         config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.AUTHENTICATION_PROVIDER,
                 TestBrokerConfiguration.ENTRY_NAME_ANONYMOUS_PROVIDER);
-        config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", false);
+        config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, false);
 
         // reset credentials
         getRestTestHelper().setUsernameAndPassword(null, null);

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java Fri Apr 26 16:53:46 2013
@@ -30,6 +30,7 @@ import java.util.Collections;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -86,7 +87,7 @@ public class BasicAuthRestTest extends Q
     public void testBasicAuthWhenDisabledWithHttp() throws Exception
     {
         configure(false);
-        getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", false);
+        getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, false);
         super.setUp();
 
         // Try the attempt with authentication, it should fail because
@@ -99,7 +100,7 @@ public class BasicAuthRestTest extends Q
     {
         configure(false);
 
-        getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", true);
+        getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
         super.setUp();
 
         // Try the attempt with authentication, it should succeed because

Added: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java?rev=1476288&view=auto
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java (added)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java Fri Apr 26 16:53:46 2013
@@ -0,0 +1,69 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.systest.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.qpid.server.management.plugin.HttpManagement;
+import org.apache.qpid.test.utils.TestBrokerConfiguration;
+
+public class HttpManagementRestTest extends QpidRestTestCase
+{
+
+    public void testGetHttpManagement() throws Exception
+    {
+        Map<String, Object> details = getRestTestHelper().getJsonAsSingletonList(
+                "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+
+        assertEquals("Unexpected session timeout", HttpManagement.DEFAULT_TIMEOUT_IN_SECONDS,
+                details.get(HttpManagement.TIME_OUT));
+        assertEquals("Unexpected http basic auth enabled", true,
+                details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected https basic auth enabled", HttpManagement.DEFAULT_HTTPS_BASIC_AUTHENTICATION_ENABLED,
+                details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected http sasl auth enabled", HttpManagement.DEFAULT_HTTP_SASL_AUTHENTICATION_ENABLED,
+                details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected https sasl auth enabled", HttpManagement.DEFAULT_HTTPS_SASL_AUTHENTICATION_ENABLED,
+                details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
+    }
+
+    public void testUpdateAttributes() throws Exception
+    {
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(HttpManagement.NAME, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+        attributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.TIME_OUT, 10000);
+
+        getRestTestHelper().submitRequest("/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
+
+        Map<String, Object> details = getRestTestHelper().getJsonAsSingletonList(
+                "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+
+        assertEquals("Unexpected session timeout", 10000, details.get(HttpManagement.TIME_OUT));
+        assertEquals("Unexpected http basic auth enabled", true, details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected https basic auth enabled", false, details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected http sasl auth enabled", false, details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected https sasl auth enabled", false, details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
+    }
+}

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java Fri Apr 26 16:53:46 2013
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory;
@@ -98,7 +99,7 @@ public class QpidRestTestCase extends Qp
         // set password authentication provider on http port for the tests
         config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.AUTHENTICATION_PROVIDER,
                 TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER);
-        config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", true);
+        config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
     }
 
     public RestTestHelper getRestTestHelper()

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java Fri Apr 26 16:53:46 2013
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
 import org.apache.qpid.server.model.AccessControlProvider;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
@@ -74,7 +75,7 @@ public class BrokerACLTest extends QpidR
                 "ACL DENY-LOG ALL ALL";
 
         getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT,
-                "httpBasicAuthenticationEnabled", true);
+                HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
     }
 
     /* === AuthenticationProvider === */
@@ -877,6 +878,63 @@ public class BrokerACLTest extends QpidR
         assertEquals("Setting of access control provider attributes should be denied", 403, responseCode);
     }
 
+    /* === HTTP management === */
+
+    public void testSetHttpManagementAttributesAllowed() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(HttpManagement.NAME, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+        attributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.TIME_OUT, 10000);
+
+        int responseCode = getRestTestHelper().submitRequest(
+                "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
+        assertEquals("Setting of http management should be allowed", 200, responseCode);
+
+        Map<String, Object> details = getRestTestHelper().getJsonAsSingletonList(
+                "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+
+        assertEquals("Unexpected session timeout", 10000, details.get(HttpManagement.TIME_OUT));
+        assertEquals("Unexpected http basic auth enabled", true, details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected https basic auth enabled", false, details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected http sasl auth enabled", false, details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected https sasl auth enabled", false, details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
+    }
+
+    public void testSetHttpManagementAttributesDenied() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
+
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(HttpManagement.NAME, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+        attributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, false);
+        attributes.put(HttpManagement.TIME_OUT, 10000);
+
+        int responseCode = getRestTestHelper().submitRequest(
+                "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
+        assertEquals("Setting of http management should be denied", 403, responseCode);
+
+        Map<String, Object> details = getRestTestHelper().getJsonAsSingletonList(
+                "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+
+        assertEquals("Unexpected session timeout", HttpManagement.DEFAULT_TIMEOUT_IN_SECONDS,
+                details.get(HttpManagement.TIME_OUT));
+        assertEquals("Unexpected http basic auth enabled", true,
+                details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected https basic auth enabled", HttpManagement.DEFAULT_HTTPS_BASIC_AUTHENTICATION_ENABLED,
+                details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected http sasl auth enabled", HttpManagement.DEFAULT_HTTP_SASL_AUTHENTICATION_ENABLED,
+                details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
+        assertEquals("Unexpected https sasl auth enabled", HttpManagement.DEFAULT_HTTPS_SASL_AUTHENTICATION_ENABLED,
+                details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
+    }
+
     /* === Utility Methods === */
 
     private int createPort(String portName) throws Exception

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java Fri Apr 26 16:53:46 2013
@@ -29,6 +29,7 @@ import java.util.Properties;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
 import org.apache.qpid.server.security.acl.AbstractACLTestCase;
 import org.apache.qpid.systest.rest.QpidRestTestCase;
 import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -60,7 +61,7 @@ public class GroupRestACLTest extends Qp
     protected void customizeConfiguration() throws ConfigurationException, IOException
     {
         super.customizeConfiguration();
-        getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", true);
+        getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
     }
 
     @Override

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java?rev=1476288&r1=1476287&r2=1476288&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java Fri Apr 26 16:53:46 2013
@@ -29,6 +29,7 @@ import java.util.Properties;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
 import org.apache.qpid.server.security.acl.AbstractACLTestCase;
 import org.apache.qpid.systest.rest.QpidRestTestCase;
 import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -62,7 +63,7 @@ public class UserRestACLTest extends Qpi
     protected void customizeConfiguration() throws ConfigurationException, IOException
     {
         super.customizeConfiguration();
-        getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", true);
+        getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
     }
 
     @Override



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org