qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1416521 - in /qpid/branches/java-broker-config-qpid-4390/qpid/java: broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/ broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugi...
Date Mon, 03 Dec 2012 13:55:04 GMT
Author: orudyy
Date: Mon Dec  3 13:55:02 2012
New Revision: 1416521

URL: http://svn.apache.org/viewvc?rev=1416521&view=rev
Log:
QPID-4390: remove references to ApplicationRegistry from http management console

Modified:
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageContentServlet.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/VirtualHost.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
Mon Dec  3 13:55:02 2012
@@ -30,6 +30,7 @@ import org.apache.qpid.server.logging.ac
 import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
 import org.apache.qpid.server.management.plugin.servlet.DefinedFileServlet;
 import org.apache.qpid.server.management.plugin.servlet.FileServlet;
+import org.apache.qpid.server.management.plugin.servlet.rest.AbstractServlet;
 import org.apache.qpid.server.management.plugin.servlet.rest.LogRecordsServlet;
 import org.apache.qpid.server.management.plugin.servlet.rest.LogoutServlet;
 import org.apache.qpid.server.management.plugin.servlet.rest.MessageContentServlet;
@@ -207,6 +208,12 @@ public class HttpManagement extends Abst
         root.setContextPath("/");
         server.setHandler(root);
 
+        // set servlet context attributes for broker, configuration, security manager and
ports
+        root.getServletContext().setAttribute(AbstractServlet.ATTR_BROKER, _broker);
+        root.getServletContext().setAttribute(AbstractServlet.ATTR_CONFIGURATION, _configuration);
+        root.getServletContext().setAttribute(AbstractServlet.ATTR_SECURITY_MANAGER, _broker.getSecurityManager());
+        root.getServletContext().setAttribute(AbstractServlet.ATTR_PORTS, ports);
+
         addRestServlet(root, "broker");
         addRestServlet(root, "virtualhost", VirtualHost.class);
         addRestServlet(root, "authenticationprovider", AuthenticationProvider.class);
@@ -221,13 +228,13 @@ public class HttpManagement extends Abst
         addRestServlet(root, "port", Port.class);
         addRestServlet(root, "session", VirtualHost.class, Connection.class, Session.class);
 
-        root.addServlet(new ServletHolder(new StructureServlet(_broker,  _configuration)),
"/rest/structure");
-        root.addServlet(new ServletHolder(new MessageServlet(_broker,  _configuration)),
"/rest/message/*");
-        root.addServlet(new ServletHolder(new MessageContentServlet(_broker, _configuration)),
"/rest/message-content/*");
+        root.addServlet(new ServletHolder(new StructureServlet()), "/rest/structure");
+        root.addServlet(new ServletHolder(new MessageServlet()), "/rest/message/*");
+        root.addServlet(new ServletHolder(new MessageContentServlet()), "/rest/message-content/*");
 
-        root.addServlet(new ServletHolder(new LogRecordsServlet(_broker, _configuration)),
"/rest/logrecords");
+        root.addServlet(new ServletHolder(new LogRecordsServlet()), "/rest/logrecords");
 
-        root.addServlet(new ServletHolder(new SaslServlet(_broker, _configuration)), "/rest/sasl");
+        root.addServlet(new ServletHolder(new SaslServlet()), "/rest/sasl");
 
         root.addServlet(new ServletHolder(new DefinedFileServlet("index.html")), ENTRY_POINT_PATH);
         root.addServlet(new ServletHolder(new LogoutServlet()), "/logout");
@@ -252,7 +259,7 @@ public class HttpManagement extends Abst
 
     private void addRestServlet(ServletContextHandler root, String name, Class<? extends
ConfiguredObject>... hierarchy)
     {
-        root.addServlet(new ServletHolder(new RestServlet(_broker, _configuration, hierarchy)),
"/rest/" + name + "/*");
+        root.addServlet(new ServletHolder(new RestServlet(hierarchy)), "/rest/" + name +
"/*");
     }
 
     private void checkKeyStorePath(String keyStorePath)

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
Mon Dec  3 13:55:02 2012
@@ -26,9 +26,11 @@ import java.net.SocketAddress;
 import java.security.AccessControlException;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Collection;
 
 import javax.security.auth.Subject;
 import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -44,7 +46,7 @@ import org.apache.qpid.server.logging.ac
 import org.apache.qpid.server.management.plugin.HttpConfiguration;
 import org.apache.qpid.server.management.plugin.session.LoginLogoutReporter;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
@@ -55,55 +57,53 @@ public abstract class AbstractServlet ex
 {
     private static final Logger LOGGER = Logger.getLogger(AbstractServlet.class);
 
+    /**
+     * Servlet context attribute holding a reference to a broker instance
+     */
+    public static final String ATTR_BROKER = "Qpid.broker";
+
+    /**
+     * Servlet context attribute holding a reference to plugin configuration
+     */
+    public static final String ATTR_CONFIGURATION = "Qpid.configuration";
+
+    /**
+     * Servlet context attribute holding a reference to a security manager
+     */
+    public static final String ATTR_SECURITY_MANAGER = "Qpid.securityManager";
+
+    /**
+     * Servlet context attribute holding a reference to a collection of http ports
+     */
+    public static final String ATTR_PORTS = "Qpid.ports";
+
     private static final String ATTR_LOGIN_LOGOUT_REPORTER = "AbstractServlet.loginLogoutReporter";
     private static final String ATTR_SUBJECT = "AbstractServlet.subject";
     private static final String ATTR_LOG_ACTOR = "AbstractServlet.logActor";
 
-    private static final String HTTP_BASIC_AUTHENTICATION_ENABLED = "http-basic-authentication-enabled";
-    private static final String HTTPS_BASIC_AUTHENTICATION_ENABLED = "https-basic-authentication-enabled";
-
-    private final Broker _broker;
-
+    private Broker _broker;
     private RootMessageLogger _rootLogger;
-
-    private volatile boolean initializationRequired = false;
-    private boolean _httpBasicAuthenticationEnabled;
-    private boolean _httpsBasicAuthenticationEnabled;
+    private HttpConfiguration _configuration;
+    private Collection<Port> _ports;
+    private SecurityManager _securityManager;
 
     protected AbstractServlet()
     {
         super();
-        _broker = ApplicationRegistry.getInstance().getBroker();
-        _rootLogger = ApplicationRegistry.getInstance().getRootMessageLogger();
-    }
-
-    protected AbstractServlet(Broker broker, HttpConfiguration configuration)
-    {
-        _broker = broker;
-        _rootLogger = ApplicationRegistry.getInstance().getRootMessageLogger();
-        _httpBasicAuthenticationEnabled = configuration.isHttpBasicAuthenticationEnabled();
-        _httpsBasicAuthenticationEnabled = configuration.isHttpsBasicAuthenticationEnabled();
-        initializationRequired = false;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public void init() throws ServletException
     {
-        if (initializationRequired)
-        {
-            doInitialization();
-            initializationRequired = false;
-        }
-        super.init();
-    }
-
-    private void doInitialization()
-    {
         ServletConfig servletConfig = getServletConfig();
-        String httpSaslAuthentication = servletConfig.getInitParameter(HTTP_BASIC_AUTHENTICATION_ENABLED);
-        String httpsSaslAuthentication = servletConfig.getInitParameter(HTTPS_BASIC_AUTHENTICATION_ENABLED);
-        _httpBasicAuthenticationEnabled = Boolean.parseBoolean(httpSaslAuthentication);
-        _httpsBasicAuthenticationEnabled = httpsSaslAuthentication == null ? true : Boolean.parseBoolean(httpsSaslAuthentication);
+        ServletContext servletContext = servletConfig.getServletContext();
+        _broker = (Broker)servletContext.getAttribute(ATTR_BROKER);
+        _rootLogger = _broker.getRootMessageLogger();
+        _configuration = (HttpConfiguration)servletContext.getAttribute(ATTR_CONFIGURATION);
+        _securityManager = (SecurityManager)servletContext.getAttribute(ATTR_SECURITY_MANAGER);
+        _ports = (Collection<Port>)servletContext.getAttribute(ATTR_PORTS);
+        super.init();
     }
 
     @Override
@@ -295,7 +295,7 @@ public abstract class AbstractServlet ex
             return subject;
         }
 
-        SubjectCreator subjectCreator = ApplicationRegistry.getInstance().getSubjectCreator(getSocketAddress(request));
+        SubjectCreator subjectCreator = getSubjectCreator(getSocketAddress(request));
         subject = authenticate(request, subjectCreator);
         if (subject != null)
         {
@@ -310,6 +310,20 @@ public abstract class AbstractServlet ex
         return subject;
     }
 
+    protected SubjectCreator getSubjectCreator(SocketAddress localAddress)
+    {
+        InetSocketAddress inetSocketAddress = (InetSocketAddress)localAddress;
+        Collection<Port> ports = _ports == null ? _broker.getPorts() : _ports;
+        for (Port p : ports)
+        {
+            if (inetSocketAddress.getPort() == p.getPort())
+            {
+                return p.getAuthenticationProvider().getSubjectCreator();
+            }
+        }
+        return null;
+    }
+
     protected void authoriseManagement(HttpServletRequest request, Subject subject)
     {
         // TODO: We should eliminate SecurityManager.setThreadSubject in favour of Subject.doAs
@@ -325,7 +339,7 @@ public abstract class AbstractServlet ex
                     @Override
                     public Void run() throws Exception
                     {
-                        boolean allowed = ApplicationRegistry.getInstance().getSecurityManager().accessManagement();
+                        boolean allowed = _securityManager.accessManagement();
                         if (!allowed)
                         {
                             throw new AccessControlException("User is not authorised for
management");
@@ -414,7 +428,8 @@ public abstract class AbstractServlet ex
 
     private boolean isBasicAuthSupported(HttpServletRequest req)
     {
-        return req.isSecure()  ? _httpsBasicAuthenticationEnabled : _httpBasicAuthenticationEnabled;
+        return req.isSecure()  ? _configuration.isHttpsBasicAuthenticationEnabled()
+                : _configuration.isHttpBasicAuthenticationEnabled();
     }
 
     private HttpManagementActor getLogActorAndCacheInSession(HttpServletRequest req)
@@ -472,13 +487,14 @@ public abstract class AbstractServlet ex
         return new HttpManagementActor(_rootLogger, request.getRemoteAddr(), request.getRemotePort());
     }
 
-    /**
-     * Only should be called from init method
-     */
-    protected boolean isInitializationRequired()
+    protected HttpConfiguration getConfiguration()
     {
-        return initializationRequired;
+        return _configuration;
     }
 
+    protected SecurityManager getSecurityManager()
+    {
+        return _securityManager;
+    }
 
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java
Mon Dec  3 13:55:02 2012
@@ -26,9 +26,6 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.apache.qpid.server.logging.LogRecorder;
-import org.apache.qpid.server.management.plugin.HttpConfiguration;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
 
@@ -39,11 +36,6 @@ public class LogRecordsServlet extends A
         super();
     }
 
-    public LogRecordsServlet(Broker broker, HttpConfiguration configuration)
-    {
-        super(broker, configuration);
-    }
-
     @Override
     protected void doGetWithSubjectAndActor(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException
     {
@@ -54,10 +46,10 @@ public class LogRecordsServlet extends A
         response.setHeader("Pragma","no-cache");
         response.setDateHeader ("Expires", 0);
 
-        ApplicationRegistry applicationRegistry = (ApplicationRegistry) ApplicationRegistry.getInstance();
         List<Map<String,Object>> logRecords = new ArrayList<Map<String,
Object>>();
 
-        for(LogRecorder.Record record : applicationRegistry.getLogRecorder())
+        LogRecorder logRecorder = getBroker().getLogRecorder();
+        for(LogRecorder.Record record : logRecorder)
         {
             logRecords.add(logRecordToObject(record));
         }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageContentServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageContentServlet.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageContentServlet.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageContentServlet.java
Mon Dec  3 13:55:02 2012
@@ -27,10 +27,8 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.qpid.server.management.plugin.HttpConfiguration;
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.queue.QueueEntry;
@@ -43,11 +41,6 @@ public class MessageContentServlet exten
         super();
     }
 
-    public MessageContentServlet(Broker broker, HttpConfiguration configuration)
-    {
-        super(broker, configuration);
-    }
-
     @Override
     protected void doGetWithSubjectAndActor(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException
     {

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java
Mon Dec  3 13:55:02 2012
@@ -31,17 +31,13 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.management.plugin.HttpConfiguration;
 import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.queue.QueueEntryVisitor;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.IApplicationRegistry;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.subscription.Subscription;
@@ -57,11 +53,6 @@ public class MessageServlet extends Abst
         super();
     }
 
-    public MessageServlet(Broker broker, HttpConfiguration configuration)
-    {
-        super(broker, configuration);
-    }
-
     @Override
     protected void doGetWithSubjectAndActor(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException
     {
@@ -423,7 +414,7 @@ public class MessageServlet extends Abst
             // FIXME: added temporary authorization check until we introduce management layer
             // and review current ACL rules to have common rules for all management interfaces
             String methodName = isMoveTransaction? "moveMessages":"copyMessages";
-            if (isQueueUpdateMethodAuthorized(methodName, vhost.getName()))
+            if (isQueueUpdateMethodAuthorized(methodName, vhost))
             {
                 final Queue destinationQueue = getQueueFromVirtualHost(destQueueName, vhost);
                 final List messageIds = new ArrayList((List) providedObject.get("messages"));
@@ -467,7 +458,7 @@ public class MessageServlet extends Abst
 
         // FIXME: added temporary authorization check until we introduce management layer
         // and review current ACL rules to have common rules for all management interfaces
-        if (isQueueUpdateMethodAuthorized("deleteMessages", vhost.getName()))
+        if (isQueueUpdateMethodAuthorized("deleteMessages", vhost))
         {
             vhost.executeTransaction(new DeleteTransaction(sourceQueue, messageIds));
             response.setStatus(HttpServletResponse.SC_OK);
@@ -479,25 +470,10 @@ public class MessageServlet extends Abst
 
     }
 
-    private boolean isQueueUpdateMethodAuthorized(String methodName, String virtualHost)
+    private boolean isQueueUpdateMethodAuthorized(String methodName, VirtualHost host)
     {
-        SecurityManager securityManager = getSecurityManager(virtualHost);
+        SecurityManager securityManager = host.getSecurityManager();
         return securityManager.authoriseMethod(Operation.UPDATE, "VirtualHost.Queue", methodName);
     }
 
-    private SecurityManager getSecurityManager(String virtualHost)
-    {
-        IApplicationRegistry appRegistry = ApplicationRegistry.getInstance();
-        SecurityManager security;
-        if (virtualHost == null)
-        {
-            security = appRegistry.getSecurityManager();
-        }
-        else
-        {
-            security = appRegistry.getVirtualHostRegistry().getVirtualHost(virtualHost).getSecurityManager();
-        }
-        return security;
-    }
-
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
Mon Dec  3 13:55:02 2012
@@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.log4j.Logger;
 import org.apache.qpid.AMQSecurityException;
-import org.apache.qpid.server.management.plugin.HttpConfiguration;
 import org.apache.qpid.server.model.*;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
@@ -49,24 +48,27 @@ public class RestServlet extends Abstrac
     private Class<? extends ConfiguredObject>[] _hierarchy;
 
     private final ConfiguredObjectToMapConverter _objectConverter = new ConfiguredObjectToMapConverter();
+    private final boolean _hierarchyInitializationRequired;
 
     public RestServlet()
     {
         super();
+        _hierarchyInitializationRequired = true;
     }
 
-    public RestServlet(Broker broker, HttpConfiguration configuration, Class<? extends
ConfiguredObject>... hierarchy)
+    public RestServlet(Class<? extends ConfiguredObject>... hierarchy)
     {
-        super(broker, configuration);
+        super();
         _hierarchy = hierarchy;
+        _hierarchyInitializationRequired = false;
     }
 
     @Override
     public void init() throws ServletException
     {
-        if (isInitializationRequired())
+        super.init();
+        if (_hierarchyInitializationRequired)
         {
-            super.init();
             doInitialization();
         }
     }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
Mon Dec  3 13:55:02 2012
@@ -26,15 +26,12 @@ import org.codehaus.jackson.map.Serializ
 
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.management.plugin.HttpConfiguration;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.auth.AuthenticatedPrincipal;
 
 import javax.security.auth.Subject;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
-import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -50,8 +47,6 @@ import java.util.Random;
 
 public class SaslServlet extends AbstractServlet
 {
-    private static final String HTTPS_SASL_AUTHENTICATION_ENABLED = "https-sasl-authentication-enabled";
-    private static final String HTTP_SASL_AUTHENTICATION_ENABLED = "http-sasl-authentication-enabled";
 
     private static final Logger LOGGER = Logger.getLogger(SaslServlet.class);
 
@@ -62,40 +57,11 @@ public class SaslServlet extends Abstrac
     private static final String ATTR_EXPIRY = "SaslServlet.Expiry";
     private static final long SASL_EXCHANGE_EXPIRY = 1000L;
 
-    private boolean _httpSaslAuthenticationEnabled;
-    private boolean _httpsSaslAuthenticationEnabled;
-
     public SaslServlet()
     {
         super();
     }
 
-    public SaslServlet(Broker broker, HttpConfiguration configuration)
-    {
-        super(broker, configuration);
-        _httpSaslAuthenticationEnabled = configuration.isHttpSaslAuthenticationEnabled();
-        _httpsSaslAuthenticationEnabled = configuration.isHttpsSaslAuthenticationEnabled();
-    }
-
-    @Override
-    public void init() throws ServletException
-    {
-        if (isInitializationRequired())
-        {
-            super.init();
-            doInitialization();
-        }
-    }
-
-    private void doInitialization()
-    {
-        ServletConfig servletConfig = getServletConfig();
-        String httpSaslAuthentication = servletConfig.getInitParameter(HTTP_SASL_AUTHENTICATION_ENABLED);
-        String httpsSaslAuthentication = servletConfig.getInitParameter(HTTPS_SASL_AUTHENTICATION_ENABLED);
-        _httpSaslAuthenticationEnabled = httpSaslAuthentication == null ? true : Boolean.parseBoolean(httpSaslAuthentication);
-        _httpsSaslAuthenticationEnabled = httpsSaslAuthentication == null ? true : Boolean.parseBoolean(httpsSaslAuthentication);
-    }
-
     protected void doGetWithSubjectAndActor(HttpServletRequest request, HttpServletResponse
response) throws
                                                                                    ServletException,
                                                                                    IOException
@@ -110,7 +76,7 @@ public class SaslServlet extends Abstrac
         HttpSession session = request.getSession();
         getRandom(session);
 
-        SubjectCreator subjectCreator = ApplicationRegistry.getInstance().getSubjectCreator(getSocketAddress(request));
+        SubjectCreator subjectCreator = getSubjectCreator(getSocketAddress(request));
         String[] mechanisms = subjectCreator.getMechanisms().split(" ");
         Map<String, Object> outputObject = new LinkedHashMap<String, Object>();
 
@@ -168,7 +134,7 @@ public class SaslServlet extends Abstrac
             String id = request.getParameter("id");
             String saslResponse = request.getParameter("response");
 
-            SubjectCreator subjectCreator = ApplicationRegistry.getInstance().getSubjectCreator(getSocketAddress(request));
+            SubjectCreator subjectCreator = getSubjectCreator(getSocketAddress(request));
 
             if(mechanism != null)
             {
@@ -230,13 +196,14 @@ public class SaslServlet extends Abstrac
     private void checkSaslAuthEnabled(HttpServletRequest request)
     {
         boolean saslAuthEnabled;
+        HttpConfiguration configuration = getConfiguration();
         if (request.isSecure())
         {
-            saslAuthEnabled = _httpsSaslAuthenticationEnabled;
+            saslAuthEnabled = configuration.isHttpsSaslAuthenticationEnabled();
         }
         else
         {
-            saslAuthEnabled = _httpSaslAuthenticationEnabled;
+            saslAuthEnabled = configuration.isHttpSaslAuthenticationEnabled();
         }
 
         if (!saslAuthEnabled)

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java
Mon Dec  3 13:55:02 2012
@@ -28,7 +28,6 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.qpid.server.management.plugin.HttpConfiguration;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Model;
@@ -42,11 +41,6 @@ public class StructureServlet extends Ab
         super();
     }
 
-    public StructureServlet(Broker broker, HttpConfiguration configuration)
-    {
-        super(broker, configuration);
-    }
-
     @Override
     protected void doGetWithSubjectAndActor(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException
     {

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
Mon Dec  3 13:55:02 2012
@@ -26,6 +26,10 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 
+import org.apache.qpid.server.logging.LogRecorder;
+import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.security.SecurityManager;
+
 public interface Broker extends ConfiguredObject
 {
 
@@ -104,4 +108,21 @@ public interface Broker extends Configur
 
     Collection<GroupProvider> getGroupProviders();
 
+    /**
+     * A temporary hack to expose root message logger via broker instance.
+     * TODO We need a better way to do operational logging, for example, via logging listeners
+     */
+    RootMessageLogger getRootMessageLogger();
+
+    /**
+     * A temporary hack to expose security manager via broker instance.
+     * TODO We need to add and implement an authorization provider configured object instead
+     */
+    SecurityManager getSecurityManager();
+
+    /**
+     * TODO: A temporary hack to expose log recorder via broker instance.
+     */
+    LogRecorder getLogRecorder();
+
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/VirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/VirtualHost.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/VirtualHost.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/VirtualHost.java
Mon Dec  3 13:55:02 2012
@@ -21,6 +21,8 @@
 package org.apache.qpid.server.model;
 
 import org.apache.qpid.server.queue.QueueEntry;
+import org.apache.qpid.server.security.SecurityManager;
+
 import java.security.AccessControlException;
 import java.util.Arrays;
 import java.util.Collection;
@@ -149,4 +151,10 @@ public interface VirtualHost extends Con
     }
 
     void executeTransaction(TransactionalOperation op);
+
+    /**
+     * A temporary hack to expose host security manager.
+     * TODO We need to add and implement an authorization provider configured object instead
+     */
+    SecurityManager getSecurityManager();
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
Mon Dec  3 13:55:02 2012
@@ -45,7 +45,6 @@ import org.apache.qpid.server.model.Stat
 import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.model.User;
 import org.apache.qpid.server.model.VirtualHostAlias;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.security.auth.UsernamePrincipal;
@@ -53,12 +52,14 @@ import org.apache.qpid.server.security.a
 import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
 import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
 import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
+import org.apache.qpid.server.security.SecurityManager;
 
 public abstract class AuthenticationProviderAdapter<T extends AuthenticationManager>
extends AbstractAdapter implements AuthenticationProvider
 {
     private static final Logger LOGGER = Logger.getLogger(AuthenticationProviderAdapter.class);
 
     private final T _authManager;
+    protected final Broker _broker;
 
     private GroupPrincipalAccessor _groupAccessor;
 
@@ -66,6 +67,7 @@ public abstract class AuthenticationProv
     {
         super(id);
         _authManager = authManager;
+        _broker = broker;
         addParent(Broker.class, broker);
     }
 
@@ -287,9 +289,9 @@ public abstract class AuthenticationProv
             }
         }
 
-        private org.apache.qpid.server.security.SecurityManager getSecurityManager()
+        private SecurityManager getSecurityManager()
         {
-            return ApplicationRegistry.getInstance().getSecurityManager();
+            return _broker.getSecurityManager();
         }
 
         private PrincipalDatabase getPrincipalDatabase()

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
Mon Dec  3 13:55:02 2012
@@ -37,6 +37,8 @@ import org.apache.log4j.Logger;
 import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.server.configuration.BrokerProperties;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.logging.LogRecorder;
+import org.apache.qpid.server.logging.RootMessageLogger;
 import org.apache.qpid.server.logging.actors.BrokerActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.model.AuthenticationProvider;
@@ -51,6 +53,7 @@ import org.apache.qpid.server.model.Stat
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.registry.IApplicationRegistry;
 import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
+import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.stats.StatisticsGatherer;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 
@@ -693,4 +696,21 @@ public class BrokerAdapter extends Abstr
         }
     }
 
+    @Override
+    public RootMessageLogger getRootMessageLogger()
+    {
+        return _applicationRegistry.getRootMessageLogger();
+    }
+
+    @Override
+    public SecurityManager getSecurityManager()
+    {
+        return _applicationRegistry.getSecurityManager();
+    }
+
+    @Override
+    public LogRecorder getLogRecorder()
+    {
+        return _applicationRegistry.getLogRecorder();
+    }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
Mon Dec  3 13:55:02 2012
@@ -38,15 +38,15 @@ import org.apache.qpid.server.model.Life
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.Statistics;
 import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.security.group.GroupManager;
+import org.apache.qpid.server.security.SecurityManager;
 
 public class GroupProviderAdapter extends AbstractAdapter implements
         GroupProvider
 {
     private final GroupManager _groupManager;
-
+    private final Broker _broker;
     public GroupProviderAdapter(UUID id, GroupManager groupManager, Broker broker)
     {
         super(id);
@@ -56,6 +56,7 @@ public class GroupProviderAdapter extend
             throw new IllegalArgumentException("GroupManager must not be null");
         }
         _groupManager = groupManager;
+        _broker = broker;
        addParent(Broker.class, broker);
     }
 
@@ -218,9 +219,9 @@ public class GroupProviderAdapter extend
         }
     }
 
-    private org.apache.qpid.server.security.SecurityManager getSecurityManager()
+    private SecurityManager getSecurityManager()
     {
-        return ApplicationRegistry.getInstance().getSecurityManager();
+        return _broker.getSecurityManager();
     }
 
     private class GroupAdapter extends AbstractAdapter implements Group

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
Mon Dec  3 13:55:02 2012
@@ -951,4 +951,10 @@ public final class VirtualHostAdapter ex
         return false;
     }
 
+    @Override
+    public SecurityManager getSecurityManager()
+    {
+        return _virtualHost.getSecurityManager();
+    }
+
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
Mon Dec  3 13:55:02 2012
@@ -492,11 +492,13 @@ public class ApplicationRegistry impleme
         logActor.message(BrokerMessages.MAX_MEMORY(Runtime.getRuntime().maxMemory()));
     }
 
+    @Override
     public Broker getBroker()
     {
         return _broker;
     }
 
+    @Override
     public LogRecorder getLogRecorder()
     {
         return _logRecorder;

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java?rev=1416521&r1=1416520&r2=1416521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
(original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
Mon Dec  3 13:55:02 2012
@@ -22,6 +22,7 @@ package org.apache.qpid.server.registry;
 
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
+import org.apache.qpid.server.logging.LogRecorder;
 import org.apache.qpid.server.logging.RootMessageLogger;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.security.SecurityManager;
@@ -74,4 +75,6 @@ public interface IApplicationRegistry ex
     VirtualHost createVirtualHost(VirtualHostConfiguration vhostConfig) throws Exception;
 
     void initialiseStatisticsReporting();
+
+    LogRecorder getLogRecorder();
 }



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


Mime
View raw message