diff options
author | Remigiusz Janeczek <remigiusz.janeczek@nokia.com> | 2020-02-28 12:27:12 +0100 |
---|---|---|
committer | Remigiusz Janeczek <remigiusz.janeczek@nokia.com> | 2020-03-04 14:20:55 +0100 |
commit | d18af899b0bb9813c3e1bc3111171787e85ccfc4 (patch) | |
tree | 2580993897a464b0a8749d7473f67dc37171227a /certServiceClient/src/main | |
parent | 1d535a1b38e26c7035db2bde7405261d97bf7261 (diff) |
Improve paths validation and creation in certServiceClient, improve coverage
Add tests for path validation
Add tests for CsrConfigurationFactory
Ensure path from env can end with "/"
Ensure path built in file creator is not dependent on representation of root path
Issue-ID: AAF-996
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: I3d6a7f534d49ff64177917989727a7330e3f6869
Diffstat (limited to 'certServiceClient/src/main')
2 files changed, 7 insertions, 5 deletions
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java index 60121b03..d8c41bfd 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java @@ -21,6 +21,8 @@ package org.onap.aaf.certservice.client.certification.conversion; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Path; + import org.onap.aaf.certservice.client.certification.exception.PemToPKCS12ConverterException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,10 +41,10 @@ class PKCS12FilesCreator { PKCS12FilesCreator(String path) { - keystoreJksPath = path + KEYSTORE_JKS; - keystorePassPath = path + KEYSTORE_PASS; - truststoreJksPath = path + TRUSTSTORE_JKS; - truststorePassPath = path + TRUSTSTORE_PASS; + keystoreJksPath = Path.of(path, KEYSTORE_JKS).toString(); + keystorePassPath = Path.of(path, KEYSTORE_PASS).toString(); + truststoreJksPath = Path.of(path, TRUSTSTORE_JKS).toString(); + truststorePassPath = Path.of(path, TRUSTSTORE_PASS).toString(); } void saveKeystoreData(byte[] keystoreData, String keystorePassword) throws PemToPKCS12ConverterException { diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvValidationUtils.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvValidationUtils.java index e65d688d..b0405274 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvValidationUtils.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvValidationUtils.java @@ -27,7 +27,7 @@ public final class EnvValidationUtils { private EnvValidationUtils() {} public static Boolean isPathValid(String path) { - return path.matches("^/|(/[a-zA-Z0-9_-]+)+$"); + return path.matches("^/|(/[a-zA-Z0-9_-]+)+/?$"); } public static Boolean isAlphaNumeric(String caName) { |