This commit is contained in:
Justin Bertram 2020-03-18 10:01:41 -05:00
commit 5a52aa22a6
4 changed files with 23 additions and 7 deletions

View File

@ -47,6 +47,9 @@ public class WebServerDTO extends ComponentDTO {
@XmlAttribute
public String trustStorePath;
@XmlAttribute
public String customizer;
@XmlElementRef
public List<AppDTO> apps;

View File

@ -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);
}

View File

@ -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());

View File

@ -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`