[ 
https://issues.apache.org/jira/browse/ARTEMIS-3808?focusedWorklogId=769825&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-769825
 ]

ASF GitHub Bot logged work on ARTEMIS-3808:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/May/22 19:02
            Start Date: 12/May/22 19:02
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on code in PR #4061:
URL: https://github.com/apache/activemq-artemis/pull/4061#discussion_r871717708


##########
artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java:
##########
@@ -193,87 +203,97 @@ public void configure(ComponentDTO config, String 
artemisInstance, String artemi
       instanceContext.setResourceBase(instanceWarDir.toString());
       instanceContext.setHandler(instanceResourceHandler);
       instanceContext.setVirtualHosts(virtualHosts);
-      
homeContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", 
"false");
+      homeContext.setInitParameter(DIR_ALLOWED, "false");
 
       DefaultHandler defaultHandler = new DefaultHandler();
       defaultHandler.setServeIcon(false);
 
-      if (webServerConfig.requestLog != null) {
+      if (this.config.requestLog != null) {
          handlers.addHandler(getLogHandler());
       }
       handlers.addHandler(homeContext);
       handlers.addHandler(instanceContext);
       handlers.addHandler(defaultHandler); // this should be last
 
       server.setHandler(handlers);
-   }
 
-   private RequestLogHandler getLogHandler() {
-      RequestLogWriter requestLogWriter = new RequestLogWriter();
-      CustomRequestLog requestLog;
+      cleanupTmp();
+      server.start();
 
-      // required via config so no check necessary
-      requestLogWriter.setFilename(webServerConfig.requestLog.filename);
+      ActiveMQWebLogger.LOGGER.webserverStarted(bindings
+                                                   .stream()
+                                                   .map(binding -> binding.uri)
+                                                   
.collect(Collectors.joining(", ")));
 
-      if (webServerConfig.requestLog.append != null) {
-         requestLogWriter.setAppend(webServerConfig.requestLog.append);
-      }
+      ActiveMQWebLogger.LOGGER.jolokiaAvailable(String.join(", ", 
jolokiaUrls));
+      ActiveMQWebLogger.LOGGER.consoleAvailable(String.join(", ", 
consoleUrls));
+   }
 
-      if (webServerConfig.requestLog.filenameDateFormat != null) {
-         
requestLogWriter.setFilenameDateFormat(webServerConfig.requestLog.filenameDateFormat);
-      }
+   private ServerConnector createServerConnector(HttpConfiguration 
httpConfiguration,
+                                              int i,
+                                              BindingDTO binding,
+                                              URI uri,
+                                              String scheme) throws Exception {
+      ServerConnector connector;
 
-      if (webServerConfig.requestLog.retainDays != null) {
-         requestLogWriter.setRetainDays(webServerConfig.requestLog.retainDays);
-      }
+      if ("https".equals(scheme)) {
+         SslContextFactory.Server sslFactory = new SslContextFactory.Server();
+         sslFactory.setKeyStorePath(binding.keyStorePath == null ? 
artemisInstance + "/etc/keystore.jks" : binding.keyStorePath);
+         sslFactory.setKeyStorePassword(binding.getKeyStorePassword() == null 
? "password" : binding.getKeyStorePassword());
 
-      if (webServerConfig.requestLog.format != null) {
-         requestLog = new CustomRequestLog(requestLogWriter, 
webServerConfig.requestLog.format);
-      } else if (webServerConfig.requestLog.extended != null && 
webServerConfig.requestLog.extended) {
-         requestLog = new CustomRequestLog(requestLogWriter, 
CustomRequestLog.EXTENDED_NCSA_FORMAT);
-      } else {
-         requestLog = new CustomRequestLog(requestLogWriter, 
CustomRequestLog.NCSA_FORMAT);
-      }
-
-      if (webServerConfig.requestLog.ignorePaths != null && 
webServerConfig.requestLog.ignorePaths.length() > 0) {
-         String[] split = webServerConfig.requestLog.ignorePaths.split(",");
-         String[] ignorePaths = new String[split.length];
-         for (int i = 0; i < ignorePaths.length; i++) {
-            ignorePaths[i] = split[i].trim();
+         if (binding.getIncludedTLSProtocols() != null) {
+            sslFactory.setIncludeProtocols(binding.getIncludedTLSProtocols());
+         }
+         if (binding.getExcludedTLSProtocols() != null) {
+            sslFactory.setExcludeProtocols(binding.getExcludedTLSProtocols());
+         }
+         if (binding.getIncludedCipherSuites() != null) {
+            
sslFactory.setIncludeCipherSuites(binding.getIncludedCipherSuites());
+         }
+         if (binding.getExcludedCipherSuites() != null) {
+            
sslFactory.setExcludeCipherSuites(binding.getExcludedCipherSuites());
+         }
+         if (binding.clientAuth != null) {
+            sslFactory.setNeedClientAuth(binding.clientAuth);
+            if (binding.clientAuth) {
+               sslFactory.setTrustStorePath(binding.trustStorePath);
+               
sslFactory.setTrustStorePassword(binding.getTrustStorePassword());
+            }
          }
-         requestLog.setIgnorePaths(ignorePaths);
-      }
 
-      RequestLogHandler requestLogHandler = new RequestLogHandler();
-      requestLogHandler.setRequestLog(requestLog);
-      return requestLogHandler;
-   }
+         SslConnectionFactory sslConnectionFactory = new 
SslConnectionFactory(sslFactory, "HTTP/1.1");
 
-   @Override
-   public void start() throws Exception {
-      if (isStarted()) {
-         return;
-      }
-      cleanupTmp();
-      server.start();
+         httpConfiguration.addCustomizer(new SecureRequestCustomizer());
+         httpConfiguration.setSendServerVersion(false);
+         HttpConnectionFactory httpFactory = new 
HttpConnectionFactory(httpConfiguration);
 
-      String bindings = webServerConfig.getBindings()
-            .stream()
-            .map(binding -> binding.uri)
-            .collect(Collectors.joining(", "));
-      ActiveMQWebLogger.LOGGER.webserverStarted(bindings);
+         connector = new ServerConnector(server, sslConnectionFactory, 
httpFactory);
 
-      ActiveMQWebLogger.LOGGER.jolokiaAvailable(String.join(", ", 
jolokiaUrls));
-      ActiveMQWebLogger.LOGGER.consoleAvailable(String.join(", ", 
consoleUrls));
+      } else {
+         httpConfiguration.setSendServerVersion(false);
+         ConnectionFactory connectionFactory = new 
HttpConnectionFactory(httpConfiguration);
+         connector = new ServerConnector(server, connectionFactory);
+      }
+      connector.setPort(uri.getPort());
+      connector.setHost(uri.getHost());
+      connector.setName("Connector-" + i);
+      return connector;
    }
 
    public void internalStop() throws Exception {
+      ActiveMQWebLogger.LOGGER.stoppingEmbeddedWebServer();

Review Comment:
   Resolved by moving this into `stop(boolean)`.



##########
artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java:
##########
@@ -53,115 +54,122 @@
 import org.eclipse.jetty.webapp.WebAppContext;
 import org.jboss.logging.Logger;
 
-public class WebServerComponent implements ExternalComponent {
+public class WebServerComponent implements ExternalComponent, 
WebServerComponentMarker {
 
    private static final Logger logger = 
Logger.getLogger(WebServerComponent.class);
+   public static final String DIR_ALLOWED = 
"org.eclipse.jetty.servlet.Default.dirAllowed";
 
    private Server server;
    private HandlerList handlers;
-   private WebServerDTO webServerConfig;
+   private WebServerDTO config;
    private final List<String> consoleUrls = new ArrayList<>();
    private final List<String> jolokiaUrls = new ArrayList<>();
-   private List<WebAppContext> webContexts;
+   private List<WebAppContext> webContexts = new ArrayList<>();;

Review Comment:
   Done.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 769825)
    Time Spent: 3h 50m  (was: 3h 40m)

> Support starting/stopping the embedded web server via mangement
> ---------------------------------------------------------------
>
>                 Key: ARTEMIS-3808
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3808
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Justin Bertram
>            Assignee: Justin Bertram
>            Priority: Major
>          Time Spent: 3h 50m
>  Remaining Estimate: 0h
>
> It would be useful to be able to cycle the embedded web server if, for 
> example, one needed to renew the SSL certificates.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to