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 2012/11/07 10:10:15 UTC
svn commit: r1406505 - 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...
Author: orudyy
Date: Wed Nov 7 09:10:15 2012
New Revision: 1406505
URL: http://svn.apache.org/viewvc?rev=1406505&view=rev
Log:
QPID-4390: WIP - Add configuration POJO for http management plugin and remove references to ServerConfiguration from http management plugin
Added:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpConfiguration.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
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.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/configuration/store/XMLConfigurationEntryStore.java
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpConfiguration.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/HttpConfiguration.java?rev=1406505&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpConfiguration.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpConfiguration.java Wed Nov 7 09:10:15 2012
@@ -0,0 +1,82 @@
+/*
+ *
+ * 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.server.management.plugin;
+
+public class HttpConfiguration
+{
+ private final int _sessionTimeout;
+ private final boolean _httpBasicAuthenticationEnabled;
+ private final boolean _httpsBasicAuthenticationEnabled;
+ private final boolean _httpSaslAuthenticationEnabled;
+ private final boolean _httpsSaslAuthenticationEnabled;
+
+ private final String _keyStorePath;
+ private final String _keyStorePassword;
+
+ public HttpConfiguration(int sessionTimeout, boolean httpBasicAuthenticationEnabled, boolean httpsBasicAuthenticationEnabled,
+ boolean httpSaslAuthenticationEnabled, boolean httpsSaslAuthenticationEnabled, String keyStorePath, String keyStorePassword)
+ {
+ super();
+ _sessionTimeout = sessionTimeout;
+ _httpBasicAuthenticationEnabled = httpBasicAuthenticationEnabled;
+ _httpsBasicAuthenticationEnabled = httpsBasicAuthenticationEnabled;
+ _httpSaslAuthenticationEnabled = httpSaslAuthenticationEnabled;
+ _httpsSaslAuthenticationEnabled = httpsSaslAuthenticationEnabled;
+ _keyStorePath = keyStorePath;
+ _keyStorePassword = keyStorePassword;
+ }
+
+ public int getSessionTimeout()
+ {
+ return _sessionTimeout;
+ }
+
+ public boolean isHttpSaslAuthenticationEnabled()
+ {
+ return _httpSaslAuthenticationEnabled;
+ }
+
+ public boolean isHttpBasicAuthenticationEnabled()
+ {
+ return _httpBasicAuthenticationEnabled;
+ }
+
+ public boolean isHttpsSaslAuthenticationEnabled()
+ {
+ return _httpsSaslAuthenticationEnabled;
+ }
+
+ public boolean isHttpsBasicAuthenticationEnabled()
+ {
+ return _httpsBasicAuthenticationEnabled;
+ }
+
+ public String getKeyStorePath()
+ {
+ return _keyStorePath;
+ }
+
+ public String getKeyStorePassword()
+ {
+ return _keyStorePassword;
+ }
+
+}
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=1406505&r1=1406504&r2=1406505&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 Wed Nov 7 09:10:15 2012
@@ -76,18 +76,14 @@ public class HttpManagement extends Abst
private final Map<Integer, Server> _servers = new ConcurrentHashMap<Integer, Server>();
- private String _keyStorePassword;
- private String _keyStorePath;
- private int _sessionTimeout;
+ private final HttpConfiguration _configuration;
// XXX refactor back to use a single instance of server and add connectors for different ports
- public HttpManagement(UUID id, Broker broker, String keyStorePath, String keyStorePassword, int sessionTimeout)
+ public HttpManagement(UUID id, Broker broker, HttpConfiguration configuration)
{
super(id);
_broker = broker;
- _keyStorePassword = keyStorePassword;
- _keyStorePath = keyStorePath;
- _sessionTimeout = sessionTimeout;
+ _configuration = configuration;
addParent(Broker.class, broker);
}
@@ -149,19 +145,19 @@ public class HttpManagement extends Abst
/** Added for testing purposes */
String getKeyStorePassword()
{
- return _keyStorePassword;
+ return _configuration.getKeyStorePassword();
}
/** Added for testing purposes */
String getKeyStorePath()
{
- return _keyStorePath;
+ return _configuration.getKeyStorePath();
}
/** Added for testing purposes */
int getSessionTimeout()
{
- return _sessionTimeout;
+ return _configuration.getSessionTimeout();
}
protected void stopServer(Port port)
@@ -221,11 +217,12 @@ public class HttpManagement extends Abst
}
else if (protocols.contains(Protocol.HTTPS))
{
- checkKeyStorePath(_keyStorePath);
+ String keyStorePath = _configuration.getKeyStorePath();
+ checkKeyStorePath(keyStorePath);
SslContextFactory factory = new SslContextFactory();
- factory.setKeyStorePath(_keyStorePath);
- factory.setKeyStorePassword(_keyStorePassword);
+ factory.setKeyStorePath(keyStorePath);
+ factory.setKeyStorePassword(_configuration.getKeyStorePassword());
connector = new SslSocketConnector(factory);
}
@@ -254,13 +251,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)), "/rest/structure");
- root.addServlet(new ServletHolder(new MessageServlet(_broker)), "/rest/message/*");
- root.addServlet(new ServletHolder(new MessageContentServlet(_broker)), "/rest/message-content/*");
+ 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 LogRecordsServlet(_broker)), "/rest/logrecords");
+ root.addServlet(new ServletHolder(new LogRecordsServlet(_broker, _configuration)), "/rest/logrecords");
- root.addServlet(new ServletHolder(new SaslServlet(_broker)), "/rest/sasl");
+ root.addServlet(new ServletHolder(new SaslServlet(_broker, _configuration)), "/rest/sasl");
root.addServlet(new ServletHolder(new DefinedFileServlet("index.html")), ENTRY_POINT_PATH);
root.addServlet(new ServletHolder(new LogoutServlet()), "/logout");
@@ -278,14 +275,14 @@ public class HttpManagement extends Abst
final SessionManager sessionManager = root.getSessionHandler().getSessionManager();
- sessionManager.setMaxInactiveInterval(_sessionTimeout);
+ sessionManager.setMaxInactiveInterval(_configuration.getSessionTimeout());
return server;
}
private void addRestServlet(ServletContextHandler root, String name, Class<? extends ConfiguredObject>... hierarchy)
{
- root.addServlet(new ServletHolder(new RestServlet(_broker, hierarchy)), "/rest/" + name + "/*");
+ root.addServlet(new ServletHolder(new RestServlet(_broker, _configuration, 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/HttpManagementFactory.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/HttpManagementFactory.java?rev=1406505&r1=1406504&r2=1406505&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java Wed Nov 7 09:10:15 2012
@@ -18,6 +18,10 @@
*/
package org.apache.qpid.server.management.plugin;
+import static org.apache.qpid.server.util.MapValueConverter.getBooleanAttribute;
+import static org.apache.qpid.server.util.MapValueConverter.getStringAttribute;
+import static org.apache.qpid.server.util.MapValueConverter.getIntegerAttribute;
+
import java.util.Map;
import java.util.UUID;
@@ -34,10 +38,13 @@ public class HttpManagementFactory imple
public static final String TIME_OUT = "sessionTimeout";
public static final String KEY_STORE_PATH = "keyStorePath";
public static final String KEY_STORE_PASSWORD = "keyStorePassword";
+ public static final String HTTP_BASIC_AUTHENTICATION_ENABLED = "httpBasicAuthenticationEnabled";
+ public static final String HTTPS_BASIC_AUTHENTICATION_ENABLED = "httpsBasicAuthenticationEnabled";
+ public static final String HTTP_SASL_AUTHENTICATION_ENABLED = "httpSaslAuthenticationEnabled";
+ public static final String HTTPS_SASL_AUTHENTICATION_ENABLED = "httpsSaslAuthenticationEnabled";
public static final String PLUGIN_NAME = "MANAGEMENT-HTTP";
- // XXX create a configuration POJO containing SASL and basic auth configuration
@Override
public ConfiguredObject createInstance(UUID id, Map<String, Object> attributes, Broker broker)
{
@@ -45,9 +52,16 @@ public class HttpManagementFactory imple
{
return null;
}
- Integer sessionTimeout = MapValueConverter.getIntegerAttribute(TIME_OUT, attributes, DEFAULT_TIMEOUT_IN_SECONDS);
- String keyStorePath = MapValueConverter.getStringAttribute(KEY_STORE_PATH, attributes, null);
- String keyStorePasssword = MapValueConverter.getStringAttribute(KEY_STORE_PASSWORD, attributes, null);
- return new HttpManagement( id, broker, keyStorePath, keyStorePasssword, sessionTimeout);
+
+ HttpConfiguration configuration = new HttpConfiguration(
+ getIntegerAttribute(TIME_OUT, attributes, DEFAULT_TIMEOUT_IN_SECONDS),
+ getBooleanAttribute(HTTP_BASIC_AUTHENTICATION_ENABLED, attributes, false),
+ getBooleanAttribute(HTTPS_BASIC_AUTHENTICATION_ENABLED, attributes, true),
+ getBooleanAttribute(HTTP_SASL_AUTHENTICATION_ENABLED, attributes, true),
+ getBooleanAttribute(HTTPS_SASL_AUTHENTICATION_ENABLED, attributes, true),
+ getStringAttribute(KEY_STORE_PATH, attributes, null),
+ getStringAttribute(KEY_STORE_PASSWORD, attributes, null)
+ );
+ return new HttpManagement( id, broker, configuration);
}
}
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=1406505&r1=1406504&r2=1406505&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 Wed Nov 7 09:10:15 2012
@@ -28,6 +28,7 @@ import java.security.PrivilegedActionExc
import java.security.PrivilegedExceptionAction;
import javax.security.auth.Subject;
+import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -40,6 +41,7 @@ import org.apache.qpid.server.logging.Lo
import org.apache.qpid.server.logging.RootMessageLogger;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.actors.HttpManagementActor;
+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;
@@ -57,10 +59,17 @@ public abstract class AbstractServlet ex
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 RootMessageLogger _rootLogger;
+ private volatile boolean initializationRequired = false;
+ private boolean _httpBasicAuthenticationEnabled;
+ private boolean _httpsBasicAuthenticationEnabled;
+
protected AbstractServlet()
{
super();
@@ -68,10 +77,33 @@ public abstract class AbstractServlet ex
_rootLogger = ApplicationRegistry.getInstance().getRootMessageLogger();
}
- protected AbstractServlet(Broker broker)
+ protected AbstractServlet(Broker broker, HttpConfiguration configuration)
{
_broker = broker;
_rootLogger = ApplicationRegistry.getInstance().getRootMessageLogger();
+ _httpBasicAuthenticationEnabled = configuration.isHttpBasicAuthenticationEnabled();
+ _httpsBasicAuthenticationEnabled = configuration.isHttpsBasicAuthenticationEnabled();
+ initializationRequired = false;
+ }
+
+ @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);
}
@Override
@@ -380,11 +412,9 @@ public abstract class AbstractServlet ex
return subject;
}
- // XXX remove reference on ServerConfiguration
private boolean isBasicAuthSupported(HttpServletRequest req)
{
- return req.isSecure() ? ApplicationRegistry.getInstance().getConfiguration().getHTTPSManagementBasicAuth()
- : ApplicationRegistry.getInstance().getConfiguration().getHTTPManagementBasicAuth();
+ return req.isSecure() ? _httpsBasicAuthenticationEnabled : _httpBasicAuthenticationEnabled;
}
private HttpManagementActor getLogActorAndCacheInSession(HttpServletRequest req)
@@ -442,5 +472,13 @@ public abstract class AbstractServlet ex
return new HttpManagementActor(_rootLogger, request.getRemoteAddr(), request.getRemotePort());
}
+ /**
+ * Only should be called from init method
+ */
+ protected boolean isInitializationRequired()
+ {
+ return initializationRequired;
+ }
+
}
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=1406505&r1=1406504&r2=1406505&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 Wed Nov 7 09:10:15 2012
@@ -26,6 +26,7 @@ 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;
@@ -35,12 +36,12 @@ public class LogRecordsServlet extends A
{
public LogRecordsServlet()
{
- super(ApplicationRegistry.getInstance().getBroker());
+ super();
}
- public LogRecordsServlet(Broker broker)
+ public LogRecordsServlet(Broker broker, HttpConfiguration configuration)
{
- super(broker);
+ super(broker, configuration);
}
@Override
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=1406505&r1=1406504&r2=1406505&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 Wed Nov 7 09:10:15 2012
@@ -27,6 +27,7 @@ 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;
@@ -42,9 +43,9 @@ public class MessageContentServlet exten
super();
}
- public MessageContentServlet(Broker broker)
+ public MessageContentServlet(Broker broker, HttpConfiguration configuration)
{
- super(broker);
+ super(broker, configuration);
}
@Override
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=1406505&r1=1406504&r2=1406505&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 Wed Nov 7 09:10:15 2012
@@ -31,6 +31,7 @@ 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;
@@ -56,9 +57,9 @@ public class MessageServlet extends Abst
super();
}
- public MessageServlet(Broker broker)
+ public MessageServlet(Broker broker, HttpConfiguration configuration)
{
- super(broker);
+ super(broker, configuration);
}
@Override
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=1406505&r1=1406504&r2=1406505&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 Wed Nov 7 09:10:15 2012
@@ -28,6 +28,7 @@ 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;
@@ -47,29 +48,26 @@ public class RestServlet extends Abstrac
private Class<? extends ConfiguredObject>[] _hierarchy;
- private volatile boolean initializationRequired = false;
-
private final ConfiguredObjectToMapConverter _objectConverter = new ConfiguredObjectToMapConverter();
public RestServlet()
{
super();
- initializationRequired = true;
}
- public RestServlet(Broker broker, Class<? extends ConfiguredObject>... hierarchy)
+ public RestServlet(Broker broker, HttpConfiguration configuration, Class<? extends ConfiguredObject>... hierarchy)
{
- super(broker);
+ super(broker, configuration);
_hierarchy = hierarchy;
}
@Override
public void init() throws ServletException
{
- if (initializationRequired)
+ if (isInitializationRequired())
{
+ super.init();
doInitialization();
- initializationRequired = false;
}
}
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=1406505&r1=1406504&r2=1406505&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 Wed Nov 7 09:10:15 2012
@@ -25,6 +25,7 @@ import org.codehaus.jackson.map.ObjectMa
import org.codehaus.jackson.map.SerializationConfig;
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;
@@ -33,6 +34,7 @@ import org.apache.qpid.server.security.a
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;
@@ -48,6 +50,9 @@ 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);
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
@@ -57,15 +62,38 @@ 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)
+ 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()
{
- super(broker);
+ 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
@@ -200,12 +228,11 @@ public class SaslServlet extends Abstrac
boolean saslAuthEnabled;
if (request.isSecure())
{
- // XXX replace getHTTPSManagementSaslAuthEnabled with access to a field set from config
- saslAuthEnabled = ApplicationRegistry.getInstance().getConfiguration().getHTTPSManagementSaslAuthEnabled();
+ saslAuthEnabled = _httpsSaslAuthenticationEnabled;
}
else
{
- saslAuthEnabled = ApplicationRegistry.getInstance().getConfiguration().getHTTPManagementSaslAuthEnabled();
+ saslAuthEnabled = _httpSaslAuthenticationEnabled;
}
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=1406505&r1=1406504&r2=1406505&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 Wed Nov 7 09:10:15 2012
@@ -28,6 +28,7 @@ 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;
@@ -41,9 +42,9 @@ public class StructureServlet extends Ab
super();
}
- public StructureServlet(Broker broker)
+ public StructureServlet(Broker broker, HttpConfiguration configuration)
{
- super(broker);
+ super(broker, configuration);
}
@Override
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java?rev=1406505&r1=1406504&r2=1406505&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java Wed Nov 7 09:10:15 2012
@@ -331,6 +331,10 @@ public class XMLConfigurationEntryStore
attributes.put("keyStorePath", serverConfiguration.getManagementKeyStorePath());
attributes.put("keyStorePassword", serverConfiguration.getManagementKeyStorePassword());
attributes.put("sessionTimeout", serverConfiguration.getHTTPManagementSessionTimeout());
+ attributes.put("httpBasicAuthenticationEnabled", serverConfiguration.getHTTPManagementBasicAuth());
+ attributes.put("httpsBasicAuthenticationEnabled", serverConfiguration.getHTTPSManagementBasicAuth());
+ attributes.put("httpSaslAuthenticationEnabled", serverConfiguration.getHTTPManagementSaslAuthEnabled());
+ attributes.put("httpsSaslAuthenticationEnabled", serverConfiguration.getHTTPSManagementSaslAuthEnabled());
ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.PLUGIN, attributes, null, this);
rootChildren.put(entry.getId(), entry);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org