Skip to content

Commit

Permalink
Upgrade to Spring Boot 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Bassi committed Dec 11, 2024
1 parent 6812d87 commit 53eb613
Show file tree
Hide file tree
Showing 114 changed files with 1,217 additions and 993 deletions.
9 changes: 5 additions & 4 deletions doc/external-sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ spring:
session:
store-type: redis

redis:
host: redis.host.example
port: 6379
data:
redis:
host: redis.host.example
port: 6379

management:
health:
Expand All @@ -30,4 +31,4 @@ management:
For other redis connection configuration options, see the [Spring boot reference guide][spring-boot-reference].
[redis]: https://redis.io/
[spring-boot-reference]: https://docs.spring.io/spring-boot/docs/2.2.9.RELEASE/reference/htmlsingle/#data-properties
[spring-boot-reference]: https://docs.spring.io/spring-boot/appendix/application-properties/index.html#appendix.application-properties.data
83 changes: 68 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- Keep this aligned with the spring.boot-version property below! -->
<version>2.7.18</version>
<version>3.4.0</version>
<relativePath />
</parent>

Expand All @@ -26,29 +26,34 @@
<plugin.assembly.version>2.4</plugin.assembly.version>
<plugin.shade.version>2.3</plugin.shade.version>
<plugin.license.version>1.9.0</plugin.license.version>
<plugin.git-commit-id.version>9.0.1</plugin.git-commit-id.version>
<plugin.jacoco.version>0.8.8</plugin.jacoco.version>

<java.version>17</java.version>

<!-- Keep this aligned with the parent project version! -->
<spring-boot.version>2.7.18</spring-boot.version>
<spring-security.version>5.8.15</spring-security.version>
<spring-boot.version>3.4.0</spring-boot.version>

<!-- Sonarcloud.io properties -->
<sonar.projectKey>italiangrid_storm-webdav</sonar.projectKey>
<sonar.organization>italiangrid</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.exclusions>src/main/java/org/italiangrid/storm/webdav/spring/RedirectExec.java</sonar.exclusions>

<voms-api-java.version>3.3.3</voms-api-java.version>
<milton.version>2.7.1.7</milton.version>
<milton.version>4.0.4.2305</milton.version>

<commons-lang.version>2.3</commons-lang.version>
<commons-cli.version>1.2</commons-cli.version>
<commons-csv.version>1.0</commons-csv.version>
<jimfs.version>1.1</jimfs.version>

<http-core.version>4.2.2</http-core.version>
<http-client.version>4.2.1</http-client.version>
<metrics.version>4.2.28</metrics.version>
<http-server.version>11.0.24</http-server.version>
<httpclient5.version>5.4.1</httpclient5.version>

<logback-access.version>2.0.3</logback-access.version>
<logback-access-jetty12.version>2.0.4</logback-access-jetty12.version>

<guava.version>32.0.0-jre</guava.version>

Expand Down Expand Up @@ -77,8 +82,20 @@
</plugin>

<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>${plugin.git-commit-id.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<parameters>true</parameters>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>

<plugin>
Expand Down Expand Up @@ -123,11 +140,12 @@
<exclude>docker/**</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>Jenkinsfile</exclude>
<exlude>src/main/resources/static/**</exlude>
<exclude>src/main/resources/static/**</exclude>
<exclude>src/main/resources/META-INF/spring.factories</exclude>
<exclude>maven/**</exclude>
<exclude>cnaf-mirror-settings.xml</exclude>
<exclude>sonar-project.properties</exclude>
<exclude>src/main/java/org/italiangrid/storm/webdav/spring/RedirectExec.java</exclude>
</excludes>
<useDefaultExcludes>true</useDefaultExcludes>
<strictCheck>true</strictCheck>
Expand Down Expand Up @@ -171,6 +189,23 @@
</build>

<dependencies>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
Expand Down Expand Up @@ -314,11 +349,13 @@
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${metrics.version}</version>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jetty9</artifactId>
<artifactId>metrics-jetty12</artifactId>
<version>${metrics.version}</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
Expand All @@ -329,12 +366,20 @@

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlets</artifactId>
<artifactId>metrics-jetty12-ee10</artifactId>
<version>${metrics.version}</version>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jakarta-servlets</artifactId>
<version>${metrics.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<version>${http-server.version}</version>
</dependency>

<dependency>
Expand All @@ -359,8 +404,9 @@
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<groupId>ch.qos.logback.access</groupId>
<artifactId>common</artifactId>
<version>${logback-access.version}</version>
</dependency>

<dependency>
Expand All @@ -374,8 +420,15 @@
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<groupId>ch.qos.logback.access</groupId>
<artifactId>logback-access-jetty12</artifactId>
<version>${logback-access-jetty12.version}</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${httpclient5.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
Expand Down
16 changes: 8 additions & 8 deletions robot/test/partial_transfer.robot
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ Partial Get works
[Tags] voms get
[Setup] Setup file partial_works test123456789
${url} DAVS URL partial_works
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: 0-3"
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: bytes=0-3"
Should Contain ${out} test
Should Not Contain ${out} 123456789
Should Contain ${out} Content-Length: 4
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: 4-7"
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: bytes=4-7"
Should Contain ${out} 1234
Should Contain ${out} Content-Length: 4
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: 9-12"
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: bytes=9-12"
Should Contain ${out} 6789
Should Contain ${out} Content-Length: 4
[Teardown] Teardown file partial_works
Expand All @@ -46,7 +46,7 @@ Partial Get with multiple range
[Tags] voms get
[Setup] Setup file partial_works test123456789
${url} DAVS URL partial_works
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: 1-3,5-7,10-11"
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: bytes=1-3,5-7,10-11"
Should Contain ${out} Content-Range: bytes 1-3/13
Should Contain ${out} est
Should Contain ${out} Content-Range: bytes 5-7/13
Expand All @@ -59,7 +59,7 @@ Partial Get not entirely on range
[Tags] voms get
[Setup] Setup file partial_works test123456789
${url} DAVS URL partial_works
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: 11-13"
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: bytes=11-13"
Should Contain ${out} Content-Range: bytes 11-12/13
Should Contain ${out} 89
Should Contain ${out} Content-Length: 2
Expand All @@ -69,15 +69,15 @@ Partial Get out of range
[Tags] voms get
[Setup] Setup file partial_works test123456789
${url} DAVS URL partial_works
${rc} ${out} Curl Voms Get Failure ${url} ${curl.opts.default} -H "Range: 20-24"
${rc} ${out} Curl Voms Get Failure ${url} ${curl.opts.default} -H "Range: bytes=20-24"
Should Match Regexp ${out} 416 Requested Range Not Satisfiable|416 Range Not Satisfiable
[Teardown] Teardown file partial_works

Partial Get out in one of multiple range
[Tags] voms get
[Setup] Setup file partial_works test123456789
${url} DAVS URL partial_works
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: 1-3,20-24"
${rc} ${out} Curl Voms Get Success ${url} ${curl.opts.default} -H "Range: bytes=1-3,20-24"
Should Contain ${out} Content-Range: bytes 1-3/13
Should Contain ${out} est
Should Contain ${out} Content-Length: 3
Expand All @@ -90,4 +90,4 @@ Partial Put works
${dest} DAVS Url pput_test
${rc} ${out} Curl Voms Put Success ${TEMPDIR}/pput0_test ${dest}
${rc} ${out} Curl Voms Put Success ${TEMPDIR}/pput1_test ${dest} ${opts}
[Teardown] Partial Put Teardown
[Teardown] Partial Put Teardown
4 changes: 2 additions & 2 deletions robot/test/propfind.robot
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Get PROPFIND PROPNAME body
[Return] ${output}

Get PROPFIND PROP body [Arguments] ${propname}
${output} Set variable "<?xml version='1.0' encoding='utf-8' ?><D:propfind xmlns:D='DAV:'><D:prop><D:${propname}/><prop/></D:propfind>"
${output} Set variable "<?xml version='1.0' encoding='utf-8' ?><D:propfind xmlns:D='DAV:'><D:prop/><D:${propname}/></D:propfind>"
[Return] ${output}


Expand Down Expand Up @@ -71,4 +71,4 @@ Propfind status property works
${body} Get PROPFIND PROP body status
${rc} ${out} Curl Voms PROPFIND ${url} ${body}
Should Contain ${out} <d:status>HTTP/1.1 200 OK</d:status>
[Teardown] Teardown file propfind_works
[Teardown] Teardown file propfind_works
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import java.util.LinkedHashMap;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.springframework.http.HttpStatus;
import org.springframework.security.core.AuthenticationException;
Expand All @@ -46,8 +46,8 @@ public void commence(HttpServletRequest request, HttpServletResponse response,

response.setStatus(status.value());

if (authException instanceof OAuth2AuthenticationException) {
OAuth2Error error = ((OAuth2AuthenticationException) authException).getError();
if (authException instanceof OAuth2AuthenticationException oAuth2AuthenticationException) {
OAuth2Error error = oAuth2AuthenticationException.getError();

parameters.put("error", error.getErrorCode());

Expand All @@ -59,14 +59,12 @@ public void commence(HttpServletRequest request, HttpServletResponse response,
parameters.put("error_uri", error.getUri());
}

if (error instanceof BearerTokenError) {
BearerTokenError bearerTokenError = (BearerTokenError) error;

if (error instanceof BearerTokenError bearerTokenError) {
if (StringUtils.hasText(bearerTokenError.getScope())) {
parameters.put("scope", bearerTokenError.getScope());
}

status = ((BearerTokenError) error).getHttpStatus();
status = bearerTokenError.getHttpStatus();
response.setStatus(status.value());
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/italiangrid/storm/webdav/authz/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import java.util.Optional;

import javax.security.auth.x500.X500Principal;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import eu.emi.security.authn.x509.proxy.ProxyUtils;

public class Utils {

public static final String X509_CERT_REQ_ATTR = "javax.servlet.request.X509Certificate";
public static final String X509_CERT_REQ_ATTR = "jakarta.servlet.request.X509Certificate";

private Utils() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import java.util.Collection;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import org.italiangrid.voms.VOMSAttribute;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails;

public class VOMSAuthenticationDetails
extends PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails {

private static final long serialVersionUID = 1L;

// Transient here is due to the fact that VOMSAttributesImpl is not serializable!
final transient List<VOMSAttribute> vomsAttributes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.security.cert.X509Certificate;
import java.util.Optional;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Set;

import javax.security.auth.x500.X500Principal;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import org.italiangrid.storm.webdav.authz.vomap.VOMapDetailsService;
import org.italiangrid.voms.VOMSAttribute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@
import org.italiangrid.storm.webdav.authz.VOMSVOAuthority;
import org.italiangrid.storm.webdav.authz.VOMSVOMapAuthority;
import org.springframework.security.core.Authentication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StormSecurityExpressionMethods {

private static final Logger LOG = LoggerFactory.getLogger(StormSecurityExpressionMethods.class);

final Authentication authentication;

public StormSecurityExpressionMethods(Authentication authn) {
this.authentication = authn;
}

public boolean isVOMSAuthenticated() {
LOG.warn("isVOMSAuthenticated: {}", authentication.getAuthorities().stream().anyMatch(VOMSVOAuthority.class::isInstance));
return authentication.getAuthorities().stream().anyMatch(VOMSVOAuthority.class::isInstance);
}

Expand Down
Loading

0 comments on commit 53eb613

Please sign in to comment.