diff options
-rw-r--r-- | http-utils/OWNERS | 1 | ||||
-rw-r--r-- | http-utils/README.md | 1 | ||||
-rw-r--r-- | http-utils/pom.xml | 52 | ||||
-rw-r--r-- | jrt/pom.xml | 10 | ||||
-rw-r--r-- | pom.xml | 1 | ||||
-rw-r--r-- | security-utils/pom.xml | 10 | ||||
-rw-r--r-- | security-utils/src/main/java/com/yahoo/security/tls/https/VespaHttpClientBuilder.java (renamed from http-utils/src/main/java/ai/vespa/util/http/VespaHttpClientBuilder.java) | 32 | ||||
-rw-r--r-- | security-utils/src/test/java/com/yahoo/security/tls/https/VespaHttpClientBuilderTest.java (renamed from http-utils/src/test/java/ai/vespa/util/http/VespaHttpClientBuilderTest.java) | 4 |
8 files changed, 25 insertions, 86 deletions
diff --git a/http-utils/OWNERS b/http-utils/OWNERS deleted file mode 100644 index 569bf1cc3a1..00000000000 --- a/http-utils/OWNERS +++ /dev/null @@ -1 +0,0 @@ -bjorncs diff --git a/http-utils/README.md b/http-utils/README.md deleted file mode 100644 index 8bbe2cd7d05..00000000000 --- a/http-utils/README.md +++ /dev/null @@ -1 +0,0 @@ -# Http utilities for Java
\ No newline at end of file diff --git a/http-utils/pom.xml b/http-utils/pom.xml deleted file mode 100644 index aea402aef87..00000000000 --- a/http-utils/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>7-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <artifactId>http-utils</artifactId> - <packaging>jar</packaging> - <version>7-SNAPSHOT</version> - <dependencies> - <!-- provided --> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>security-utils</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <!-- compile scope --> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpcore</artifactId> - <scope>compile</scope> - </dependency> - - <!-- test scope --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/jrt/pom.xml b/jrt/pom.xml index 5208c0417cc..e9383654e30 100644 --- a/jrt/pom.xml +++ b/jrt/pom.xml @@ -34,6 +34,16 @@ <artifactId>security-utils</artifactId> <version>${project.version}</version> <scope>compile</scope> + <exclusions> + <exclusion> <!-- not needed --> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </exclusion> + <exclusion> <!-- not needed --> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <!-- required due to bug in maven dependency resolving - bouncycastle is compile scope in security-utils, yet it is not part of test scope here --> <groupId>org.bouncycastle</groupId> @@ -79,7 +79,6 @@ <module>filedistribution</module> <module>flags</module> <module>fsa</module> - <module>http-utils</module> <module>indexinglanguage</module> <module>jaxrs_client_utils</module> <module>jaxrs_utils</module> diff --git a/security-utils/pom.xml b/security-utils/pom.xml index 10dec598915..f7704762250 100644 --- a/security-utils/pom.xml +++ b/security-utils/pom.xml @@ -31,6 +31,16 @@ <artifactId>jackson-databind</artifactId> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <scope>compile</scope> + </dependency> <!-- test scope --> <dependency> diff --git a/http-utils/src/main/java/ai/vespa/util/http/VespaHttpClientBuilder.java b/security-utils/src/main/java/com/yahoo/security/tls/https/VespaHttpClientBuilder.java index 5e7a9441fc8..9fa51fc36cb 100644 --- a/http-utils/src/main/java/ai/vespa/util/http/VespaHttpClientBuilder.java +++ b/security-utils/src/main/java/com/yahoo/security/tls/https/VespaHttpClientBuilder.java @@ -1,5 +1,5 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package ai.vespa.util.http; +package com.yahoo.security.tls.https; import com.yahoo.security.tls.MixedMode; import com.yahoo.security.tls.TlsContext; @@ -8,15 +8,10 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.utils.URIBuilder; -import org.apache.http.config.Registry; -import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.HttpClientConnectionManager; -import org.apache.http.conn.socket.ConnectionSocketFactory; -import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.conn.BasicHttpClientConnectionManager; import org.apache.http.protocol.HttpContext; import javax.net.ssl.SSLParameters; @@ -39,33 +34,19 @@ public class VespaHttpClientBuilder { private static final Logger log = Logger.getLogger(VespaHttpClientBuilder.class.getName()); public interface ConnectionManagerFactory { - HttpClientConnectionManager create(Registry<ConnectionSocketFactory> socketFactoryRegistry); + HttpClientConnectionManager create(SSLConnectionSocketFactory sslSocketFactory); } private VespaHttpClientBuilder() {} - /** - * Create a client builder with default connection manager. - */ public static HttpClientBuilder create() { return createBuilder(null); } - /** - * Create a client builder with a user specified connection manager. - */ public static HttpClientBuilder create(ConnectionManagerFactory connectionManagerFactory) { return createBuilder(connectionManagerFactory); } - /** - * Creates a client builder with a {@link BasicHttpClientConnectionManager} configured. - * This connection manager uses a single connection for all requests. See Javadoc for details. - */ - public static HttpClientBuilder createWithBasicConnectionManager() { - return createBuilder(BasicHttpClientConnectionManager::new); - } - private static HttpClientBuilder createBuilder(ConnectionManagerFactory connectionManagerFactory) { var builder = HttpClientBuilder.create(); addSslSocketFactory(builder, connectionManagerFactory); @@ -79,7 +60,7 @@ public class VespaHttpClientBuilder { log.log(Level.FINE, "Adding ssl socket factory to client"); SSLConnectionSocketFactory socketFactory = createSslSocketFactory(tlsContext); if (connectionManagerFactory != null) { - builder.setConnectionManager(connectionManagerFactory.create(createRegistry(socketFactory))); + builder.setConnectionManager(connectionManagerFactory.create(socketFactory)); } else { builder.setSSLSocketFactory(socketFactory); } @@ -99,13 +80,6 @@ public class VespaHttpClientBuilder { return new SSLConnectionSocketFactory(tlsContext.context(), parameters.getProtocols(), parameters.getCipherSuites(), new NoopHostnameVerifier()); } - private static Registry<ConnectionSocketFactory> createRegistry(SSLConnectionSocketFactory sslSocketFactory) { - return RegistryBuilder.<ConnectionSocketFactory>create() - .register("https", sslSocketFactory) - .register("http", PlainConnectionSocketFactory.getSocketFactory()) - .build(); - } - static class HttpToHttpsRewritingRequestInterceptor implements HttpRequestInterceptor { @Override public void process(HttpRequest request, HttpContext context) { diff --git a/http-utils/src/test/java/ai/vespa/util/http/VespaHttpClientBuilderTest.java b/security-utils/src/test/java/com/yahoo/security/tls/https/VespaHttpClientBuilderTest.java index 7ffd0e459b0..10b8458359c 100644 --- a/http-utils/src/test/java/ai/vespa/util/http/VespaHttpClientBuilderTest.java +++ b/security-utils/src/test/java/com/yahoo/security/tls/https/VespaHttpClientBuilderTest.java @@ -1,7 +1,7 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package ai.vespa.util.http; +package com.yahoo.security.tls.https; -import ai.vespa.util.http.VespaHttpClientBuilder.HttpToHttpsRewritingRequestInterceptor; +import com.yahoo.security.tls.https.VespaHttpClientBuilder.HttpToHttpsRewritingRequestInterceptor; import org.apache.http.client.methods.HttpGet; import org.apache.http.protocol.BasicHttpContext; import org.junit.Test; |