You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/08/08 08:43:44 UTC
(maven) 03/03: Address review feedback on the Jetty 12 port
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
commit bb101aa852c3ddc19fa53af2a2a307761533d77b
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Fri Aug 7 16:39:11 2026 +0200
Address review feedback on the Jetty 12 port
- Restore the role-based BASIC auth constraints. The port flattened every
Jetty 9 constraint to Authorization.ANY_USER, which authorises any
authenticated principal; map each of the 11 sites back to SPECIFIC_ROLE
with the roles it declared before (MNG-553 used the two-arg Constraint
constructor rather than setRoles, so it is easy to miss).
- Hoist the repeated Request.getPathInContext(request) calls into a local,
matching the pattern the other handlers already use.
- Restore the dropped "import static java.nio.file.StandardCopyOption.REPLACE_EXISTING"
instead of fully qualifying it inline.
---
.../src/test/java/org/apache/maven/it/HttpServer.java | 2 +-
.../maven/it/MavenITmng0553SettingsAuthzEncryptionTest.java | 2 +-
.../maven/it/MavenITmng3599useHttpProxyForWebDAVMk2Test.java | 7 ++++---
.../maven/it/MavenITmng3953AuthenticatedDeploymentTest.java | 2 +-
.../apache/maven/it/MavenITmng4068AuthenticatedMirrorTest.java | 2 +-
.../maven/it/MavenITmng4235HttpAuthDeploymentChecksumsTest.java | 5 +++--
.../maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java | 5 +++--
.../java/org/apache/maven/it/MavenITmng4360WebDavSupportTest.java | 8 ++++----
.../maven/it/MavenITmng4413MirroringOfDependencyRepoTest.java | 2 +-
.../it/MavenITmng4469AuthenticatedDeploymentToCustomRepoTest.java | 2 +-
.../it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java | 2 +-
.../maven/it/MavenITmng4489MirroringOfExtensionRepoTest.java | 2 +-
.../apache/maven/it/MavenITmng4561MirroringOfPluginRepoTest.java | 2 +-
.../it/MavenITmng4729MirrorProxyAuthUsedByProjectBuilderTest.java | 2 +-
14 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/HttpServer.java b/its/core-it-suite/src/test/java/org/apache/maven/it/HttpServer.java
index 7f431ff67d..dc25edd06e 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/HttpServer.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/HttpServer.java
@@ -110,7 +110,7 @@ private Server server(int port) {
SecurityHandler.PathMapped security = new SecurityHandler.PathMapped();
security.setAuthenticator(new BasicAuthenticator());
security.setLoginService(loginService);
- security.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ security.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "user", "admin"));
security.setHandler(handler);
server.setHandler(security);
} else {
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0553SettingsAuthzEncryptionTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0553SettingsAuthzEncryptionTest.java
index 95e63e4025..8069e9df59 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0553SettingsAuthzEncryptionTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0553SettingsAuthzEncryptionTest.java
@@ -69,7 +69,7 @@ protected void setUp() throws Exception {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "user"));
ResourceHandler repoHandler = new ResourceHandler();
repoHandler.setBaseResource(ResourceFactory.of(server).newResource(testDir.resolve("repo")));
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3599useHttpProxyForWebDAVMk2Test.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3599useHttpProxyForWebDAVMk2Test.java
index 8410d052e6..0d5e69b20c 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3599useHttpProxyForWebDAVMk2Test.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3599useHttpProxyForWebDAVMk2Test.java
@@ -70,10 +70,11 @@ public boolean handle(Request request, Response response, Callback callback) thr
response.getHeaders().put(HttpHeader.CONTENT_TYPE, "text/plain");
System.out.println("Checking for 'Proxy-Connection' header...");
+ String uri = Request.getPathInContext(request);
PrintWriter writer = new PrintWriter(Content.Sink.asOutputStream(response));
if (request.getHeaders().get("Proxy-Connection") != null) {
response.setStatus(200);
- if (Request.getPathInContext(request).endsWith(".sha1")) {
+ if (uri.endsWith(".sha1")) {
writer.print(CONTENT_CHECKSUM_SHA1);
} else {
writer.print(CONTENT);
@@ -87,10 +88,10 @@ public boolean handle(Request request, Response response, Callback callback) thr
* Changing the code to test for more generalized case: local proxy receives a request with
* correct server url and resource uri
*/
- else if (Request.getPathInContext(request).startsWith("/org/apache/maven/its/mng3599/test-dependency")
+ else if (uri.startsWith("/org/apache/maven/its/mng3599/test-dependency")
&& request.getHttpURI().toString().startsWith("http://www.example.com")) {
response.setStatus(200);
- if (Request.getPathInContext(request).endsWith(".sha1")) {
+ if (uri.endsWith(".sha1")) {
writer.print(CONTENT_CHECKSUM_SHA1);
} else {
writer.print(CONTENT);
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3953AuthenticatedDeploymentTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3953AuthenticatedDeploymentTest.java
index 7d9a8c1781..a3b1835cbf 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3953AuthenticatedDeploymentTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3953AuthenticatedDeploymentTest.java
@@ -79,7 +79,7 @@ public boolean handle(Request request, Response response, Callback callback) {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "deployer"));
securityHandler.setHandler(repoHandler);
server.setHandler(securityHandler);
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4068AuthenticatedMirrorTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4068AuthenticatedMirrorTest.java
index 47f4cd688f..fc86687919 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4068AuthenticatedMirrorTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4068AuthenticatedMirrorTest.java
@@ -65,7 +65,7 @@ protected void setUp() throws Exception {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "user"));
ResourceHandler repoHandler = new ResourceHandler();
repoHandler.setBaseResource(ResourceFactory.of(server).newResource(testDir.resolve("repo")));
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4235HttpAuthDeploymentChecksumsTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4235HttpAuthDeploymentChecksumsTest.java
index fed7b31e8a..d492386f7c 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4235HttpAuthDeploymentChecksumsTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4235HttpAuthDeploymentChecksumsTest.java
@@ -46,6 +46,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -77,7 +78,7 @@ protected void setUp() throws Exception {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "deployer"));
server = new Server(0);
@@ -178,7 +179,7 @@ public boolean handle(Request request, Response response, Callback callback) thr
Files.createDirectories(dir);
}
- Files.copy(Request.asInputStream(request), resource, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(Request.asInputStream(request), resource, REPLACE_EXISTING);
DeployedResource deployedResource = new DeployedResource();
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
index d7a750b2f1..7ecd57ab3d 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
@@ -62,9 +62,10 @@ public boolean handle(Request request, Response response, Callback callback) thr
System.out.println("Handling " + request.getMethod() + " "
+ request.getHttpURI().toString());
+ String uri = Request.getPathInContext(request);
// NOTE: Old Maven versions use the test repo also to check for plugin updates so we need to filter
- if (Request.getPathInContext(request).startsWith("/org/apache/maven/its/mng4348")) {
- requestedUris.add(Request.getPathInContext(request));
+ if (uri.startsWith("/org/apache/maven/its/mng4348")) {
+ requestedUris.add(uri);
}
response.setStatus(404);
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4360WebDavSupportTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4360WebDavSupportTest.java
index 223f87dffb..540f59239e 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4360WebDavSupportTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4360WebDavSupportTest.java
@@ -83,19 +83,19 @@ public boolean handle(Request request, Response response, Callback callback) thr
PrintWriter writer = new PrintWriter(Content.Sink.asOutputStream(response));
+ String uri = Request.getPathInContext(request);
response.setStatus(200);
- if (Request.getPathInContext(request).endsWith(".pom")) {
+ if (uri.endsWith(".pom")) {
writer.println("<project xmlns=\"http://maven.apache.org/POM/4.0.0\">");
writer.println(" <modelVersion>4.0.0</modelVersion>");
writer.println(" <groupId>org.apache.maven.its.mng4360</groupId>");
writer.println(" <artifactId>dep</artifactId>");
writer.println(" <version>0.1</version>");
writer.println("</project>");
- } else if (Request.getPathInContext(request).endsWith(".jar")) {
+ } else if (uri.endsWith(".jar")) {
writer.println("empty");
- } else if (Request.getPathInContext(request).endsWith(".md5")
- || Request.getPathInContext(request).endsWith(".sha1")) {
+ } else if (uri.endsWith(".md5") || uri.endsWith(".sha1")) {
response.setStatus(404);
}
writer.flush();
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4413MirroringOfDependencyRepoTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4413MirroringOfDependencyRepoTest.java
index 0c94b0f992..8a0ec95e93 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4413MirroringOfDependencyRepoTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4413MirroringOfDependencyRepoTest.java
@@ -61,7 +61,7 @@ public void testit() throws Exception {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "user"));
ResourceHandler repoHandler = new ResourceHandler();
repoHandler.setBaseResource(ResourceFactory.of(server).newResource(testDir.resolve("repo-a")));
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4469AuthenticatedDeploymentToCustomRepoTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4469AuthenticatedDeploymentToCustomRepoTest.java
index 2fa3ea1e88..de382a0edf 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4469AuthenticatedDeploymentToCustomRepoTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4469AuthenticatedDeploymentToCustomRepoTest.java
@@ -79,7 +79,7 @@ public boolean handle(Request request, Response response, Callback callback) {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "deployer"));
securityHandler.setHandler(repoHandler);
server.setHandler(securityHandler);
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java
index a48fbb4703..f7a5690004 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java
@@ -132,7 +132,7 @@ public boolean handle(Request request, Response response, Callback callback) {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "deployer"));
securityHandler.setHandler(repoHandler);
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4489MirroringOfExtensionRepoTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4489MirroringOfExtensionRepoTest.java
index 30a427a37d..cb40b3a29e 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4489MirroringOfExtensionRepoTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4489MirroringOfExtensionRepoTest.java
@@ -61,7 +61,7 @@ public void testit() throws Exception {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "user"));
ResourceHandler repoHandler = new ResourceHandler();
repoHandler.setBaseResource(ResourceFactory.of(server).newResource(testDir));
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4561MirroringOfPluginRepoTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4561MirroringOfPluginRepoTest.java
index 244b6a3007..e170ea2dcd 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4561MirroringOfPluginRepoTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4561MirroringOfPluginRepoTest.java
@@ -61,7 +61,7 @@ public void testit() throws Exception {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "user"));
ResourceHandler repoHandler = new ResourceHandler();
repoHandler.setBaseResource(ResourceFactory.of(server).newResource(testDir));
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4729MirrorProxyAuthUsedByProjectBuilderTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4729MirrorProxyAuthUsedByProjectBuilderTest.java
index ff954060ba..0d0ae1f9fe 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4729MirrorProxyAuthUsedByProjectBuilderTest.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4729MirrorProxyAuthUsedByProjectBuilderTest.java
@@ -64,7 +64,7 @@ public void testit() throws Exception {
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthenticator(new BasicAuthenticator());
- securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.ANY_USER));
+ securityHandler.put("/*", Constraint.from("auth", Constraint.Authorization.SPECIFIC_ROLE, "user"));
ResourceHandler repoHandler = new ResourceHandler();
repoHandler.setBaseResource(ResourceFactory.of(server).newResource(testDir));