From a49e0a3d7843522726487ca9535d085a98d0e937 Mon Sep 17 00:00:00 2001 From: Karan Mehta Date: Thu, 14 Jun 2018 21:00:12 -0700 Subject: [PATCH] CALCITE-2285 Support client cert keystore for Avatica Client (Addendum, Remove unused code) --- .../avatica/remote/AvaticaCommonsHttpClientImpl.java | 9 --------- .../AvaticaCommonsHttpClientImplSocketFactoryTest.java | 7 ------- 2 files changed, 16 deletions(-) diff --git a/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java b/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java index e7e6aa0436..0981efe9c3 100644 --- a/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java +++ b/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java @@ -88,7 +88,6 @@ public class AvaticaCommonsHttpClientImpl implements AvaticaHttpClient, protected CredentialsProvider credentialsProvider = null; protected Lookup authRegistry = null; - protected boolean configureHttpsSocket = false; protected File truststore = null; protected File keystore = null; protected String truststorePassword = null; @@ -134,11 +133,6 @@ protected Registry configureSocketFactories() { } protected void configureHttpsRegistry(RegistryBuilder registryBuilder) { - if (!configureHttpsSocket) { - LOG.debug("HTTPS Socket not being configured because no truststore/keystore provided"); - return; - } - try { SSLContext sslContext = getSSLContext(); final HostnameVerifier verifier = getHostnameVerifier(hostnameVerification); @@ -284,7 +278,6 @@ private static URI toURI(URL url) throws RuntimeException { "Truststore is must be an existing, regular file: " + truststore); } this.truststorePassword = Objects.requireNonNull(password); - configureHttpsSocket = true; initializeClient(); } @@ -296,13 +289,11 @@ private static URI toURI(URL url) throws RuntimeException { } this.keystorePassword = Objects.requireNonNull(keystorepassword); this.keyPassword = Objects.requireNonNull(keypassword); - configureHttpsSocket = true; initializeClient(); } @Override public void setHostnameVerification(HostnameVerification verification) { this.hostnameVerification = Objects.requireNonNull(verification); - configureHttpsSocket = true; initializeClient(); } } diff --git a/core/src/test/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImplSocketFactoryTest.java b/core/src/test/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImplSocketFactoryTest.java index a75222a15f..b05b8dcf1b 100644 --- a/core/src/test/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImplSocketFactoryTest.java +++ b/core/src/test/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImplSocketFactoryTest.java @@ -26,7 +26,6 @@ import java.io.File; import java.net.URL; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; @@ -51,8 +50,6 @@ public class AvaticaCommonsHttpClientImplSocketFactoryTest { @Test public void testPlainSocketFactory() throws Exception { configureHttpClient(); - assertFalse("Https socket should not be configured" - + " without truststore/keystore", client.configureHttpsSocket); verifyFactoryInstance(client, HTTP_REGISTRY, PlainConnectionSocketFactory.class); verifyFactoryInstance(client, HTTPS_REGISTRY, null); verify(client, times(0)).loadTrustStore(any(SSLContextBuilder.class)); @@ -62,8 +59,6 @@ public class AvaticaCommonsHttpClientImplSocketFactoryTest { @Test public void testTrustStoreLoadedInFactory() throws Exception { configureHttpsClient(); client.setTrustStore(storeFile, password); - assertTrue("Https socket should be configured" - + " with truststore", client.configureHttpsSocket); verifyFactoryInstance(client, HTTP_REGISTRY, null); verifyFactoryInstance(client, HTTPS_REGISTRY, SSLConnectionSocketFactory.class); verify(client, times(1)).configureSocketFactories(); @@ -74,8 +69,6 @@ public class AvaticaCommonsHttpClientImplSocketFactoryTest { @Test public void testKeyStoreLoadedInFactory() throws Exception { configureHttpsClient(); client.setKeyStore(storeFile, password, password); - assertTrue("Https socket should be configured" - + " with keystore", client.configureHttpsSocket); verifyFactoryInstance(client, HTTP_REGISTRY, null); verifyFactoryInstance(client, HTTPS_REGISTRY, SSLConnectionSocketFactory.class); verify(client, times(1)).configureSocketFactories();