diff --git a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/WebServerDTO.java b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/WebServerDTO.java index 292ceff815..4cc627a151 100644 --- a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/WebServerDTO.java +++ b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/WebServerDTO.java @@ -47,6 +47,9 @@ public class WebServerDTO extends ComponentDTO { @XmlAttribute public String trustStorePath; + @XmlAttribute + public String customizer; + @XmlElementRef public List apps; diff --git a/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java b/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java index a273c24850..59d115d1dd 100644 --- a/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java +++ b/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java @@ -58,4 +58,8 @@ public interface ActiveMQWebLogger extends BasicLogger { @LogMessage(level = Logger.Level.INFO) @Message(id = 241004, value = "Artemis Console available at {0}", format = Message.Format.MESSAGE_FORMAT) void consoleAvailable(String bind); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 244005, value = "Web customizer {0} not loaded: {1}", format = Message.Format.MESSAGE_FORMAT) + void customizerNotLoaded(String customizer, Throwable t); } diff --git a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java index e20bbedee1..9f74e0d666 100644 --- a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java +++ b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java @@ -68,6 +68,16 @@ public class WebServerComponent implements ExternalComponent { server = new Server(); String scheme = uri.getScheme(); + HttpConfiguration httpConfiguration = new HttpConfiguration(); + + if (webServerConfig.customizer != null) { + try { + httpConfiguration.addCustomizer((HttpConfiguration.Customizer) Class.forName(webServerConfig.customizer).getConstructor().newInstance()); + } catch (Throwable t) { + ActiveMQWebLogger.LOGGER.customizerNotLoaded(webServerConfig.customizer, t); + } + } + if ("https".equals(scheme)) { SslContextFactory.Server sslFactory = new SslContextFactory.Server(); sslFactory.setKeyStorePath(webServerConfig.keyStorePath == null ? artemisInstance + "/etc/keystore.jks" : webServerConfig.keyStorePath); @@ -96,17 +106,15 @@ public class WebServerComponent implements ExternalComponent { SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslFactory, "HTTP/1.1"); - HttpConfiguration https = new HttpConfiguration(); - https.addCustomizer(new SecureRequestCustomizer()); - https.setSendServerVersion(false); - HttpConnectionFactory httpFactory = new HttpConnectionFactory(https); + httpConfiguration.addCustomizer(new SecureRequestCustomizer()); + httpConfiguration.setSendServerVersion(false); + HttpConnectionFactory httpFactory = new HttpConnectionFactory(httpConfiguration); connector = new ServerConnector(server, sslConnectionFactory, httpFactory); } else { - HttpConfiguration configuration = new HttpConfiguration(); - configuration.setSendServerVersion(false); - ConnectionFactory connectionFactory = new HttpConnectionFactory(configuration); + httpConfiguration.setSendServerVersion(false); + ConnectionFactory connectionFactory = new HttpConnectionFactory(httpConfiguration); connector = new ServerConnector(server, connectionFactory); } connector.setPort(uri.getPort()); diff --git a/docs/user-manual/en/web-server.md b/docs/user-manual/en/web-server.md index 88853051bd..7dc8ce1471 100644 --- a/docs/user-manual/en/web-server.md +++ b/docs/user-manual/en/web-server.md @@ -26,6 +26,7 @@ The `web` element has the following attributes: - `path` The name of the subdirectory in which to find the web application archives (i.e. WAR files). This is a subdirectory of the broker's home or instance directory. +- `customizer` The name of customizer class to load. - `clientAuth` Whether or not clients should present an SSL certificate when they connect. Only applicable when using `https`. - `passwordCodec` The custom coded to use for unmasking the `keystorePassword`