ARTEMIS-5208 bump Jetty from 10.0.24 to 12.0.15

This commit is contained in:
Justin Bertram 2024-12-05 12:16:13 -06:00 committed by Robbie Gemmell
parent c7c5dce42b
commit 539bd0881c
11 changed files with 72 additions and 62 deletions

View File

@ -525,6 +525,14 @@
<scope>import</scope>
<!-- License: (Joint): Apache 2.0 or EPL 2.0 -->
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-bom</artifactId>
<version>${jetty.version}</version>
<type>pom</type>
<scope>import</scope>
<!-- License: (Joint): Apache 2.0 or EPL 2.0 -->
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-servlet-api</artifactId>

View File

@ -67,21 +67,29 @@
<artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-nested</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-security</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-server</artifactId>

View File

@ -16,10 +16,6 @@
*/
package org.apache.activemq.artemis.component;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import javax.security.auth.Subject;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@ -27,9 +23,13 @@ import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.Session;
/*
* This filter intercepts the login and audits its results
* */
@ -47,7 +47,7 @@ public class AuthenticationFilter implements Filter {
//Successful responses (200 299)
//the user has been authenticated if the session isn't empty
//the hawtio logout servlet cleans the session and redirects to the login servlet
HttpSession session = ((Request) servletRequest).getSession(false);
Session session = ((Request) servletRequest).getSession(false);
if (session != null) {
AuditLogger.userSuccesfullyAuthenticatedInAudit((Subject) session.getAttribute("subject"));
}

View File

@ -16,12 +16,9 @@
*/
package org.apache.activemq.artemis.component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.util.Callback;
public class DefaultHandler extends org.eclipse.jetty.server.handler.DefaultHandler {
private String rootRedirectLocation;
@ -35,14 +32,13 @@ public class DefaultHandler extends org.eclipse.jetty.server.handler.DefaultHand
}
@Override
public void handle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
if (rootRedirectLocation != null && target.matches("^$|/")) {
response.sendRedirect(rootRedirectLocation);
public boolean handle(Request request, Response response, Callback callback) throws Exception {
if (rootRedirectLocation != null && request.getHttpURI().getPath().matches("^$|/")) {
Response.sendRedirect(request, response, callback, Response.toRedirectURI(request, rootRedirectLocation));
callback.succeeded();
return true;
} else {
super.handle(target, baseRequest, request, response);
return super.handle(request, response, callback);
}
}
}

View File

@ -16,9 +16,6 @@
*/
package org.apache.activemq.artemis.component;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.eclipse.jetty.server.Request;
import javax.security.auth.Subject;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@ -26,9 +23,12 @@ import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Session;
/*
* This intercepts all calls made via jolokia
* */
@ -54,7 +54,7 @@ public class JolokiaFilter implements Filter {
* */
if (AuditLogger.isAnyLoggingEnabled()) {
try {
HttpSession session = ((Request) servletRequest).getSession();
Session session = ((Request) servletRequest).getSession(true);
Subject subject = (Subject) session.getAttribute("subject");
AuditLogger.setCurrentCaller(subject);
} catch (Throwable e) {

View File

@ -32,6 +32,7 @@ import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
@ -49,9 +50,12 @@ import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.marker.WebServerComponentMarker;
import org.apache.activemq.artemis.utils.ClassloadingUtil;
import org.apache.activemq.artemis.utils.PemConfigUtil;
import org.eclipse.jetty.security.DefaultAuthenticatorFactory;
import org.eclipse.jetty.ee8.security.DefaultAuthenticatorFactory;
import org.eclipse.jetty.ee8.servlet.FilterHolder;
import org.eclipse.jetty.ee8.webapp.WebAppContext;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.CustomRequestLog;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.RequestLog;
@ -61,14 +65,11 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.util.Scanner;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -77,7 +78,6 @@ import static org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport.chec
public class WebServerComponent implements ExternalComponent, WebServerComponentMarker {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static final String DIR_ALLOWED = "org.eclipse.jetty.servlet.Default.dirAllowed";
// this should match the value of <display-name> in the console war's WEB-INF/web.xml
public static final String WEB_CONSOLE_DISPLAY_NAME = System.getProperty("org.apache.activemq.artemis.webConsoleDisplayName", "hawtio");
@ -91,7 +91,7 @@ public class WebServerComponent implements ExternalComponent, WebServerComponent
public static final int DEFAULT_SCAN_PERIOD_VALUE = 5;
private Server server;
private HandlerList handlers;
private Handler.Sequence handlers;
private WebServerDTO webServerConfig;
private final List<String> consoleUrls = new ArrayList<>();
private final List<String> jolokiaUrls = new ArrayList<>();
@ -134,7 +134,7 @@ public class WebServerComponent implements ExternalComponent, WebServerComponent
ActiveMQWebLogger.LOGGER.startingEmbeddedWebServer();
server = new Server(new QueuedThreadPool(webServerConfig.maxThreads, webServerConfig.minThreads, webServerConfig.idleThreadTimeout));
handlers = new HandlerList();
handlers = new Handler.Sequence();
HttpConfiguration httpConfiguration = new HttpConfiguration();
@ -179,7 +179,6 @@ public class WebServerComponent implements ExternalComponent, WebServerComponent
}
WebAppContext webContext = createWebAppContext(app.url, app.war, dirToUse, virtualHosts[i]);
handlers.addHandler(webContext);
webContext.setInitParameter(DIR_ALLOWED, "false");
webContext.getSessionHandler().getSessionCookieConfig().setComment("__SAME_SITE_STRICT__");
webContext.addEventListener(new ServletContextListener() {
@Override
@ -202,31 +201,29 @@ public class WebServerComponent implements ExternalComponent, WebServerComponent
server.setConnectors(connectors);
ResourceHandler homeResourceHandler = new ResourceHandler();
homeResourceHandler.setResourceBase(homeWarDir.toString());
homeResourceHandler.setDirectoriesListed(false);
homeResourceHandler.setWelcomeFiles(new String[]{"index.html"});
homeResourceHandler.setBaseResourceAsString(homeWarDir.toString());
homeResourceHandler.setDirAllowed(false);
homeResourceHandler.setWelcomeFiles("index.html");
ContextHandler homeContext = new ContextHandler();
homeContext.setContextPath("/");
homeContext.setResourceBase(homeWarDir.toString());
homeContext.setBaseResourceAsString(homeWarDir.toString());
homeContext.setHandler(homeResourceHandler);
homeContext.setVirtualHosts(virtualHosts);
homeContext.setInitParameter(DIR_ALLOWED, "false");
homeContext.setVirtualHosts(Arrays.asList(virtualHosts));
ResourceHandler instanceResourceHandler = new ResourceHandler();
instanceResourceHandler.setResourceBase(instanceWarDir.toString());
instanceResourceHandler.setDirectoriesListed(false);
instanceResourceHandler.setWelcomeFiles(new String[]{"index.html"});
instanceResourceHandler.setBaseResourceAsString(instanceWarDir.toString());
instanceResourceHandler.setDirAllowed(false);
instanceResourceHandler.setWelcomeFiles("index.html");
ContextHandler instanceContext = new ContextHandler();
instanceContext.setContextPath("/");
instanceContext.setResourceBase(instanceWarDir.toString());
instanceContext.setBaseResourceAsString(instanceWarDir.toString());
instanceContext.setHandler(instanceResourceHandler);
instanceContext.setVirtualHosts(virtualHosts);
homeContext.setInitParameter(DIR_ALLOWED, "false");
instanceContext.setVirtualHosts(Arrays.asList(virtualHosts));
DefaultHandler defaultHandler = new DefaultHandler();
defaultHandler.setServeIcon(false);
defaultHandler.setServeFavIcon(false);
defaultHandler.setRootRedirectLocation(this.webServerConfig.rootRedirectLocation);
if (this.webServerConfig.requestLog != null &&

View File

@ -18,7 +18,7 @@ package org.apache.activemq.artemis.component;
import java.nio.file.Path;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.ee8.webapp.WebAppContext;
public class WebServerComponentTestAccessor {

View File

@ -16,7 +16,7 @@
*/
package org.apache.activemq.cli.test;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Request;
@ -27,7 +27,8 @@ public class TestCustomizer implements HttpConfiguration.Customizer {
}
@Override
public void customize(Connector connector, HttpConfiguration httpConfiguration, Request request) {
public Request customize(Request request, HttpFields.Mutable responseHeaders) {
count++;
return request;
}
}

View File

@ -95,10 +95,10 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.DefaultRoutePlanner;
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContextBuilder;
import org.eclipse.jetty.ee8.webapp.WebAppContext;
import org.eclipse.jetty.ee8.webapp.WebInfConfiguration;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.ThreadPool;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebInfConfiguration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -164,7 +164,7 @@ public class WebServerComponentTest extends ArtemisTestCase {
}
WebServerComponent webServerComponent = new WebServerComponent();
assertFalse(webServerComponent.isStarted());
webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
webServerComponent.configure(webServerDTO, "src/test/resources/", "src/test/resources/");
testedComponents.add(webServerComponent);
webServerComponent.start();
final int port = webServerComponent.getPort();
@ -227,7 +227,7 @@ public class WebServerComponentTest extends ArtemisTestCase {
webServerDTO.webContentEnabled = true;
WebServerComponent webServerComponent = new WebServerComponent();
assertFalse(webServerComponent.isStarted());
webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
webServerComponent.configure(webServerDTO, "src/test/resources/", "src/test/resources/");
webServerComponent.start();
// Make the connection attempt.
verifyConnection(webServerComponent.getPort());
@ -251,7 +251,7 @@ public class WebServerComponentTest extends ArtemisTestCase {
webServerDTO.webContentEnabled = true;
WebServerComponent webServerComponent = new WebServerComponent();
assertFalse(webServerComponent.isStarted());
webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
webServerComponent.configure(webServerDTO, "src/test/resources/", "src/test/resources/");
webServerComponent.start();
// Make the connection attempt.
verifyConnection(webServerComponent.getPort());
@ -305,7 +305,7 @@ public class WebServerComponentTest extends ArtemisTestCase {
WebServerComponent webServerComponent = new WebServerComponent();
assertFalse(webServerComponent.isStarted());
webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
webServerComponent.configure(webServerDTO, "src/test/resources/", "src/test/resources/");
testedComponents.add(webServerComponent);
webServerComponent.start();
@ -660,7 +660,7 @@ public class WebServerComponentTest extends ArtemisTestCase {
WebServerComponent webServerComponent = new WebServerComponent();
assertFalse(webServerComponent.isStarted());
webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
webServerComponent.configure(webServerDTO, "src/test/resources/", "src/test/resources/");
testedComponents.add(webServerComponent);
webServerComponent.start();
final int port = webServerComponent.getPort();

View File

@ -107,7 +107,7 @@
<guava.version>33.3.1-jre</guava.version>
<hawtio.version>2.17.7</hawtio.version>
<jsr305.version>3.0.2</jsr305.version>
<jetty.version>10.0.24</jetty.version>
<jetty.version>12.0.15</jetty.version>
<jetty-servlet-api.version>4.0.6</jetty-servlet-api.version>
<jgroups.version>5.3.13.Final</jgroups.version>
<errorprone.version>2.31.0</errorprone.version>

View File

@ -102,7 +102,7 @@ public class WebServerComponentTest {
webServerDTO.setRequestLog(requestLogDTO);
WebServerComponent webServerComponent = new WebServerComponent();
assertFalse(webServerComponent.isStarted());
webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
webServerComponent.configure(webServerDTO, "src/test/resources/", "src/test/resources/");
testedComponents.add(webServerComponent);
webServerComponent.start();