diff options
author | 2020-06-09 15:37:46 +0200 | |
---|---|---|
committer | 2020-06-16 14:37:56 +0200 | |
commit | b288b7ab24f33af72e9c0fedecbb9979d1b4afc7 (patch) | |
tree | 1344fef298151973e7d2626f79571f63d6a7cca2 /certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java | |
parent | 1a890623eff92322a033943ba8e46d2e33b9c2c5 (diff) |
Refactor flow of cert files generation, based on OUTPUT_TYPE parameter
-Add artifacts creator provider (strategy pattern)
-Refactor KeystoreTruststoreCreator
-Add new exception: CertOutputTypeNotSupported
-Change Unit tests
Issue-ID: AAF-1152
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: If2b2fa50d551e72f19319d781bfb6079d07c7b83
Diffstat (limited to 'certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java')
-rw-r--r-- | certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java index 1b5b8ee3..27e8a4f0 100644 --- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java +++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java @@ -23,8 +23,7 @@ import org.onap.aaf.certservice.client.api.ExitableException; import org.onap.aaf.certservice.client.certification.CsrFactory; import org.onap.aaf.certservice.client.certification.KeyPairFactory; import org.onap.aaf.certservice.client.certification.PrivateKeyToPemEncoder; -import org.onap.aaf.certservice.client.certification.conversion.KeystoreTruststoreCreator; -import org.onap.aaf.certservice.client.certification.conversion.KeystoreTruststoreCreatorFactory; +import org.onap.aaf.certservice.client.certification.conversion.ArtifactsCreatorProvider; import org.onap.aaf.certservice.client.common.Base64Encoder; import org.onap.aaf.certservice.client.configuration.EnvsForClient; import org.onap.aaf.certservice.client.configuration.EnvsForCsr; @@ -78,12 +77,15 @@ public class CertServiceClient { base64Encoder.encode(csrFactory.createCsrInPem(keyPair)), base64Encoder.encode(pkEncoder.encodePrivateKeyToPem(keyPair.getPrivate()))); - KeystoreTruststoreCreator filesCreator = new KeystoreTruststoreCreatorFactory( - clientConfiguration.getCertsOutputPath()).create(); - filesCreator.createKeystore(certServiceData.getCertificateChain(), keyPair.getPrivate()); - filesCreator.createTruststore(certServiceData.getTrustedCertificates()); + ArtifactsCreatorProvider + .getCreator(clientConfiguration.getOutputType(), + clientConfiguration.getCertsOutputPath()) + .create(certServiceData.getCertificateChain(), + certServiceData.getTrustedCertificates(), + keyPair.getPrivate()); + } catch (ExitableException e) { - LOGGER.error("Cert Service Client fail in execution: ", e); + LOGGER.error("Cert Service Client fails in execution: ", e); appExitHandler.exit(e.applicationExitStatus()); } appExitHandler.exit(SUCCESS); |