Skip to content

Commit

Permalink
Adopt Spring Boot 3.2 and Jetty 12
Browse files Browse the repository at this point in the history
Resolves #72.
  • Loading branch information
iay committed Jun 21, 2024
1 parent a8049d4 commit 631d8fc
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 88 deletions.
103 changes: 15 additions & 88 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
<shib-shared.groupId>net.shibboleth</shib-shared.groupId>
<shib-shared.version>9.1.2</shib-shared.version>

<spring.boot.version>3.1.12</spring.boot.version>
<spring.boot.version>3.2.7</spring.boot.version>

<ukf-mda.version>0.10.0</ukf-mda.version>
<jetty.version>11.0.21</jetty.version>

<image.library>ianayoung</image.library>
<image.name>${project.artifactId}</image.name>
Expand Down Expand Up @@ -119,6 +118,20 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

<!-- Provided Dependencies -->

Expand Down Expand Up @@ -173,36 +186,6 @@
<artifactId>spring-boot-starter</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>jakarta.servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand All @@ -218,18 +201,6 @@
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>

<!-- Test dependencies -->

Expand Down Expand Up @@ -277,50 +248,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-xml</artifactId>
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down
49 changes: 49 additions & 0 deletions src/main/java/uk/org/iay/mdq/server/JettyCustomizer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2024 Ian A. Young.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.org.iay.mdq.server;

import java.util.Set;

import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;

@Component
public class JettyCustomizer implements WebServerFactoryCustomizer<JettyServletWebServerFactory> {

@Override
public void customize(JettyServletWebServerFactory factory) {
factory.addServerCustomizers(this::customizeUriCompliance);
}

private void customizeUriCompliance(Server server) {
for (Connector connector : server.getConnectors()) {
connector.getConnectionFactories().stream()
.filter(factory -> factory instanceof HttpConnectionFactory)
.forEach(factory -> {
HttpConfiguration httpConfig = ((HttpConnectionFactory) factory).getHttpConfiguration();
httpConfig.setUriCompliance(UriCompliance.from(Set.of(
UriCompliance.Violation.AMBIGUOUS_PATH_SEPARATOR,
UriCompliance.Violation.AMBIGUOUS_PATH_ENCODING)));
});
}
}
}

0 comments on commit 631d8fc

Please sign in to comment.