diff options
Diffstat (limited to 'certServiceClient/src/main/java/org')
3 files changed, 18 insertions, 7 deletions
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProvider.java index ac1eda1a..4ed86a4d 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProvider.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProvider.java @@ -19,8 +19,7 @@ package org.onap.aaf.certservice.client.certification.conversion; public enum ArtifactsCreatorProvider { - - P12 { + P12("P12") { @Override ArtifactsCreator create(String outputPath) { return new PKCS12ArtifactsCreator( @@ -29,21 +28,31 @@ public enum ArtifactsCreatorProvider { new PemToPKCS12Converter()); } }, - JKS { + JKS("JKS") { @Override ArtifactsCreator create(String outputPath) { return null; } }, - PEM { + PEM("PEM") { @Override ArtifactsCreator create(String outputPath) { return null; } }; + private final String name; + + ArtifactsCreatorProvider(String name) { + this.name = name; + } + public static ArtifactsCreator getCreator(String outputType, String outputPath) { - return valueOf(outputType).create(outputPath); + return valueOf(outputType).create(outputPath); + } + + public String getName() { + return name; } abstract ArtifactsCreator create(String outputPath); diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java index b7def803..70faa6b4 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java @@ -59,7 +59,8 @@ public abstract class AbstractConfigurationFactory<T extends ConfigurationModel> public boolean isOutputTypeValid(String outputType) { return Arrays.stream(ArtifactsCreatorProvider.values()) - .anyMatch(artifactsCreatorProvider -> artifactsCreatorProvider.toString().equals(outputType)); + .map(ArtifactsCreatorProvider::getName) + .anyMatch(name -> name.equals(outputType)); } private boolean isPortNumberPresent(String stringToCheck) { 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 d813233a..d8498d84 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 @@ -43,7 +43,6 @@ public class ClientConfigurationFactory extends AbstractConfigurationFactory<Cli ClientConfiguration configuration = new ClientConfiguration(); - Optional<String> outputType = envsForClient.getOutputType(); envsForClient.getUrlToCertService() .map(configuration::setUrlToCertService); @@ -61,6 +60,8 @@ public class ClientConfigurationFactory extends AbstractConfigurationFactory<Cli .map(configuration::setCaName) .orElseThrow(() -> new ClientConfigurationException(ClientConfigurationEnvs.CA_NAME + " is invalid.")); + Optional<String> outputType = envsForClient.getOutputType(); + if (outputType.isPresent()) { outputType.filter(this::isOutputTypeValid) .map(configuration::setOutputType) |