diff --git a/src/main/java/io/orkes/conductor/client/ApiClient.java b/src/main/java/io/orkes/conductor/client/ApiClient.java index 29820ac4..7026da5e 100644 --- a/src/main/java/io/orkes/conductor/client/ApiClient.java +++ b/src/main/java/io/orkes/conductor/client/ApiClient.java @@ -82,10 +82,6 @@ public class ApiClient { private String keyId; private String keySecret; - private SecretsManager secretsManager; - private String ssmKeyPath; - private String ssmSecretPath; - private String grpcHost = "localhost"; private int grpcPort = 8090; @@ -118,10 +114,9 @@ public ApiClient(String basePath) { public ApiClient(String basePath, SecretsManager secretsManager, String keyPath, String secretPath) { this(basePath); - this.secretsManager = secretsManager; - this.ssmKeyPath = keyPath; - this.ssmSecretPath = secretPath; try { + keyId = secretsManager.getSecret(keyPath); + keySecret = secretsManager.getSecret(secretPath); getToken(); } catch (Throwable t) { LOGGER.error(t.getMessage(), t); @@ -462,14 +457,6 @@ public ApiClient setWriteTimeout(int writeTimeout) { return this; } - public SecretsManager getSecretsManager() { - return secretsManager; - } - - public void setSecretsManager(SecretsManager secretsManager) { - this.secretsManager = secretsManager; - } - /** * Format the given parameter object into string. * @@ -1263,6 +1250,9 @@ private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityExcepti public String getToken() { try { + if (!useSecurity()) { + return null; + } return tokenCache.get(TOKEN_CACHE_KEY, () -> refreshToken()); } catch (ExecutionException e) { return null; @@ -1270,10 +1260,6 @@ public String getToken() { } private String refreshToken() { - if (secretsManager != null) { - keyId = secretsManager.getSecret(this.ssmKeyPath); - keySecret = secretsManager.getSecret(this.ssmSecretPath); - } if (this.keyId == null || this.keySecret == null) { throw new RuntimeException("KeyId and KeySecret must be set in order to get an authentication token"); }