aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2020-06-17 16:04:51 +0200
committerpwielebs <piotr.wielebski@nokia.com>2020-06-18 09:34:11 +0200
commit81d42dfeec4b638c7b7d8f201c6f677477f8226f (patch)
treef0679962afc004badbcb388f96b8cff19edf7bc2
parent8464ed158369bbb5b047a63ddea3b483f6a79454 (diff)
Add validation for OUTPUT_TYPE parameter (2)
Issue-ID: AAF-1152 Signed-off-by: pwielebs <piotr.wielebski@nokia.com> Change-Id: I026d7979dcb35ccd3c953217b2eccf376cfaf85b
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProvider.java19
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java3
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java3
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)