Migrated to Spring Boot 3, build completes, was forced to update to httpclient5 from apache. Need to verify no impact on ssl mechanism after changes

This commit is contained in:
mstrankowski 2023-09-19 09:24:26 +02:00
parent 1c1ed8724b
commit 1a821500b1
48 changed files with 204 additions and 155 deletions

View File

@ -71,8 +71,8 @@
<artifactId>pooled-jms</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>

View File

@ -56,7 +56,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.net.URL;

View File

@ -31,9 +31,9 @@ import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import java.util.Optional;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest;

View File

@ -34,8 +34,8 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest;

View File

@ -30,11 +30,11 @@ import static org.alfresco.transformer.fs.FileManager.SOURCE_FILE;
import static org.alfresco.transformer.fs.FileManager.TARGET_FILE;
import static org.alfresco.transformer.fs.FileManager.deleteFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.alfresco.transformer.logging.LogEntry;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
/**
* @deprecated will be removed in a future release. Replaced by alfresco-base-t-engine.
@ -44,7 +44,7 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
* Handles ThreadLocal Log entries for each request.
*/
@Deprecated
public class TransformInterceptor extends HandlerInterceptorAdapter
public class TransformInterceptor implements AsyncHandlerInterceptor
{
@Override
public boolean preHandle(HttpServletRequest request,

View File

@ -33,7 +33,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import org.alfresco.transform.config.TransformConfig;
import org.alfresco.transform.registry.AbstractTransformRegistry;

View File

@ -39,6 +39,7 @@ import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.HttpClientErrorException;
@ -73,7 +74,7 @@ public class AlfrescoSharedFileStoreClient
}
catch (HttpClientErrorException e)
{
throw new TransformException(e.getStatusCode(), e.getMessage(), e);
throw new TransformException(HttpStatus.resolve(e.getStatusCode().value()), e.getMessage(), e);
}
}
@ -100,7 +101,7 @@ public class AlfrescoSharedFileStoreClient
}
catch (HttpClientErrorException e)
{
throw new TransformException(e.getStatusCode(), e.getMessage(), e);
throw new TransformException(HttpStatus.resolve(e.getStatusCode().value()), e.getMessage(), e);
}
}
}

View File

@ -26,12 +26,18 @@
*/
package org.alfresco.transformer.config;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager;
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -40,7 +46,6 @@ import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
@ -120,11 +125,23 @@ public class MTLSConfig {
}
private RestTemplate createRestTemplateWithSslContext(SSLContextBuilder sslContextBuilder) throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sslContext = sslContextBuilder.build();
SSLConnectionSocketFactory sslContextFactory = hostNameVerificationDisabled ? new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE)
: new SSLConnectionSocketFactory(sslContext);
final SSLConnectionSocketFactoryBuilder sslConnectionSocketFactoryBuilder =
SSLConnectionSocketFactoryBuilder.create()
.setSslContext(sslContextBuilder.build())
.setTlsVersions(TLS.V_1_2, TLS.V_1_3);
if (hostNameVerificationDisabled) {
sslConnectionSocketFactoryBuilder.setHostnameVerifier(NoopHostnameVerifier.INSTANCE);
}
final SSLConnectionSocketFactory sslConnectionSocketFactory = sslConnectionSocketFactoryBuilder.build();
HttpClientBuilder httpClientBuilder = HttpClients.custom().setSSLSocketFactory(sslContextFactory);
final Registry<ConnectionSocketFactory> sslSocketFactoryRegistry =
RegistryBuilder.<ConnectionSocketFactory> create()
.register("https", sslConnectionSocketFactory)
.build();
final BasicHttpClientConnectionManager sslConnectionManager = new BasicHttpClientConnectionManager(sslSocketFactoryRegistry);
HttpClientBuilder httpClientBuilder = HttpClients.custom().setConnectionManager(sslConnectionManager);
CloseableHttpClient httpClient = httpClientBuilder.build();
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
return new RestTemplate(requestFactory);

View File

@ -40,7 +40,7 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.alfresco.transform.exceptions.TransformException;
import org.alfresco.transformer.logging.LogEntry;

View File

@ -26,8 +26,8 @@
*/
package org.alfresco.transformer.messaging;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Queue;
import org.alfresco.transform.messages.TransformRequestValidator;
import org.apache.activemq.command.ActiveMQQueue;

View File

@ -26,7 +26,7 @@
*/
package org.alfresco.transformer.messaging;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -39,9 +39,9 @@ import org.springframework.jms.support.converter.MessageType;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.Session;
/**
* @deprecated will be removed in a future release. Replaced by alfresco-base-t-engine.

View File

@ -26,7 +26,7 @@
*/
package org.alfresco.transformer.messaging;
import javax.jms.Destination;
import jakarta.jms.Destination;
import org.alfresco.transform.client.model.TransformReply;
import org.slf4j.Logger;

View File

@ -42,7 +42,7 @@ import java.nio.file.StandardCopyOption;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.alfresco.transform.exceptions.TransformException;
import org.alfresco.transformer.AbstractTransformerController;

View File

@ -36,7 +36,7 @@ import static org.springframework.test.util.AssertionErrors.assertTrue;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;

View File

@ -28,7 +28,7 @@ package org.alfresco.transformer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import javax.jms.Queue;
import jakarta.jms.Queue;
import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest;

View File

@ -36,9 +36,9 @@ import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest;

View File

@ -88,13 +88,8 @@
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<scope>test</scope>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>

View File

@ -57,10 +57,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.PostConstruct;
import javax.jms.Destination;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.annotation.PostConstruct;
import jakarta.jms.Destination;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;

View File

@ -29,12 +29,18 @@ package org.alfresco.transform.base.config;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import org.alfresco.transform.base.WebClientBuilderAdjuster;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager;
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -46,7 +52,6 @@ import org.springframework.web.client.RestTemplate;
import reactor.netty.http.client.HttpClient;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLParameters;
@ -179,11 +184,23 @@ public class MTLSConfig {
}
private RestTemplate createRestTemplateWithSslContext(SSLContextBuilder sslContextBuilder) throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sslContext = sslContextBuilder.build();
SSLConnectionSocketFactory sslContextFactory = hostNameVerificationDisabled ? new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE)
: new SSLConnectionSocketFactory(sslContext);
final SSLConnectionSocketFactoryBuilder sslConnectionSocketFactoryBuilder =
SSLConnectionSocketFactoryBuilder.create()
.setSslContext(sslContextBuilder.build())
.setTlsVersions(TLS.V_1_2, TLS.V_1_3);
if (hostNameVerificationDisabled) {
sslConnectionSocketFactoryBuilder.setHostnameVerifier(NoopHostnameVerifier.INSTANCE);
}
final SSLConnectionSocketFactory sslConnectionSocketFactory = sslConnectionSocketFactoryBuilder.build();
HttpClientBuilder httpClientBuilder = HttpClients.custom().setSSLSocketFactory(sslContextFactory);
final Registry<ConnectionSocketFactory> sslSocketFactoryRegistry =
RegistryBuilder.<ConnectionSocketFactory> create()
.register("https", sslConnectionSocketFactory)
.build();
final BasicHttpClientConnectionManager sslConnectionManager = new BasicHttpClientConnectionManager(sslSocketFactoryRegistry);
HttpClientBuilder httpClientBuilder = HttpClients.custom().setConnectionManager(sslConnectionManager);
CloseableHttpClient httpClient = httpClientBuilder.build();
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
return new RestTemplate(requestFactory);

View File

@ -35,7 +35,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriUtils;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

View File

@ -30,11 +30,10 @@ import static org.alfresco.transform.base.fs.FileManager.SOURCE_FILE;
import static org.alfresco.transform.base.fs.FileManager.TARGET_FILE;
import static org.alfresco.transform.base.fs.FileManager.deleteFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
/**
* Cleans up temporary files in transform requests that upload the content and download the result.

View File

@ -40,8 +40,8 @@ import org.springframework.lang.NonNull;
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory;
import org.springframework.transaction.PlatformTransactionManager;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Queue;
/**
* JMS and messaging configuration for the T-Engines. Contains the basic config in order to have the

View File

@ -26,7 +26,7 @@
*/
package org.alfresco.transform.base.messaging;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -39,9 +39,9 @@ import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.stereotype.Component;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import java.util.Optional;
import static org.springframework.http.HttpStatus.BAD_REQUEST;

View File

@ -39,9 +39,9 @@ import org.springframework.jms.support.converter.MessageType;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.Session;
/**
* Copied from the t-router. We would need to create a common dependency between t-engine base and t-router that

View File

@ -26,7 +26,7 @@
*/
package org.alfresco.transform.base.messaging;
import javax.jms.Destination;
import jakarta.jms.Destination;
import org.alfresco.transform.client.model.TransformReply;
import org.slf4j.Logger;

View File

@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@ -35,7 +35,7 @@ import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

View File

@ -32,7 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.util.List;
/**

View File

@ -45,6 +45,7 @@ import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -53,7 +54,7 @@ import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import javax.net.ssl.SSLException;
/**
@ -100,7 +101,7 @@ public class SharedFileStoreClient
}
catch (HttpClientErrorException e)
{
throw new TransformException(e.getStatusCode(), e.getMessage(), e);
throw new TransformException(HttpStatus.resolve(e.getStatusCode().value()), e.getMessage(), e);
}
}
@ -127,7 +128,7 @@ public class SharedFileStoreClient
}
catch (HttpClientErrorException e)
{
throw new TransformException(e.getStatusCode(), e.getMessage(), e);
throw new TransformException(HttpStatus.resolve(e.getStatusCode().value()), e.getMessage(), e);
}
}

View File

@ -37,8 +37,8 @@ import org.alfresco.transform.common.TransformerDebug;
import org.alfresco.transform.registry.TransformServiceRegistry;
import org.springframework.web.multipart.MultipartFile;
import javax.jms.Destination;
import javax.servlet.http.HttpServletRequest;
import jakarta.jms.Destination;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;

View File

@ -52,8 +52,8 @@ import org.springframework.validation.Errors;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.multipart.MultipartFile;
import javax.jms.Destination;
import javax.servlet.http.HttpServletRequest;
import jakarta.jms.Destination;
import jakarta.servlet.http.HttpServletRequest;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
@ -372,7 +372,7 @@ public class TransformHandler
}
catch (HttpClientErrorException e)
{
throw new TransformException(e.getStatusCode(), messageWithCause("Failed to read the source from the SFS", e));
throw new TransformException(HttpStatus.resolve(e.getStatusCode().value()), messageWithCause("Failed to read the source from the SFS", e));
}
}
@ -394,7 +394,7 @@ public class TransformHandler
}
catch (HttpClientErrorException e)
{
throw new TransformException(e.getStatusCode(), messageWithCause(FAILED_WRITING_TO_SFS, e));
throw new TransformException(HttpStatus.resolve(e.getStatusCode().value()), messageWithCause(FAILED_WRITING_TO_SFS, e));
}
catch (Exception e)
{

View File

@ -33,7 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

View File

@ -1,10 +1,17 @@
package org.alfresco.transform.base;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager;
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@ -59,10 +66,26 @@ public class MtlsTestUtils {
.loadTrustMaterial(trustStore, trustStorePassword);
SSLContext sslContext = sslContextBuilder.build();
SSLConnectionSocketFactory sslContextFactory = HOSTNAME_VERIFICATION_DISABLED ? new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE)
: new SSLConnectionSocketFactory(sslContext);
return HttpClients.custom().setSSLSocketFactory(sslContextFactory).build();
return HttpClients.custom().setConnectionManager(buildSslConnectionManager(sslContext)).build();
}
private static HttpClientConnectionManager buildSslConnectionManager(SSLContext sslContext) {
final SSLConnectionSocketFactoryBuilder sslConnectionSocketFactoryBuilder =
SSLConnectionSocketFactoryBuilder.create()
.setSslContext(sslContext)
.setTlsVersions(TLS.V_1_2, TLS.V_1_3);
if (HOSTNAME_VERIFICATION_DISABLED) {
sslConnectionSocketFactoryBuilder.setHostnameVerifier(NoopHostnameVerifier.INSTANCE);
}
final SSLConnectionSocketFactory sslConnectionSocketFactory = sslConnectionSocketFactoryBuilder.build();
final Registry<ConnectionSocketFactory> sslSocketFactoryRegistry =
RegistryBuilder.<ConnectionSocketFactory> create()
.register("https", sslConnectionSocketFactory)
.build();
return new BasicHttpClientConnectionManager(sslSocketFactoryRegistry);
}
public static RestTemplate restTemplateWithMtls()

View File

@ -8,15 +8,15 @@
package org.alfresco.transform.base.clients;
import javax.jms.BytesMessage;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import jakarta.jms.BytesMessage;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.DeliveryMode;
import jakarta.jms.Destination;
import jakarta.jms.MessageConsumer;
import jakarta.jms.MessageProducer;
import jakarta.jms.Session;
import jakarta.jms.TextMessage;
import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest;

View File

@ -22,17 +22,18 @@ import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import org.alfresco.transform.base.MtlsTestUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
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.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.classic.methods.HttpHead;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.entity.mime.FileBody;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpEntityContainer;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableMap;
@ -71,17 +72,17 @@ public class SfsClient
sfsBaseUrl+"/alfresco/api/-default-/private/sfs/versions/1/file");
post.setEntity(MultipartEntityBuilder
.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.setMode(HttpMultipartMode.LEGACY)
.addPart("file", new FileBody(file, ContentType.DEFAULT_BINARY))
.build());
try (CloseableHttpClient client = MtlsTestUtils.getHttpClient())
{
final HttpResponse response = client.execute(post);
int status = response.getStatusLine().getStatusCode();
int status = response.getCode();
if (status >= 200 && status < 300)
{
return JacksonSerializer.readStringValue(EntityUtils.toString(response.getEntity()),
return JacksonSerializer.readStringValue(EntityUtils.toString(((HttpEntityContainer) response).getEntity()),
"entry.fileRef");
}
else
@ -137,7 +138,7 @@ public class SfsClient
try (CloseableHttpClient client = MtlsTestUtils.getHttpClient())
{
final HttpResponse response = client.execute(head);
final int status = response.getStatusLine().getStatusCode();
final int status = response.getCode();
return status >= 200 && status < 300;
}
}
@ -156,12 +157,12 @@ public class SfsClient
try (CloseableHttpClient client = MtlsTestUtils.getHttpClient())
{
final HttpResponse response = client.execute(get);
final int status = response.getStatusLine().getStatusCode();
final int status = response.getCode();
if (status < 200 || status >= 300)
{
throw new Exception("File with UUID " + uuid + " was not found on SFS");
}
final HttpEntity entity = response.getEntity();
final HttpEntity entity = ((HttpEntityContainer) response).getEntity();
if (entity == null)
{
throw new Exception("Failed to read HTTP reply entity for file with UUID " + uuid);

View File

@ -28,7 +28,7 @@ package org.alfresco.transform.base.messaging;
import static org.junit.jupiter.api.Assertions.assertEquals;
import javax.jms.Queue;
import jakarta.jms.Queue;
import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest;

View File

@ -38,9 +38,9 @@ import org.mockito.Mock;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jms.support.converter.MessageConversionException;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;

View File

@ -51,7 +51,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import javax.jms.Destination;
import jakarta.jms.Destination;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

View File

@ -52,7 +52,7 @@ import static org.alfresco.transform.common.RequestParamMap.START_PAGE;
import static org.alfresco.transform.common.RequestParamMap.THUMBNAIL;
import static org.alfresco.transform.common.RequestParamMap.TIMEOUT;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.io.File;
import java.util.HashMap;
import java.util.List;

View File

@ -34,8 +34,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeException;

View File

@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;

View File

@ -72,9 +72,9 @@
<!-- EMLTransformer -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>

View File

@ -32,11 +32,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.mail.Header;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
import javax.mail.internet.MimeUtility;
import jakarta.mail.Header;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeMessage;
import jakarta.mail.internet.MimeMessage.RecipientType;
import jakarta.mail.internet.MimeUtility;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;

View File

@ -33,11 +33,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import jakarta.mail.MessagingException;
import jakarta.mail.Multipart;
import jakarta.mail.Part;
import jakarta.mail.Session;
import jakarta.mail.internet.MimeMessage;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;

View File

@ -35,7 +35,7 @@ import org.alfresco.transform.pdfrenderer.PdfRendererOptionsBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.io.File;
import java.util.HashMap;
import java.util.Map;

13
pom.xml
View File

@ -10,7 +10,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.14</version>
<version>3.1.3</version>
</parent>
<properties>
@ -220,14 +220,9 @@
<version>1.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.14</version>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>