diff options
author | 2020-06-09 09:58:31 +0200 | |
---|---|---|
committer | 2020-06-10 15:40:43 +0200 | |
commit | 0022ba11a0dd13f5a4ee030913cd37d1a3dcb97b (patch) | |
tree | 5ba24498a06cc09cc52a18894fd1203dcbb364f8 /certServiceClient/src/main/java/org/onap/aaf/certservice | |
parent | 892eb3fb564c2d7c50e2ecb0494bbc599f5f7ae4 (diff) |
Add output type env to certservice client configuration
- add new enum value OUTPUT_TYPE
- add reading new OUTPUT_TYPE env in EnvsForClient
- add handling output type to ClientConfigurationFactory
Issue-ID: AAF-1152
Signed-off-by: Piotr Marcinkiewicz <piotr.marcinkiewicz@nokia.com>
Change-Id: I60269c3befff90f685e16a8e7255674df6ca9368
Diffstat (limited to 'certServiceClient/src/main/java/org/onap/aaf/certservice')
4 files changed, 24 insertions, 3 deletions
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java index 779e65bb..f8a0e91a 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java @@ -24,5 +24,6 @@ public enum ClientConfigurationEnvs { REQUEST_URL, REQUEST_TIMEOUT, OUTPUT_PATH, - CA_NAME + CA_NAME, + OUTPUT_TYPE } diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java index 59fd5efc..dedd4d6b 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java @@ -40,6 +40,10 @@ public class EnvsForClient { return readEnv(ClientConfigurationEnvs.CA_NAME); } + public Optional<String> getOutputType() { + return readEnv(ClientConfigurationEnvs.OUTPUT_TYPE); + } + private Optional<String> readEnv(ClientConfigurationEnvs envName) { return envProvider.readEnvVariable(envName.toString()); } diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java index a03ded6c..793799e2 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java @@ -57,6 +57,9 @@ public class ClientConfigurationFactory extends AbstractConfigurationFactory<Cli .map(configuration::setCaName) .orElseThrow(() -> new ClientConfigurationException(ClientConfigurationEnvs.CA_NAME + " is invalid.")); + envsForClient.getOutputType() + .map(configuration::setOutputType); + LOGGER.info("Successful validation of Client configuration. Configuration data: {}", configuration.toString()); return configuration; diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java index 2ac481dc..78fa1b4b 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java @@ -26,16 +26,19 @@ public class ClientConfiguration implements ConfigurationModel { private static final Integer DEFAULT_TIMEOUT_MS = 30000; private static final String DEFAULT_REQUEST_URL = "https://aaf-cert-service:8443/v1/certificate/"; + private static final String DEFAULT_OUTPUT_TYPE = "P12"; private String urlToCertService; private Integer requestTimeout; private String certsOutputPath; private String caName; + private String outputType; public ClientConfiguration() { urlToCertService = DEFAULT_REQUEST_URL; requestTimeout = DEFAULT_TIMEOUT_MS; + outputType = DEFAULT_OUTPUT_TYPE; } @@ -75,12 +78,22 @@ public class ClientConfiguration implements ConfigurationModel { return this; } + public String getOutputType() { + return outputType; + } + + public ClientConfiguration setOutputType(String outputType) { + this.outputType = outputType; + return this; + } + @Override public String toString() { - return String.format("%s: %s, %s: %s, %s: %s, %s: %s", + return String.format("%s: %s, %s: %s, %s: %s, %s: %s, %s: %s", ClientConfigurationEnvs.REQUEST_URL, urlToCertService, ClientConfigurationEnvs.REQUEST_TIMEOUT, requestTimeout, ClientConfigurationEnvs.OUTPUT_PATH, certsOutputPath, - ClientConfigurationEnvs.CA_NAME, caName); + ClientConfigurationEnvs.CA_NAME, caName, + ClientConfigurationEnvs.OUTPUT_TYPE, outputType); } } |