From e269f9ca554555b022c65b00dd9020709843feec Mon Sep 17 00:00:00 2001 From: Yong Sheng Tan Date: Mon, 21 Oct 2019 18:18:23 +0800 Subject: [PATCH] Removed parallel auth from certificate-based auth Minor upgrades of libraries --- pom.xml | 12 ++-- src/main/java/authentication/SymBotAuth.java | 59 ++------------------ 2 files changed, 11 insertions(+), 60 deletions(-) diff --git a/pom.xml b/pom.xml index 40151bde4..54ff54946 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.symphony.platformsolutions symphony-api-client-java - 1.0.43-SNAPSHOT + 1.0.44 Symphony API Client https://github.com/SymphonyPlatformSolutions/symphony-api-client-java Symphony API Client provided by Symphony Platform Solutions team @@ -34,10 +34,10 @@ UTF-8 0.9.1 - 1.12 + 1.13 2.6 - 2.29 - 1.7.26 + 2.29.1 + 1.7.28 @@ -147,7 +147,7 @@ com.fasterxml.jackson.core jackson-databind - 2.9.10 + 2.10.0 org.slf4j @@ -224,7 +224,7 @@ com.github.tomakehurst wiremock-jre8 - 2.23.2 + 2.25.1 test diff --git a/src/main/java/authentication/SymBotAuth.java b/src/main/java/authentication/SymBotAuth.java index 8bc213b31..3d15606d0 100755 --- a/src/main/java/authentication/SymBotAuth.java +++ b/src/main/java/authentication/SymBotAuth.java @@ -4,7 +4,7 @@ import clients.symphony.api.constants.CommonConstants; import configuration.SymConfig; import exceptions.AuthenticationException; -import java.util.concurrent.*; +import java.util.concurrent.TimeUnit; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.MediaType; @@ -32,16 +32,8 @@ public SymBotAuth(SymConfig config) { this.sessionAuthClient = client; this.kmAuthClient = client; - - ClientConfig clientConfig = HttpClientBuilderHelper.getPodClientConfig(config); - if (clientConfig != null) { - this.sessionAuthClient = clientBuilder.withConfig(clientConfig).build(); - } - - ClientConfig kmClientConfig = HttpClientBuilderHelper.getKMClientConfig(config); - if (kmClientConfig != null) { - this.kmAuthClient = clientBuilder.withConfig(kmClientConfig).build(); - } + this.sessionAuthClient = clientBuilder.withConfig(HttpClientBuilderHelper.getPodClientConfig(config)).build(); + this.kmAuthClient = clientBuilder.withConfig(HttpClientBuilderHelper.getKMClientConfig(config)).build(); } public SymBotAuth(final SymConfig inputConfig, @@ -70,49 +62,8 @@ public SymBotAuth(final SymConfig inputConfig, @Override public void authenticate() throws AuthenticationException { if (lastAuthTime == 0 || System.currentTimeMillis() - lastAuthTime > AuthEndpointConstants.WAIT_TIME) { - ExecutorService executor = Executors.newFixedThreadPool(2); - Future sessionAuthFuture = executor.submit(() -> { - try { - sessionAuthenticate(); - return null; - } catch (AuthenticationException e) { - return e; - } - }); - Future kmAuthFuture = executor.submit(() -> { - try { - kmAuthenticate(); - return null; - } catch (AuthenticationException e) { - return e; - } - }); - executor.shutdown(); - - try { - int connectionTimeout = config.getConnectionTimeout(); - if (connectionTimeout == 0) { - connectionTimeout = 35000; - } - executor.awaitTermination(connectionTimeout, TimeUnit.MILLISECONDS); - executor.shutdownNow(); - if (!executor.isTerminated()) { - throw new AuthenticationException(new Exception("Timeout")); - } - } catch (InterruptedException e) { - throw new RuntimeException("Termination Interrupted"); - } - - try { - if (sessionAuthFuture.get() != null) { - throw sessionAuthFuture.get(); - } - if (kmAuthFuture.get() != null) { - throw kmAuthFuture.get(); - } - } catch (InterruptedException | ExecutionException e) { - logger.error("Interrupted Exception"); - } + sessionAuthenticate(); + kmAuthenticate(); lastAuthTime = System.currentTimeMillis(); } else {