sessionRepository() {
+ return new MapSessionRepository(new HashMap<>());
+ }
+
}
diff --git a/src/main/java/org/italiangrid/storm/webdav/spring/RedirectExec.java b/src/main/java/org/italiangrid/storm/webdav/spring/RedirectExec.java
new file mode 100644
index 00000000..12b4306e
--- /dev/null
+++ b/src/main/java/org/italiangrid/storm/webdav/spring/RedirectExec.java
@@ -0,0 +1,230 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+
+package org.italiangrid.storm.webdav.spring;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Objects;
+
+import org.apache.hc.client5.http.CircularRedirectException;
+import org.apache.hc.client5.http.HttpRoute;
+import org.apache.hc.client5.http.RedirectException;
+import org.apache.hc.client5.http.auth.AuthExchange;
+import org.apache.hc.client5.http.classic.ExecChain;
+import org.apache.hc.client5.http.classic.ExecChainHandler;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.client5.http.protocol.RedirectLocations;
+import org.apache.hc.client5.http.protocol.RedirectStrategy;
+import org.apache.hc.client5.http.routing.HttpRoutePlanner;
+import org.apache.hc.client5.http.utils.URIUtils;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.Method;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
+import org.apache.hc.core5.util.Args;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Request execution handler in the classic request execution chain
+ * responsible for handling of request redirects.
+ *
+ * Further responsibilities such as communication with the opposite
+ * endpoint is delegated to the next executor in the request execution
+ * chain.
+ *
+ *
+ * @since 4.3
+ */
+// Copied from https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
+// Added the drop of Authorization header
+@Contract(threading = ThreadingBehavior.STATELESS)
+public final class RedirectExec implements ExecChainHandler {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RedirectExec.class);
+
+ private final RedirectStrategy redirectStrategy;
+ private final HttpRoutePlanner routePlanner;
+
+ public RedirectExec(
+ final HttpRoutePlanner routePlanner,
+ final RedirectStrategy redirectStrategy) {
+ super();
+ Args.notNull(routePlanner, "HTTP route planner");
+ Args.notNull(redirectStrategy, "HTTP redirect strategy");
+ this.routePlanner = routePlanner;
+ this.redirectStrategy = redirectStrategy;
+ }
+
+ @Override
+ public ClassicHttpResponse execute(
+ final ClassicHttpRequest request,
+ final ExecChain.Scope scope,
+ final ExecChain chain) throws IOException, HttpException {
+ Args.notNull(request, "HTTP request");
+ Args.notNull(scope, "Scope");
+
+ final HttpClientContext context = scope.clientContext;
+ context.setRedirectLocations(null);
+
+ final RequestConfig config = context.getRequestConfigOrDefault();
+ final int maxRedirects = config.getMaxRedirects() > 0 ? config.getMaxRedirects() : 50;
+ ClassicHttpRequest currentRequest = request;
+ ExecChain.Scope currentScope = scope;
+ for (int redirectCount = 0;;) {
+ final String exchangeId = currentScope.exchangeId;
+ final ClassicHttpResponse response = chain.proceed(currentRequest, currentScope);
+ try {
+ if (config.isRedirectsEnabled() && this.redirectStrategy.isRedirected(request, response, context)) {
+ final HttpEntity requestEntity = request.getEntity();
+ // This is the only modification
+ scope.originalRequest.removeHeaders("Authorization");
+ if (requestEntity != null && !requestEntity.isRepeatable()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} cannot redirect non-repeatable request", exchangeId);
+ }
+ return response;
+ }
+ if (redirectCount >= maxRedirects) {
+ throw new RedirectException("Maximum redirects (" + maxRedirects + ") exceeded");
+ }
+ redirectCount++;
+
+ final URI redirectUri = this.redirectStrategy.getLocationURI(currentRequest, response, context);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} redirect requested to location '{}'", exchangeId, redirectUri);
+ }
+
+ final HttpHost newTarget = URIUtils.extractHost(redirectUri);
+ if (newTarget == null) {
+ throw new ProtocolException("Redirect URI does not specify a valid host name: " +
+ redirectUri);
+ }
+
+ final RedirectLocations redirectLocations = context.getRedirectLocations();
+ if (!config.isCircularRedirectsAllowed()) {
+ if (redirectLocations.contains(redirectUri)) {
+ throw new CircularRedirectException("Circular redirect to '" + redirectUri + "'");
+ }
+ }
+ redirectLocations.add(redirectUri);
+
+ final int statusCode = response.getCode();
+ final ClassicRequestBuilder redirectBuilder;
+ switch (statusCode) {
+ case HttpStatus.SC_MOVED_PERMANENTLY:
+ case HttpStatus.SC_MOVED_TEMPORARILY:
+ if (Method.POST.isSame(request.getMethod())) {
+ redirectBuilder = ClassicRequestBuilder.get();
+ } else {
+ redirectBuilder = ClassicRequestBuilder.copy(currentScope.originalRequest);
+ }
+ break;
+ case HttpStatus.SC_SEE_OTHER:
+ if (!Method.GET.isSame(request.getMethod()) && !Method.HEAD.isSame(request.getMethod())) {
+ redirectBuilder = ClassicRequestBuilder.get();
+ } else {
+ redirectBuilder = ClassicRequestBuilder.copy(currentScope.originalRequest);
+ }
+ break;
+ default:
+ redirectBuilder = ClassicRequestBuilder.copy(currentScope.originalRequest);
+ }
+ redirectBuilder.setUri(redirectUri);
+
+ HttpRoute currentRoute = currentScope.route;
+ if (!Objects.equals(currentRoute.getTargetHost(), newTarget)) {
+ final HttpRoute newRoute = this.routePlanner.determineRoute(newTarget, context);
+ if (!Objects.equals(currentRoute, newRoute)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} new route required", exchangeId);
+ }
+ final AuthExchange targetAuthExchange = context.getAuthExchange(currentRoute.getTargetHost());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} resetting target auth state", exchangeId);
+ }
+ targetAuthExchange.reset();
+ if (currentRoute.getProxyHost() != null) {
+ final AuthExchange proxyAuthExchange = context.getAuthExchange(currentRoute.getProxyHost());
+ if (proxyAuthExchange.isConnectionBased()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} resetting proxy auth state", exchangeId);
+ }
+ proxyAuthExchange.reset();
+ }
+ }
+ currentRoute = newRoute;
+ }
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} redirecting to '{}' via {}", exchangeId, redirectUri, currentRoute);
+ }
+ currentScope = new ExecChain.Scope(
+ scope.exchangeId,
+ currentRoute,
+ redirectBuilder.build(),
+ scope.execRuntime,
+ scope.clientContext);
+ currentRequest = redirectBuilder.build();
+
+ EntityUtils.consume(response.getEntity());
+ response.close();
+ } else {
+ return response;
+ }
+ } catch (final RuntimeException | IOException ex) {
+ response.close();
+ throw ex;
+ } catch (final HttpException ex) {
+ // Protocol exception related to a direct.
+ // The underlying connection may still be salvaged.
+ try {
+ EntityUtils.consume(response.getEntity());
+ } catch (final IOException ioex) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} I/O error while releasing connection", exchangeId, ioex);
+ }
+ } finally {
+ response.close();
+ }
+ throw ex;
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/org/italiangrid/storm/webdav/spring/web/AppContextLoaderListener.java b/src/main/java/org/italiangrid/storm/webdav/spring/web/AppContextLoaderListener.java
index 1f39b68b..bcc4d36f 100644
--- a/src/main/java/org/italiangrid/storm/webdav/spring/web/AppContextLoaderListener.java
+++ b/src/main/java/org/italiangrid/storm/webdav/spring/web/AppContextLoaderListener.java
@@ -15,7 +15,7 @@
*/
package org.italiangrid.storm.webdav.spring.web;
-import javax.servlet.ServletContext;
+import jakarta.servlet.ServletContext;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
diff --git a/src/main/java/org/italiangrid/storm/webdav/spring/web/HttpMethodRequestRejectedHandler.java b/src/main/java/org/italiangrid/storm/webdav/spring/web/HttpMethodRequestRejectedHandler.java
index 76f65842..62098bd2 100644
--- a/src/main/java/org/italiangrid/storm/webdav/spring/web/HttpMethodRequestRejectedHandler.java
+++ b/src/main/java/org/italiangrid/storm/webdav/spring/web/HttpMethodRequestRejectedHandler.java
@@ -18,9 +18,9 @@
import java.io.IOException;
import java.util.List;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/src/main/java/org/italiangrid/storm/webdav/spring/web/MvcConfig.java b/src/main/java/org/italiangrid/storm/webdav/spring/web/MvcConfig.java
index 57288094..e79fbd43 100644
--- a/src/main/java/org/italiangrid/storm/webdav/spring/web/MvcConfig.java
+++ b/src/main/java/org/italiangrid/storm/webdav/spring/web/MvcConfig.java
@@ -24,6 +24,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -31,16 +32,21 @@
@Configuration
public class MvcConfig implements WebMvcConfigurer {
-
+
@Autowired
ServiceConfigurationProperties properties;
-
+
@Autowired
OAuthProperties oauthProperties;
@Autowired
StorageAreaConfiguration saConfig;
-
+
+ @Override
+ public void configurePathMatch(PathMatchConfigurer configurer) {
+ configurer.setUseTrailingSlashMatch(true);
+ }
+
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new ViewUtilsInterceptor(properties, saConfig, oauthProperties));
diff --git a/src/main/java/org/italiangrid/storm/webdav/spring/web/ServletConfiguration.java b/src/main/java/org/italiangrid/storm/webdav/spring/web/ServletConfiguration.java
index 23ce8b49..fb01e534 100644
--- a/src/main/java/org/italiangrid/storm/webdav/spring/web/ServletConfiguration.java
+++ b/src/main/java/org/italiangrid/storm/webdav/spring/web/ServletConfiguration.java
@@ -41,7 +41,6 @@
import org.italiangrid.storm.webdav.server.servlet.SAIndexServlet;
import org.italiangrid.storm.webdav.server.servlet.SciTagFilter;
import org.italiangrid.storm.webdav.server.servlet.StoRMServlet;
-import org.italiangrid.storm.webdav.server.servlet.resource.StormResourceService;
import org.italiangrid.storm.webdav.server.tracing.LogbackAccessAuthnInfoFilter;
import org.italiangrid.storm.webdav.server.tracing.RequestIdFilter;
import org.italiangrid.storm.webdav.tpc.LocalURLService;
@@ -59,7 +58,7 @@
import org.thymeleaf.TemplateEngine;
import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.servlets.MetricsServlet;
+import io.dropwizard.metrics.servlets.MetricsServlet;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -233,14 +232,12 @@ ServletRegistrationBean stormServlet(OAuthProperties oauthProperti
ServiceConfigurationProperties serviceConfig, StorageAreaConfiguration saConfig,
PathResolver pathResolver, TemplateEngine templateEngine) {
- ServletRegistrationBean stormServlet =
- new ServletRegistrationBean<>(new StoRMServlet(oauthProperties, serviceConfig, pathResolver,
- templateEngine, new StormResourceService()));
+ ServletRegistrationBean stormServlet = new ServletRegistrationBean<>(
+ new StoRMServlet(oauthProperties, serviceConfig, pathResolver, templateEngine));
stormServlet.addInitParameter("acceptRanges", "true");
stormServlet.addInitParameter("dirAllowed", "true");
- stormServlet.addInitParameter("aliases", "false");
- stormServlet.addInitParameter("gzip", "false");
+ stormServlet.addInitParameter("precompressed", "false");
saConfig.getStorageAreaInfo()
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/TpcPlainConnectionSocketFactory.java b/src/main/java/org/italiangrid/storm/webdav/tpc/TpcPlainConnectionSocketFactory.java
index 04289a9d..2ba595b5 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/TpcPlainConnectionSocketFactory.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/TpcPlainConnectionSocketFactory.java
@@ -18,9 +18,10 @@
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
-import org.apache.http.HttpHost;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.TimeValue;
import org.italiangrid.storm.webdav.scitag.SciTag;
import org.italiangrid.storm.webdav.scitag.SciTagTransfer;
@@ -38,7 +39,7 @@ public TpcPlainConnectionSocketFactory() {
}
@Override
- public Socket connectSocket(int connectTimeout, Socket socket, HttpHost host,
+ public Socket connectSocket(TimeValue connectTimeout, Socket socket, HttpHost host,
InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context)
throws IOException {
Socket s =
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/TpcSSLConnectionSocketFactory.java b/src/main/java/org/italiangrid/storm/webdav/tpc/TpcSSLConnectionSocketFactory.java
index d7660cb6..d062fc51 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/TpcSSLConnectionSocketFactory.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/TpcSSLConnectionSocketFactory.java
@@ -18,8 +18,8 @@
import java.io.IOException;
import java.net.Socket;
import javax.net.ssl.SSLContext;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.italiangrid.storm.webdav.scitag.SciTag;
import org.italiangrid.storm.webdav.scitag.SciTagTransfer;
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/TpcUtils.java b/src/main/java/org/italiangrid/storm/webdav/tpc/TpcUtils.java
index 5e7a1ec0..ff5445dd 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/TpcUtils.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/TpcUtils.java
@@ -24,7 +24,7 @@
import java.util.function.Supplier;
import java.util.regex.Matcher;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.italiangrid.storm.webdav.config.StorageAreaInfo;
import org.italiangrid.storm.webdav.error.ResourceNotFound;
@@ -106,8 +106,9 @@ default boolean isCopy(HttpServletRequest request) {
}
default boolean isPushTpc(HttpServletRequest request, LocalURLService localUrlService) {
- return "COPY".equals(request.getMethod()) && (requestHasRemoteDestinationHeader(request, localUrlService)
- || requestHasTranferHeader(request));
+ return "COPY".equals(request.getMethod())
+ && (requestHasRemoteDestinationHeader(request, localUrlService)
+ || requestHasTranferHeader(request));
}
default boolean requestHasTranferHeader(HttpServletRequest request) {
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/TransferFilter.java b/src/main/java/org/italiangrid/storm/webdav/tpc/TransferFilter.java
index c40d2a56..47d351ad 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/TransferFilter.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/TransferFilter.java
@@ -15,7 +15,7 @@
*/
package org.italiangrid.storm.webdav.tpc;
-import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
+import static jakarta.servlet.http.HttpServletResponse.SC_ACCEPTED;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -23,17 +23,17 @@
import java.time.Clock;
import java.util.Optional;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpResponseException;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.HttpResponseException;
import org.italiangrid.storm.webdav.error.BadRequest;
import org.italiangrid.storm.webdav.error.ResourceNotFound;
import org.italiangrid.storm.webdav.scitag.SciTag;
@@ -183,11 +183,8 @@ protected void logTransferDone(GetTransferRequest req) {
if (TransferStatus.Status.DONE.equals(lastStatus.getStatus())) {
LOG.info(
"Pull third-party transfer completed: {}. Source: {}, Destination: {}, Bytes transferred: {}, Duration (msec): {}, Throughput: {}/sec, id: {}",
- lastStatus, req.remoteURI(), req.path(),
- req.bytesTransferred(),
- req.duration().toMillis(),
- getUserFriendlyThroughputString(req),
- req.uuid());
+ lastStatus, req.remoteURI(), req.path(), req.bytesTransferred(),
+ req.duration().toMillis(), getUserFriendlyThroughputString(req), req.uuid());
} else {
LOG.warn("Pull third-party transfer completed: {}. Source: {}, Destination: {}", lastStatus,
req.remoteURI(), req.path());
@@ -200,9 +197,8 @@ protected void logTransferDone(PutTransferRequest req) {
LOG.info(
"Push third-party transfer completed: {}. Source: {}, Destination: {}, Bytes transferred: {}, Duration (msec): {}, Throughput: {}/sec, id: {}",
- req.lastTransferStatus().get(), req.path(), req.remoteURI(),
- req.bytesTransferred(), req.duration().toMillis(), getUserFriendlyThroughputString(req),
- req.uuid());
+ req.lastTransferStatus().get(), req.path(), req.remoteURI(), req.bytesTransferred(),
+ req.duration().toMillis(), getUserFriendlyThroughputString(req), req.uuid());
}
}
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/TransferFilterSupport.java b/src/main/java/org/italiangrid/storm/webdav/tpc/TransferFilterSupport.java
index ad0b487d..29e23bea 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/TransferFilterSupport.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/TransferFilterSupport.java
@@ -16,7 +16,7 @@
package org.italiangrid.storm.webdav.tpc;
import static java.lang.String.format;
-import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
+import static jakarta.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import java.io.IOException;
@@ -28,11 +28,11 @@
import java.util.Enumeration;
import java.util.Optional;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpResponseException;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.HttpResponseException;
import org.italiangrid.storm.webdav.scitag.SciTag;
import org.italiangrid.storm.webdav.server.PathResolver;
import org.italiangrid.storm.webdav.tpc.transfer.TransferRequest;
@@ -99,9 +99,9 @@ protected Multimap getTransferHeaders(HttpServletRequest request
}
}
- if (isPushTpc(request, localURLService) && request.getContentLength() >= enableExpectContinueThreshold) {
- xferHeaders.put(org.apache.http.protocol.HTTP.EXPECT_DIRECTIVE,
- org.apache.http.protocol.HTTP.EXPECT_CONTINUE);
+ if (isPushTpc(request, localURLService)
+ && request.getContentLength() >= enableExpectContinueThreshold) {
+ xferHeaders.put("Expect", "100-continue");
}
return xferHeaders;
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/http/GetResponseHandler.java b/src/main/java/org/italiangrid/storm/webdav/tpc/http/GetResponseHandler.java
index 98b16e66..24008134 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/http/GetResponseHandler.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/http/GetResponseHandler.java
@@ -21,10 +21,10 @@
import java.util.Collections;
import java.util.Map;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.italiangrid.storm.webdav.checksum.Adler32ChecksumOutputStream;
import org.italiangrid.storm.webdav.fs.attrs.ExtendedAttributesHelper;
import org.italiangrid.storm.webdav.tpc.transfer.GetTransferRequest;
@@ -33,7 +33,7 @@
import org.slf4j.LoggerFactory;
public class GetResponseHandler extends ResponseHandlerSupport
- implements org.apache.http.client.ResponseHandler {
+ implements HttpClientResponseHandler {
public static final int DEFAULT_BUFFER_SIZE = 4096;
@@ -83,15 +83,14 @@ private void writeEntityToStream(HttpEntity entity, OutputStream os)
@Override
- public Boolean handleResponse(HttpResponse response) throws IOException {
+ public Boolean handleResponse(ClassicHttpResponse response) throws IOException {
setupMDC();
LOG.debug("Response: {}", response);
- StatusLine sl = response.getStatusLine();
HttpEntity entity = response.getEntity();
- checkResponseStatus(sl);
+ checkResponseStatus(response);
Adler32ChecksumOutputStream checkedStream = null;
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/http/HttpTransferClient.java b/src/main/java/org/italiangrid/storm/webdav/tpc/http/HttpTransferClient.java
index a4f77887..73cdfa53 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/http/HttpTransferClient.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/http/HttpTransferClient.java
@@ -32,15 +32,16 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.Method;
+import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.HttpResponseException;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.classic.methods.HttpHead;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.italiangrid.storm.webdav.config.ServiceConfigurationProperties;
import org.italiangrid.storm.webdav.config.ThirdPartyCopyProperties;
import org.italiangrid.storm.webdav.fs.attrs.ExtendedAttributesHelper;
@@ -105,10 +106,10 @@ public void destroy() throws Exception {
executorService.shutdownNow();
}
- HttpGet prepareRequest(GetTransferRequest request) {
+ BasicClassicHttpRequest prepareRequest(GetTransferRequest request) {
request.setTransferStatus(TransferStatus.builder(clock).inProgress(0));
- HttpGet get = new HttpGet(request.remoteURI());
+ BasicClassicHttpRequest get = new BasicClassicHttpRequest(Method.GET, request.remoteURI());
for (Map.Entry h : request.transferHeaders().entries()) {
get.addHeader(h.getKey(), h.getValue());
@@ -116,11 +117,11 @@ HttpGet prepareRequest(GetTransferRequest request) {
return get;
}
- HttpPut prepareRequest(PutTransferRequest request, HttpEntity cfe) {
+ BasicClassicHttpRequest prepareRequest(PutTransferRequest request, HttpEntity cfe) {
request.setTransferStatus(TransferStatus.builder(clock).inProgress(0));
- HttpPut put = new HttpPut(request.remoteURI());
+ BasicClassicHttpRequest put = new BasicClassicHttpRequest(Method.PUT, request.remoteURI());
for (Map.Entry h : request.transferHeaders().entries()) {
put.addHeader(h.getKey(), h.getValue());
@@ -167,7 +168,7 @@ StormCountingOutputStream prepareOutputStream(String path) {
public void handle(GetTransferRequest request, TransferStatusCallback cb) {
StormCountingOutputStream os = prepareOutputStream(resolver.resolvePath(request.path()));
- HttpGet get = prepareRequest(request);
+ BasicClassicHttpRequest get = prepareRequest(request);
HttpClientContext context = HttpClientContext.create();
ScheduledFuture> reportTask = executorService.scheduleAtFixedRate(
@@ -177,8 +178,8 @@ public void handle(GetTransferRequest request, TransferStatusCallback cb) {
try {
context.setAttribute(SciTag.SCITAG_ATTRIBUTE, request.scitag());
- httpClient.execute(get, new GetResponseHandler(request, os, attributesHelper,
- MDC.getCopyOfContextMap(), socketBufferSize, true), context);
+ httpClient.execute(get, context, new GetResponseHandler(request, os, attributesHelper,
+ MDC.getCopyOfContextMap(), socketBufferSize, true));
reportTask.cancel(true);
reportStatus(cb, request, statusBuilder.done(os.getCount()));
@@ -215,13 +216,15 @@ protected void checkOverwrite(PutTransferRequest request) throws IOException {
for (Map.Entry h : request.transferHeaders().entries()) {
head.addHeader(h.getKey(), h.getValue());
}
- CloseableHttpResponse response = httpClient.execute(head);
- if (response.getStatusLine().getStatusCode() == 200) {
- throw new TransferError("Remote file exists and overwrite is false");
- } else if (response.getStatusLine().getStatusCode() != 404) {
- throw new TransferError(format("Error checking if remote file exists: %d %s",
- response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()));
- }
+ httpClient.execute(head, response -> {
+ if (response.getCode() == 200) {
+ throw new TransferError("Remote file exists and overwrite is false");
+ } else if (response.getCode() != 404) {
+ throw new TransferError(format("Error checking if remote file exists: %d %s",
+ response.getCode(), response.getReasonPhrase()));
+ }
+ return null;
+ });
}
}
@@ -230,7 +233,7 @@ public void handle(PutTransferRequest request, TransferStatusCallback cb) {
CountingFileEntity cfe = prepareFileEntity(resolver.resolvePath(request.path()));
- HttpPut put = null;
+ BasicClassicHttpRequest put = null;
HttpClientContext context = HttpClientContext.create();
put = prepareRequest(request, cfe);
@@ -242,7 +245,7 @@ public void handle(PutTransferRequest request, TransferStatusCallback cb) {
try {
checkOverwrite(request);
context.setAttribute(SciTag.SCITAG_ATTRIBUTE, request.scitag());
- httpClient.execute(put, new PutResponseHandler(MDC.getCopyOfContextMap()), context);
+ httpClient.execute(put, context, new PutResponseHandler(MDC.getCopyOfContextMap()));
reportTask.cancel(true);
reportStatus(cb, request, statusBuilder.done(cfe.getCount()));
} catch (HttpResponseException e) {
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/http/HttpTransferClientMetricsWrapper.java b/src/main/java/org/italiangrid/storm/webdav/tpc/http/HttpTransferClientMetricsWrapper.java
index 80e58a3a..34a66439 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/http/HttpTransferClientMetricsWrapper.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/http/HttpTransferClientMetricsWrapper.java
@@ -17,7 +17,7 @@
import static com.codahale.metrics.MetricRegistry.name;
-import org.apache.http.client.ClientProtocolException;
+import org.apache.hc.client5.http.ClientProtocolException;
import org.italiangrid.storm.webdav.tpc.transfer.GetTransferRequest;
import org.italiangrid.storm.webdav.tpc.transfer.PutTransferRequest;
import org.italiangrid.storm.webdav.tpc.transfer.TransferClient;
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/http/PutResponseHandler.java b/src/main/java/org/italiangrid/storm/webdav/tpc/http/PutResponseHandler.java
index 7d4a5227..588fa39b 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/http/PutResponseHandler.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/http/PutResponseHandler.java
@@ -18,14 +18,15 @@
import java.io.IOException;
import java.util.Map;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-public class PutResponseHandler extends ResponseHandlerSupport implements ResponseHandler {
+public class PutResponseHandler extends ResponseHandlerSupport
+ implements HttpClientResponseHandler {
public static final Logger LOG = LoggerFactory.getLogger(PutResponseHandler.class);
@@ -34,11 +35,11 @@ public PutResponseHandler(Map mdcContextMap) {
}
@Override
- public Boolean handleResponse(HttpResponse response) throws IOException {
+ public Boolean handleResponse(ClassicHttpResponse response) throws IOException {
setupMDC();
-
+
try {
- checkResponseStatus(response.getStatusLine());
+ checkResponseStatus(response);
return true;
} finally {
EntityUtils.consumeQuietly(response.getEntity());
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/http/ResponseHandlerSupport.java b/src/main/java/org/italiangrid/storm/webdav/tpc/http/ResponseHandlerSupport.java
index 7ef4bb7d..25929a1c 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/http/ResponseHandlerSupport.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/http/ResponseHandlerSupport.java
@@ -17,8 +17,8 @@
import java.util.Map;
-import org.apache.http.StatusLine;
-import org.apache.http.client.HttpResponseException;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.client5.http.HttpResponseException;
import org.slf4j.MDC;
public abstract class ResponseHandlerSupport {
@@ -35,9 +35,9 @@ protected void setupMDC() {
}
}
- protected void checkResponseStatus(StatusLine sl) throws HttpResponseException {
- if (sl.getStatusCode() >= 300) {
- throw new HttpResponseException(sl.getStatusCode(), sl.getReasonPhrase());
+ protected void checkResponseStatus(HttpResponse response) throws HttpResponseException {
+ if (response.getCode() >= 300) {
+ throw new HttpResponseException(response.getCode(), response.getReasonPhrase());
}
}
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/http/SuperLaxRedirectStrategy.java b/src/main/java/org/italiangrid/storm/webdav/tpc/http/SuperLaxRedirectStrategy.java
deleted file mode 100644
index 025f159f..00000000
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/http/SuperLaxRedirectStrategy.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright (c) Istituto Nazionale di Fisica Nucleare, 2014-2023.
- *
- * 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 org.italiangrid.storm.webdav.tpc.http;
-
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolException;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.protocol.HttpContext;
-
-public class SuperLaxRedirectStrategy extends DefaultRedirectStrategy {
-
- /*
- * SUH stands for Sad, Useless Header.
- */
- public static final String SUH_HEADER = "X-SUH";
-
- public static final String AUTHORIZATION_HEADER = "Authorization";
-
- private static final String[] REDIRECT_METHODS = new String[] {HttpGet.METHOD_NAME,
- HttpPut.METHOD_NAME, HttpPost.METHOD_NAME, HttpHead.METHOD_NAME, HttpDelete.METHOD_NAME};
-
- public static final SuperLaxRedirectStrategy INSTANCE = new SuperLaxRedirectStrategy();
-
- private SuperLaxRedirectStrategy() {
- // empty ctor
- }
-
- @Override
- public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
- throws ProtocolException {
-
- HttpUriRequest redirect = super.getRedirect(request, response, context);
-
- /*
- * If this method returns an HttpUriRequest that has no HTTP headers then the RedirectExec code
- * will copy all the headers from the original request into the HttpUriRequest.
- * DefaultRedirectStrategy returns such requests under several circumstances. Therefore, in
- * order to suppress the Authorization header we must ensure the returned request
- * includes headers.
- */
- if (!redirect.headerIterator().hasNext()) {
- redirect.setHeaders(request.getAllHeaders());
- }
-
- redirect.removeHeaders(AUTHORIZATION_HEADER);
-
- if (!redirect.headerIterator().hasNext()) {
- /*
- * If the Authorization header was the only one set in the original request or in the redirect, we need to
- * add back an empty header otherwise the RedirectExec code will copy the Authorization header from the original
- * request back in.
- */
- redirect.addHeader(SUH_HEADER, "");
- }
-
- return redirect;
- }
-
-
- @Override
- protected boolean isRedirectable(String method) {
- for (final String m : REDIRECT_METHODS) {
- if (m.equalsIgnoreCase(method)) {
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/transfer/TransferClient.java b/src/main/java/org/italiangrid/storm/webdav/tpc/transfer/TransferClient.java
index 58dfd993..057758b9 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/transfer/TransferClient.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/transfer/TransferClient.java
@@ -15,12 +15,14 @@
*/
package org.italiangrid.storm.webdav.tpc.transfer;
-import org.apache.http.client.ClientProtocolException;
+import org.apache.hc.client5.http.ClientProtocolException;
public interface TransferClient {
- void handle(GetTransferRequest request, TransferStatusCallback status) throws ClientProtocolException;
-
- void handle(PutTransferRequest request, TransferStatusCallback status) throws ClientProtocolException;
+ void handle(GetTransferRequest request, TransferStatusCallback status)
+ throws ClientProtocolException;
+
+ void handle(PutTransferRequest request, TransferStatusCallback status)
+ throws ClientProtocolException;
}
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/utils/Adler32DigestHeaderHelper.java b/src/main/java/org/italiangrid/storm/webdav/tpc/utils/Adler32DigestHeaderHelper.java
index c75c991f..1f0469f4 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/utils/Adler32DigestHeaderHelper.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/utils/Adler32DigestHeaderHelper.java
@@ -22,8 +22,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpResponse;
public class Adler32DigestHeaderHelper {
diff --git a/src/main/java/org/italiangrid/storm/webdav/tpc/utils/CountingFileEntity.java b/src/main/java/org/italiangrid/storm/webdav/tpc/utils/CountingFileEntity.java
index e0d5e365..8c7757d5 100644
--- a/src/main/java/org/italiangrid/storm/webdav/tpc/utils/CountingFileEntity.java
+++ b/src/main/java/org/italiangrid/storm/webdav/tpc/utils/CountingFileEntity.java
@@ -15,13 +15,13 @@
*/
package org.italiangrid.storm.webdav.tpc.utils;
-import static org.apache.http.entity.ContentType.APPLICATION_OCTET_STREAM;
+import static org.apache.hc.core5.http.ContentType.APPLICATION_OCTET_STREAM;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.http.entity.FileEntity;
+import org.apache.hc.core5.http.io.entity.FileEntity;
import com.google.common.io.CountingOutputStream;
diff --git a/src/main/java/org/italiangrid/storm/webdav/web/ViewUtilsInterceptor.java b/src/main/java/org/italiangrid/storm/webdav/web/ViewUtilsInterceptor.java
index f1b54e2b..4021e2df 100644
--- a/src/main/java/org/italiangrid/storm/webdav/web/ViewUtilsInterceptor.java
+++ b/src/main/java/org/italiangrid/storm/webdav/web/ViewUtilsInterceptor.java
@@ -15,8 +15,8 @@
*/
package org.italiangrid.storm.webdav.web;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.italiangrid.storm.webdav.authn.AuthenticationUtils;
import org.italiangrid.storm.webdav.config.OAuthProperties;
diff --git a/src/main/resources/application-redis.yml b/src/main/resources/application-redis.yml
index a1431435..5e77524b 100644
--- a/src/main/resources/application-redis.yml
+++ b/src/main/resources/application-redis.yml
@@ -4,10 +4,11 @@ management:
enabled: true
spring:
- redis:
- host: ${STORM_WEBDAV_REDIS_HOST:localhost}
- port: ${STORM_WEBDAV_REDIS_PORT:6379}
- password: ${STORM_WEBDAV_REDIS_PASSWORD:}
+ data:
+ redis:
+ host: ${STORM_WEBDAV_REDIS_HOST:localhost}
+ port: ${STORM_WEBDAV_REDIS_PORT:6379}
+ password: ${STORM_WEBDAV_REDIS_PASSWORD:}
session:
- store-type: redis
\ No newline at end of file
+ store-type: redis
diff --git a/src/test/java/org/italiangrid/storm/webdav/server/TLSConnectorBuilderTest.java b/src/test/java/org/italiangrid/storm/webdav/server/TLSConnectorBuilderTest.java
index b7fcbba9..408bee0f 100644
--- a/src/test/java/org/italiangrid/storm/webdav/server/TLSConnectorBuilderTest.java
+++ b/src/test/java/org/italiangrid/storm/webdav/server/TLSConnectorBuilderTest.java
@@ -24,7 +24,7 @@
import javax.net.ssl.KeyManager;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
@@ -114,4 +114,4 @@ void tlsConnectorBuilderTests() {
ServerConnector c = builder.build();
assertThat(c.getPort(), is(1234));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/italiangrid/storm/webdav/server/servlet/AvoidTraceMethodFilterTest.java b/src/test/java/org/italiangrid/storm/webdav/server/servlet/AvoidTraceMethodFilterTest.java
index f4ed7af1..fb11740b 100644
--- a/src/test/java/org/italiangrid/storm/webdav/server/servlet/AvoidTraceMethodFilterTest.java
+++ b/src/test/java/org/italiangrid/storm/webdav/server/servlet/AvoidTraceMethodFilterTest.java
@@ -70,27 +70,27 @@ void traceAsNonAnonymousOnRootLeadsTo405() throws Exception {
@Test
void trackAsAnonymousLeadsTo405() throws Exception {
- mvc.perform(MockMvcRequestBuilders.request("TRACK", new URI("/test/file")))
+ mvc.perform(MockMvcRequestBuilders.request(HttpMethod.valueOf("TRACK"), new URI("/test/file")))
.andExpect(status().isMethodNotAllowed());
}
@Test
@WithMockVOMSUser(vos = "wlcg", saReadPermissions = {"wlcg"})
void trackAsNonAnonymousLeadsTo405() throws Exception {
- mvc.perform(MockMvcRequestBuilders.request("TRACK", new URI("/wlcg/file")))
+ mvc.perform(MockMvcRequestBuilders.request(HttpMethod.valueOf("TRACK"), new URI("/wlcg/file")))
.andExpect(status().isMethodNotAllowed());
}
@Test
void trackAsAnonymousOnRootLeadsTo405() throws Exception {
- mvc.perform(MockMvcRequestBuilders.request("TRACK", new URI("/")))
+ mvc.perform(MockMvcRequestBuilders.request(HttpMethod.valueOf("TRACK"), new URI("/")))
.andExpect(status().isMethodNotAllowed());
}
@Test
@WithMockVOMSUser(vos = "wlcg", saReadPermissions = {"wlcg"})
void trackAsNonAnonymousOnRootLeadsTo405() throws Exception {
- mvc.perform(MockMvcRequestBuilders.request("TRACK", new URI("/")))
+ mvc.perform(MockMvcRequestBuilders.request(HttpMethod.valueOf("TRACK"), new URI("/")))
.andExpect(status().isMethodNotAllowed());
}
diff --git a/src/test/java/org/italiangrid/storm/webdav/test/authz/AuthzTest.java b/src/test/java/org/italiangrid/storm/webdav/test/authz/AuthzTest.java
index 698d9572..4d0e697f 100644
--- a/src/test/java/org/italiangrid/storm/webdav/test/authz/AuthzTest.java
+++ b/src/test/java/org/italiangrid/storm/webdav/test/authz/AuthzTest.java
@@ -19,6 +19,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.italiangrid.storm.webdav.authz.VOMSAuthenticationFilter;
+import org.italiangrid.storm.webdav.config.ServiceConfigurationProperties;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
@@ -43,6 +44,9 @@ class AuthzTest {
@Autowired
VOMSAuthenticationFilter filter;
+ @Autowired
+ ServiceConfigurationProperties props;
+
@BeforeEach
public void setup() {
filter.setCheckForPrincipalChanges(false);
diff --git a/src/test/java/org/italiangrid/storm/webdav/test/authz/integration/AuthorizationIntegrationTests.java b/src/test/java/org/italiangrid/storm/webdav/test/authz/integration/AuthorizationIntegrationTests.java
index db4c60c4..9295aaf8 100644
--- a/src/test/java/org/italiangrid/storm/webdav/test/authz/integration/AuthorizationIntegrationTests.java
+++ b/src/test/java/org/italiangrid/storm/webdav/test/authz/integration/AuthorizationIntegrationTests.java
@@ -36,6 +36,7 @@
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.http.HttpMethod;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.test.context.support.WithAnonymousUser;
import org.springframework.test.context.ActiveProfiles;
@@ -281,17 +282,17 @@ void writeAccessWithoutMatchedJWTIsDenied() throws Exception {
@WithMockVOMSUser(vos = "wlcg", saReadPermissions = {"wlcg"})
@Test
void localVomsCopyRequiresWithReadPermissionsGetsAccessDenied() throws Exception {
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source")).header("Destination",
- "http://localhost/wlcg/destination"))
+ mvc
+ .perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
+ .header("Destination", "http://localhost/wlcg/destination"))
.andExpect(status().isForbidden());
}
@WithMockVOMSUser(vos = "wlcg", saWritePermissions = {"wlcg"}, saReadPermissions = {"wlcg"})
@Test
void localVomsCopyRequiresReadAndWritePermissions() throws Exception {
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source")).header("Destination",
- "http://localhost/wlcg/destination"))
- .andExpect(status().isOk());
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
+ .header("Destination", "http://localhost/wlcg/destination")).andExpect(status().isOk());
}
@Test
@@ -303,7 +304,7 @@ void tpcJwtPullCopyBlockedWithStorageReadScope() throws Exception {
.claim("scope", "storage.read:/")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Source", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isForbidden());
}
@@ -317,7 +318,7 @@ void tpcJwtPullCopyRequiresStorageModifyScope() throws Exception {
.claim("scope", "storage.modify:/")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Source", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isAccepted());
}
@@ -331,7 +332,7 @@ void tpcJwtPullCopyRequiresStorageModifyScopeWithRightPath() throws Exception {
.claim("scope", "storage.modify:/subdir storage.read:/")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Source", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isForbidden());
}
@@ -346,7 +347,7 @@ void tpcJwtLocalCopyRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.read:/")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isForbidden());
@@ -357,7 +358,7 @@ void tpcJwtLocalCopyRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.modify:/")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isForbidden());
@@ -368,7 +369,7 @@ void tpcJwtLocalCopyRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.read:/ storage.modify:/")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isOk());
@@ -379,7 +380,7 @@ void tpcJwtLocalCopyRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.read:/subdir storage.modify:/")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isForbidden());
@@ -390,7 +391,7 @@ void tpcJwtLocalCopyRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.read:/ storage.modify:/subdir")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isForbidden());
@@ -401,7 +402,7 @@ void tpcJwtLocalCopyRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.read:/source storage.modify:/destination")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isOk());
}
@@ -415,7 +416,7 @@ void tpcJwtLocalMoveRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.read:/")
.build();
- mvc.perform(request("MOVE", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("MOVE"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isForbidden());
@@ -426,7 +427,7 @@ void tpcJwtLocalMoveRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.modify:/")
.build();
- mvc.perform(request("MOVE", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("MOVE"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isOk());
@@ -438,7 +439,7 @@ void tpcJwtLocalMoveRequiresAppropriatePermissions() throws Exception {
.claim("scope", "storage.modify:/subdir")
.build();
- mvc.perform(request("MOVE", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("MOVE"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isForbidden());
@@ -450,7 +451,7 @@ void tpcJwtLocalMoveRequiresAppropriatePermissions() throws Exception {
.claim("scope", "openid storage.modify:/source storage.modify:/destination")
.build();
- mvc.perform(request("MOVE", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("MOVE"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token))).andExpect(status().isOk());
}
@@ -465,7 +466,7 @@ void tpcJwtFineGrainedAuthzCopyTests() throws Exception {
.subject("123")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token).authorities(authConverter))).andExpect(status().isForbidden());
@@ -477,7 +478,7 @@ void tpcJwtFineGrainedAuthzCopyTests() throws Exception {
.claim("groups", "/example/admins")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token).authorities(authConverter))).andExpect(status().isOk());
@@ -488,7 +489,7 @@ void tpcJwtFineGrainedAuthzCopyTests() throws Exception {
.claim("groups", "/example")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token).authorities(authConverter))).andExpect(status().isForbidden());
@@ -499,7 +500,7 @@ void tpcJwtFineGrainedAuthzCopyTests() throws Exception {
.claim("groups", "/example/admins")
.build();
- mvc.perform(request("COPY", URI.create("http://localhost/wlcg/source"))
+ mvc.perform(request(HttpMethod.valueOf("COPY"), URI.create("http://localhost/wlcg/source"))
.header("Destination", "http://localhost/wlcg/destination")
.with(jwt().jwt(token).authorities(authConverter))).andExpect(status().isForbidden());
diff --git a/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/AuthzPdpTests.java b/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/AuthzPdpTests.java
index 342326fc..460a0fbb 100644
--- a/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/AuthzPdpTests.java
+++ b/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/AuthzPdpTests.java
@@ -27,7 +27,7 @@
import java.util.List;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.italiangrid.storm.webdav.authz.VOMSFQANAuthority;
import org.italiangrid.storm.webdav.authz.VOMSVOAuthority;
diff --git a/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/LocalAuthzPdpTests.java b/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/LocalAuthzPdpTests.java
index 3f082100..26be701f 100644
--- a/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/LocalAuthzPdpTests.java
+++ b/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/LocalAuthzPdpTests.java
@@ -28,7 +28,7 @@
import java.net.URL;
import java.util.Enumeration;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.italiangrid.storm.webdav.authz.pdp.LocalAuthorizationPdp;
import org.italiangrid.storm.webdav.authz.pdp.PathAuthorizationResult;
diff --git a/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/PolicyPropertiesValidationTests.java b/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/PolicyPropertiesValidationTests.java
index 31cfea4f..913b5a54 100644
--- a/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/PolicyPropertiesValidationTests.java
+++ b/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/PolicyPropertiesValidationTests.java
@@ -25,10 +25,10 @@
import java.util.Locale;
import java.util.Set;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
import org.italiangrid.storm.webdav.authz.pdp.PolicyEffect;
import org.italiangrid.storm.webdav.config.FineGrainedAuthzPolicyProperties;
diff --git a/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/ScopePathAuthzPdpTests.java b/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/ScopePathAuthzPdpTests.java
index 803f7f59..726568f9 100644
--- a/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/ScopePathAuthzPdpTests.java
+++ b/src/test/java/org/italiangrid/storm/webdav/test/authz/pdp/ScopePathAuthzPdpTests.java
@@ -30,7 +30,7 @@
import java.net.URL;
import java.util.Enumeration;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.italiangrid.storm.webdav.authz.pdp.PathAuthorizationResult;
import org.italiangrid.storm.webdav.authz.pdp.PathAuthorizationResult.Decision;
@@ -460,8 +460,7 @@ void parentDirCreationIsNotAllowedWithWrongScopes() {
lenient().when(pathResolver.resolveStorageArea(anyString())).thenReturn(sa);
lenient().when(request.getPathInfo()).thenReturn("test/dir/subdir");
- lenient().when(jwt.getClaimAsString(SCOPE_CLAIM))
- .thenReturn("openid storage.read:/dir/subdir");
+ lenient().when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid storage.read:/dir/subdir");
lenient().when(request.getMethod()).thenReturn("MKCOL");
PathAuthorizationResult result =
pdp.authorizeRequest(newAuthorizationRequest(request, jwtAuth));
diff --git a/src/test/java/org/italiangrid/storm/webdav/test/oauth/integration/OAuthAuthzServerIntegrationTests.java b/src/test/java/org/italiangrid/storm/webdav/test/oauth/integration/OAuthAuthzServerIntegrationTests.java
index 41eaaac3..f2d36cf8 100644
--- a/src/test/java/org/italiangrid/storm/webdav/test/oauth/integration/OAuthAuthzServerIntegrationTests.java
+++ b/src/test/java/org/italiangrid/storm/webdav/test/oauth/integration/OAuthAuthzServerIntegrationTests.java
@@ -16,7 +16,6 @@
package org.italiangrid.storm.webdav.test.oauth.integration;
import static java.lang.String.format;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.hamcrest.CoreMatchers.is;
import static org.italiangrid.storm.webdav.oauth.authzserver.ErrorResponseDTO.UNSUPPORTED_GRANT_TYPE;
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED;
@@ -30,6 +29,7 @@
import java.time.Instant;
import java.time.ZoneId;
+import org.apache.commons.lang3.RandomStringUtils;
import org.italiangrid.storm.webdav.authz.VOMSAuthenticationFilter;
import org.italiangrid.storm.webdav.config.ServiceConfigurationProperties;
import org.italiangrid.storm.webdav.oauth.authzserver.AccessTokenRequest;
@@ -161,7 +161,9 @@ void requestedLifetimeLimited() throws Exception {
@WithMockVOMSUser
void scopeLengthIsChecked() throws Exception {
- String randomAlphabetic = randomAlphabetic(AccessTokenRequest.MAX_SCOPE_LENGTH);
+ RandomStringUtils randomStringUtils = RandomStringUtils.insecure();
+
+ String randomAlphabetic = randomStringUtils.nextAlphabetic(AccessTokenRequest.MAX_SCOPE_LENGTH);
mvc
.perform(post("/oauth/token").content(format("%s&scope=%s", CONTENT, randomAlphabetic))
@@ -169,7 +171,7 @@ void scopeLengthIsChecked() throws Exception {
.andExpect(status().isOk())
.andExpect(jsonPath("$.access_token").exists());
- randomAlphabetic = randomAlphabetic(AccessTokenRequest.MAX_SCOPE_LENGTH + 1);
+ randomAlphabetic = randomStringUtils.nextAlphabetic(AccessTokenRequest.MAX_SCOPE_LENGTH + 1);
mvc
.perform(post("/oauth/token").content(format("%s&scope=%s", CONTENT, randomAlphabetic))
diff --git a/src/test/java/org/italiangrid/storm/webdav/test/oauth/jwk/OidcConfigurationFetcherTest.java b/src/test/java/org/italiangrid/storm/webdav/test/oauth/jwk/OidcConfigurationFetcherTest.java
index 0725f914..64f93704 100644
--- a/src/test/java/org/italiangrid/storm/webdav/test/oauth/jwk/OidcConfigurationFetcherTest.java
+++ b/src/test/java/org/italiangrid/storm/webdav/test/oauth/jwk/OidcConfigurationFetcherTest.java
@@ -49,6 +49,7 @@
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpStatus;
+import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@@ -94,8 +95,7 @@ private ResponseEntity