aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2020-08-21 12:49:42 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2020-08-21 13:06:35 +0200
commit0aaa5b219c1b9ae8073d8c8829c8143354c39c5f (patch)
tree82dece0ddf2bb33f2a8564c2a81c42ccdbd8e1e6
parentfe4c4957e2dd09ab09cd0486424416470c9d1730 (diff)
Remove code
Issue-ID: OOM-2526 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com> Change-Id: Ie81cfa9c4f8aaecd18fb567526aa61d391575741
-rw-r--r--Makefile34
-rw-r--r--README.md93
-rw-r--r--certService/Dockerfile15
-rw-r--r--certService/LICENSE.txt38
-rw-r--r--certService/README.md102
-rw-r--r--certService/pom.xml199
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/CertServiceApplication.java37
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/api/CertificationController.java96
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/api/ReadinessController.java61
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/api/ReloadConfigController.java64
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdvice.java100
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdvice.java43
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/api/configuration/OpenApiConfig.java44
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CertificateFactoryProvider.java42
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CertificationData.java128
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java70
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CertificationProvider.java78
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java113
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java49
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/Pkcs10CertificationRequestFactory.java45
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/RsaContentSignerBuilder.java46
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/X509CertificateBuilder.java56
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpClientConfig.java50
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java87
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoader.java64
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoadingException.java32
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProvider.java43
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Authentication.java60
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CaMode.java35
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CmpServers.java37
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Cmpv2Server.java98
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidator.java68
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2Url.java41
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidator.java55
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolation.java43
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolation.java49
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/UrlServerViolation.java25
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exception/Cmpv2ClientAdapterException.java28
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exception/Cmpv2ServerNotFoundException.java27
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exception/CsrDecryptionException.java31
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exception/DecryptionException.java33
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exception/ErrorResponseModel.java36
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exception/KeyDecryptionException.java31
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/model/CertificationModel.java44
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/model/CsrModel.java170
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/api/CmpClient.java74
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/exceptions/CmpClientException.java50
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/exceptions/PkiErrorException.java47
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java61
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Rdn.java157
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java242
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpMessageBuilder.java57
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpMessageHelper.java246
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseHelper.java335
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseValidationHelper.java241
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpUtil.java153
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/Cmpv2HttpClient.java83
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CreateCertRequest.java128
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/model/Cmpv2CertificationModel.java44
-rw-r--r--certService/src/main/resources/application.properties22
-rw-r--r--certService/src/main/resources/log4j2.xml59
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/CertServiceApplicationTests.java34
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/api/CertificationControllerTest.java147
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/api/ReadinessControllerTest.java59
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/api/ReloadConfigControllerTest.java77
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdviceTest.java134
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdviceTest.java56
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/CertificationModelFactoryTest.java220
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/CertificationProviderTest.java132
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/CsrModelFactoryTest.java147
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java76
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/RsaContentSignerBuilderTest.java63
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/TestData.java95
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/TestUtils.java61
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/X509CertificateBuilderTest.java69
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoaderTest.java117
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigTest.java236
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java100
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidatorTest.java213
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidatorTest.java57
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolationTest.java76
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolationTest.java56
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java185
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/cmpv2client/Cmpv2ClientTest.java288
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/cmpv2client/external/RdnTest.java96
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseHelperTest.java609
-rw-r--r--certService/src/test/resources/ReturnedFailurePKIMessageBadPassword2
-rw-r--r--certService/src/test/resources/ReturnedSuccessPKIMessageWithCertificateFilebin2759 -> 0 bytes
-rw-r--r--certService/src/test/resources/application.properties13
-rw-r--r--certService/src/test/resources/certificateChain.firstbin1121 -> 0 bytes
-rw-r--r--certService/src/test/resources/certificateModelChain.first1
-rw-r--r--certService/src/test/resources/cmpServers.json24
-rw-r--r--certService/src/test/resources/invalidCmpServers.json19
-rw-r--r--certService/src/test/resources/privateKeybin1218 -> 0 bytes
-rw-r--r--certService/src/test/resources/publicKeybin294 -> 0 bytes
-rw-r--r--certService/src/test/resources/trustedCertificates.firstbin1207 -> 0 bytes
-rw-r--r--certService/src/test/resources/trustedCertificatesModel.first28
-rw-r--r--certService/version.properties6
-rw-r--r--certServiceClient/Dockerfile13
-rw-r--r--certServiceClient/README.md54
-rw-r--r--certServiceClient/pom.xml185
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/AppExitHandler.java34
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java93
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/MainApp.java28
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitStatus.java51
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitableException.java32
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java66
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/CsrFactory.java153
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/EncryptionAlgorithmConstants.java38
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/KeyPairFactory.java56
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoder.java50
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreator.java30
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreator.java92
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java37
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java44
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreator.java63
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemConverter.java138
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGenerator.java52
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/StoreEntryOperation.java34
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/CertFileWriterException.java35
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/CsrGenerationException.java35
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/KeyPairGenerationException.java36
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PemConversionException.java40
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PkEncodingException.java35
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java62
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/common/Base64Encoder.java28
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java29
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/CsrConfigurationEnvs.java31
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java38
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java51
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForCsr.java59
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForTls.java47
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/TlsConfigurationEnvs.java28
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java36
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java36
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationException.java36
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java77
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java76
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactory.java77
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactory.java85
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java99
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ConfigurationModel.java24
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java111
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/CloseableHttpsClientProvider.java51
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java111
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java41
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java37
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/CertServiceResponse.java44
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/ErrorCertServiceResponse.java35
-rw-r--r--certServiceClient/src/main/resources/log4j2.xml35
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/CerServiceRequestTestData.java89
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java49
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProviderTest.java73
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java56
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/KeyPairFactoryTest.java53
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java66
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorTest.java125
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreatorTest.java58
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemConverterTest.java206
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGeneratorTest.java33
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java76
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java65
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java201
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java133
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java48
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java93
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactoryTest.java155
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactoryTest.java186
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactoryTest.java197
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/httpclient/HttpClientTest.java144
-rw-r--r--certServiceClient/src/test/resources/cert1.pem21
-rw-r--r--certServiceClient/src/test/resources/cert2.pem22
-rw-r--r--certServiceClient/src/test/resources/correctResponse10
-rw-r--r--certServiceClient/src/test/resources/expectedFirstElementOfCertificateChain21
-rw-r--r--certServiceClient/src/test/resources/expectedFirstElementOfTrustedCertificates22
-rw-r--r--certServiceClient/src/test/resources/expectedKeystore.jksbin3823 -> 0 bytes
-rw-r--r--certServiceClient/src/test/resources/expectedTruststore.jksbin2306 -> 0 bytes
-rw-r--r--certServiceClient/src/test/resources/keystore.jksbin5581 -> 0 bytes
-rw-r--r--certServiceClient/src/test/resources/missingPkResponse7
-rw-r--r--certServiceClient/src/test/resources/privateKeybin1217 -> 0 bytes
-rw-r--r--certServiceClient/src/test/resources/rsaPrivateKeyPem28
-rw-r--r--certServiceClient/src/test/resources/testCsr1
-rw-r--r--certServiceClient/src/test/resources/testPk1
-rw-r--r--certServiceClient/src/test/resources/truststore.jksbin1722 -> 0 bytes
-rw-r--r--certServiceClient/version.properties6
-rw-r--r--certs/Makefile111
-rw-r--r--certs/certServiceClient-keystore.jksbin4066 -> 0 bytes
-rw-r--r--certs/certServiceServer-keystore.jksbin4111 -> 0 bytes
-rw-r--r--certs/certServiceServer-keystore.p12bin4683 -> 0 bytes
-rw-r--r--certs/root.crt33
-rw-r--r--certs/truststore.jksbin1730 -> 0 bytes
-rw-r--r--compose-resources/client-configuration.env19
-rw-r--r--compose-resources/cmpServers.json24
-rwxr-xr-xcompose-resources/ejbca-configuration.sh19
-rw-r--r--docker-compose.yml46
-rw-r--r--docs/index.rst9
-rw-r--r--pom.xml238
197 files changed, 7 insertions, 13880 deletions
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 778b94d7..00000000
--- a/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-all: build start-backend run-client stop-backend
-start-with-client: start-backend run-client
-.PHONY: build
-
-build:
- @echo "##### Build Cert Service images locally #####"
- mvn clean install -P docker
- @echo "##### DONE #####"
-
-start-backend:
- @echo "##### Start Cert Service #####"
- docker-compose up -d
- @echo "## Configure ejbca ##"
- docker exec aafcert-ejbca /opt/primekey/scripts/ejbca-configuration.sh
- @echo "##### DONE #####"
-
-run-client:
- @echo "##### Create Cert Service Client volume folder: `pwd`/compose-resources/client-volume/ #####"
- mkdir -p `pwd`/compose-resources/client-volume/
- @echo "##### Start Cert Service Client #####"
- docker run \
- --rm \
- --name aafcert-client \
- --env-file ./compose-resources/client-configuration.env \
- --network certservice_certservice \
- --mount type=bind,src=`pwd`/compose-resources/client-volume/,dst=/var/certs \
- --volume `pwd`/certs/truststore.jks:/etc/onap/aaf/certservice/certs/truststore.jks \
- --volume `pwd`/certs/certServiceClient-keystore.jks:/etc/onap/aaf/certservice/certs/certServiceClient-keystore.jks \
- onap/org.onap.aaf.certservice.aaf-certservice-client:latest
-
-stop-backend:
- @echo "##### Stop Cert Service #####"
- docker-compose down
- @echo "##### DONE #####"
diff --git a/README.md b/README.md
index c5220308..ab8d7482 100644
--- a/README.md
+++ b/README.md
@@ -1,96 +1,5 @@
-# Cert service
+
21-08-2020
THIS PROJECT WAS ABANDON IN RELEASE Guilin!
New version of CertService is developed begin release Guilin in https://gerrit.onap.org/r/admin/repos/oom/platform/cert-service
repository.
-
-### General description
-
-More information about the project and all its functionalities you can find under the wiki page:
- ```
- https://wiki.onap.org/display/DW/AAF+Certification+Service
- ```
-
-Project consists of two submodules:
-1. aaf-certservice-api
-2. aaf-certservice-client
-
-Detailed information about submodules can be found in ```README.md``` in their directories.
-
-### Project building
-```
-mvn clean package
-```
-
-### Install the packages into the local repository
-```
-mvn clean install
-```
-
-### Building Docker images and install packages into local repository
-```
-mvn clean install -P docker
-or
-make build
-```
-
-### Generating certificates
-There are example certificates already generated in certs/ directory.
-In order to generate new certificates, first remove existing ones.
-Then execute following command from certs(!) directory:
-```
- make
-```
-
-### Running Docker containers from docker-compose with EJBCA
-Docker-compose uses a local image of certservice-api and make run-client uses a local image of certservice-client
-Build docker images locally before running docker compose command.
-```
-1. Build local images
-make build
-2. Start Cert Service with configured EJBCA
-make start-backend
-3. Run Cert Service Client
-make run-client
-4. Stop Cert Service and EJBCA
-make stop-backend
-```
-
-### AAF CertService CSITs
-#### CSIT repository
-```
-https://gerrit.onap.org/r/admin/repos/integration/csit
-```
-
-####How to run tests locally
-1. Checkout CSIT repository
-2. Configure CSIT local environment
-3. Inside CSIT directory execute
-```
-sudo ./run-csit.sh plans/aaf/certservice
-```
-
-####Jenkins build
-https://jenkins.onap.org/view/CSIT/job/aaf-master-csit-certservice/
-
-### Sonar results
-```
-https://sonarcloud.io/dashboard?id=onap_aaf-certservice
-```
-
-### Maven artifacts
-All maven artifacts are deployed under nexus uri:
-```
-https://nexus.onap.org/content/repositories/snapshots/org/onap/aaf/certservice/
-```
-
-### Docker artifacts
-All docker images are hosted under nexus3 uri:
-```
-https://nexus3.onap.org/repository/docker.snapshot/v2/onap/org.onap.aaf.certservice.aaf-certservice-api/
-```
-
-### How to release containers
-```
-https://github.com/lfit/releng-global-jjb/blob/master/docs/jjb/lf-release-jobs.rst
-```
diff --git a/certService/Dockerfile b/certService/Dockerfile
deleted file mode 100644
index 770dab97..00000000
--- a/certService/Dockerfile
+++ /dev/null
@@ -1,15 +0,0 @@
-FROM docker.io/openjdk:11-jre-slim
-
-ARG VERSION=${version}
-
-RUN groupadd certService && useradd -g certService certService
-
-RUN apt-get update && apt-get install -y vim curl
-
-RUN chown -R certService:certService /var/log
-
-USER certService:certService
-
-COPY target/aaf-certservice-api-${VERSION}.jar ./opt/onap/aaf/certservice/aaf-certservice-api.jar
-
-ENTRYPOINT ["java","-jar","./opt/onap/aaf/certservice/aaf-certservice-api.jar"]
diff --git a/certService/LICENSE.txt b/certService/LICENSE.txt
deleted file mode 100644
index ec57efca..00000000
--- a/certService/LICENSE.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-* ============LICENSE_START==========================================
-* ===================================================================
-* Copyright (c) 2020 Nokia. All rights reserved.
-* ===================================================================
-*
-* Unless otherwise specified, all software contained herein is licensed
-* under the Apache License, Version 2.0 (the "License");
-* you may not use this software except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-*
-*
-* Unless otherwise specified, all documentation contained herein is licensed
-* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
-* you may not use this documentation except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* https://creativecommons.org/licenses/by/4.0/
-*
-* Unless required by applicable law or agreed to in writing, documentation
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* ============LICENSE_END============================================
-*
-*/
-
diff --git a/certService/README.md b/certService/README.md
deleted file mode 100644
index 645ca061..00000000
--- a/certService/README.md
+++ /dev/null
@@ -1,102 +0,0 @@
-# Cert service
-
-### General description
-More information about the project and all its functionalities you can find under the wiki page:
- ```
- https://wiki.onap.org/display/DW/AAF+Certification+Service
- ```
-
-### For developers
- * AAF Cert Service Api is a Spring Boot application
- * Code style
- Use Google code formatter in your IDE.
- For IntelliJ use [https://plugins.jetbrains.com/plugin/8527-google-java-format]
- For other IDEs use []https://github.com/google/google-java-format]
-
-### Local project configuration
- * Create directory on your system /etc/onap/aaf/certservice
- * Copy sample configuration test/resources/cmpServers.json to that directory
-
-### Running Locally
-MANDATORY SEE 'Local project configuration' section
-```
-mvn spring-boot:run
-```
-
-### Running Locally with Developer Tools
-MANDATORY SEE 'Local project configuration' section
-```
-mvn spring-boot:run -Pdev
-```
-
-### Project building
-```
-mvn clean package
-```
-
-### Building Docker image manually
-Go to the certService subfolder and execute following statement (1.0.0-SNAPSHOT is related to a current project.version parameter):
-```
-docker build --build-arg VERSION=1.0.0-SNAPSHOT -t onap/org.onap.aaf.certservice.aaf-certservice-api .
-```
-
-### Install the package into the local repository
-```
-mvn clean install
-```
-
-### Building Docker image and install the package into local repository
-```
-mvn clean install -P docker
-```
-
-### Running Docker container local
-```
-docker run -p 8080:8080 --name aaf-certservice-api --mount type=bind,source=/<absolute_path>/cmpServers.json,target=/etc/onap/aaf/certservice/cmpServers.json onap/org.onap.aaf.certservice.aaf-certservice-api
-```
-
-### Running Docker container from nexus
-```
-docker run -p 8080:8080 --name aaf-certservice-api --mount type=bind,source=/<absolute_path>/cmpServers.json,target=/etc/onap/aaf/certservice/cmpServers.json nexus3.onap.org:10001/onap/org.onap.aaf.certservice.aaf-certservice-api:1.0.0
-```
-
-### Health Check
-Browser:
-```
-http://<localhost>:8080/actuator/health
-```
-
-Curl:
-```
-curl localhost:8080/actuator/health
-```
- Should return {"status":"UP"}
-
-### Logs locally
-
-path:
-```
-var/log/onap/aaf/certservice/
-```
-### Logs in Docker container
-```
-docker exec -it aaf-certservice-api bash
-```
-
-path:
-```
-cd /var/log/onap/aaf/certservice
-```
-You should see:
-audit.log error.log debug.log
-
-### RestAPI
-API is described by Swagger ( OpenAPI 3.0 ) on endpoint /docs
-( endpoint is defined in properties as springdoc.swagger-ui.path )
-```
-http://localchost:8080/docs
-```
-
-### OpenAPI
-during project building yaml file with openAPI 3.0 documentation is generated in target directory with name api-docs.yaml
-file OpenAPI.yaml located in certService directory must be update be hand if needed
diff --git a/certService/pom.xml b/certService/pom.xml
deleted file mode 100644
index 9febd167..00000000
--- a/certService/pom.xml
+++ /dev/null
@@ -1,199 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ================================================================================
- Copyright (c) 2020 Nokia. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License"); you may not
- use this file except in compliance with the License. You may obtain a copy
- of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
- by applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
- OF ANY KIND, either express or implied. See the License for the specific
- language governing permissions and limitations under the License.
- ============LICENSE_END=========================================================
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.aaf.certservice</groupId>
- <artifactId>aaf-certservice</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
- <artifactId>aaf-certservice-api</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- <name>aaf-certservice-api</name>
- <description>AAF Certification Service Api</description>
- <packaging>jar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-log4j2</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-ui</artifactId>
- </dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcpkix-jdk15on</artifactId>
- </dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk15on</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-config</artifactId>
- <version>${spring-cloud-starter-config.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>dev</id>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-devtools</artifactId>
- <optional>true</optional>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>docker-staging</id>
- <properties>
- <docker.tag>${project.version}-STAGING-${maven.build.timestamp}</docker.tag>
- <docker.latest.tag>${project.version}-STAGING-latest</docker.latest.tag>
- </properties>
- </profile>
-
- <profile>
- <id>docker</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <properties>
- <os.detected.name>linux</os.detected.name>
- <os.detected.arch>x86_64</os.detected.arch>
- <os.detected.classifier>${os.detected.name}-${os.detected.arch}</os.detected.classifier>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>${docker-maven-plugin.version}</version>
- <executions>
- <execution>
- <id>docker-build-image</id>
- <phase>package</phase>
- <goals>
- <goal>build</goal>
- </goals>
- </execution>
- <execution>
- <id>docker-push-image</id>
- <phase>deploy</phase>
- <goals>
- <goal>push</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <skipPush>${skipDockerPush}</skipPush>
- <verbose>true</verbose>
- <imagePullPolicy>IfNotPresent</imagePullPolicy>
- <images>
- <image>
- <alias>${project.artifactId}</alias>
- <name>${docker-image.namespace}/${docker-image.name}:${docker-image.tag.latest}
- </name>
- <registry>${docker-image.registry}</registry>
- <build>
- <dockerFileDir>${project.basedir}</dockerFileDir>
- <tags>
- <tag>${project.version}-${maven.build.timestamp}Z</tag>
- </tags>
- </build>
- </image>
- </images>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
-</project>
diff --git a/certService/src/main/java/org/onap/aaf/certservice/CertServiceApplication.java b/certService/src/main/java/org/onap/aaf/certservice/CertServiceApplication.java
deleted file mode 100644
index 11478965..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/CertServiceApplication.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.PropertySource;
-
-@SpringBootApplication
-@PropertySource(value = {"classpath:application.properties"})
-public class CertServiceApplication {
-
- // We are excluding this line in Sonar due to fact that
- // Spring is handling arguments
- public static void main(String[] args) { // NOSONAR
- SpringApplication.run(CertServiceApplication.class, args);
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/CertificationController.java b/certService/src/main/java/org/onap/aaf/certservice/api/CertificationController.java
deleted file mode 100644
index c440ec34..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/api/CertificationController.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api;
-
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.media.Content;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.swagger.v3.oas.annotations.responses.ApiResponses;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.onap.aaf.certservice.certification.CertificationModelFactory;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.exception.ErrorResponseModel;
-import org.onap.aaf.certservice.certification.model.CertificationModel;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RestController;
-
-
-@RestController
-@Tag(name = "CertificationService")
-public class CertificationController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CertificationController.class);
-
- private final CertificationModelFactory certificationModelFactory;
-
- @Autowired
- CertificationController(CertificationModelFactory certificationModelFactory) {
- this.certificationModelFactory = certificationModelFactory;
- }
-
- /**
- * Request for signing certificate by given CA.
- *
- * @param caName the name of Certification Authority that will sign root certificate
- * @param encodedCsr Certificate Sign Request encoded in Base64 form
- * @param encodedPrivateKey Private key for CSR, needed for PoP, encoded in Base64 form
- * @return JSON containing trusted certificates and certificate chain
- */
- @GetMapping(value = "v1/certificate/{caName}", produces = "application/json")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Certificate successfully signed"),
- @ApiResponse(responseCode = "400", description = "Given CSR or/and PK is incorrect",
- content = @Content(schema = @Schema(implementation = ErrorResponseModel.class))),
- @ApiResponse(responseCode = "404", description = "CA not found for given name",
- content = @Content(schema = @Schema(implementation = ErrorResponseModel.class))),
- @ApiResponse(responseCode = "500", description = "Something went wrong during connectiion to CMPv2 server",
- content = @Content(schema = @Schema(implementation = ErrorResponseModel.class)))
- })
- @Operation(
- summary = "sign certificate",
- description = "Web endpoint for requesting certificate signing. Used by system components to gain certificate signed by CA.",
- tags = {"CertificationService"})
- public ResponseEntity<CertificationModel> signCertificate(
- @Parameter(description = "Name of certification authority that will sign CSR.")
- @PathVariable String caName,
- @Parameter(description = "Certificate signing request in form of PEM object encoded in Base64 (with header and footer).")
- @RequestHeader("CSR") String encodedCsr,
- @Parameter(description = "Private key in form of PEM object encoded in Base64 (with header and footer).")
- @RequestHeader("PK") String encodedPrivateKey
- ) throws DecryptionException, CmpClientException {
- caName = caName.replaceAll("[\n|\r|\t]", "_");
- LOGGER.info("Received certificate signing request for CA named: {}", caName);
- CertificationModel certificationModel = certificationModelFactory
- .createCertificationModel(encodedCsr, encodedPrivateKey, caName);
- return new ResponseEntity<>(certificationModel, HttpStatus.OK);
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/ReadinessController.java b/certService/src/main/java/org/onap/aaf/certservice/api/ReadinessController.java
deleted file mode 100644
index 9c8e1bf0..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/api/ReadinessController.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api;
-
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.swagger.v3.oas.annotations.responses.ApiResponses;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.onap.aaf.certservice.certification.configuration.CmpServersConfig;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@Tag(name = "CertificationService")
-public final class ReadinessController {
-
- private final CmpServersConfig cmpServersConfig;
-
- @Autowired
- public ReadinessController(CmpServersConfig cmpServersConfig) {
- this.cmpServersConfig = cmpServersConfig;
- }
-
- @GetMapping(value = "/ready", produces = "application/json")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Configuration is loaded and service is ready to use"),
- @ApiResponse(responseCode = "503", description = "Configuration loading failed and service is unavailable")
- })
- @Operation(
- summary = "Check if CertService application is ready",
- description = "Web endpoint for checking if service is ready to be used.",
- tags = {"CertificationService"})
- public ResponseEntity<String> checkReady() {
- if (cmpServersConfig.isReady()) {
- return new ResponseEntity<>(HttpStatus.OK);
- } else {
- return new ResponseEntity<>(HttpStatus.SERVICE_UNAVAILABLE);
- }
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/ReloadConfigController.java b/certService/src/main/java/org/onap/aaf/certservice/api/ReloadConfigController.java
deleted file mode 100644
index 14bff8dd..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/api/ReloadConfigController.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api;
-
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.media.Content;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.swagger.v3.oas.annotations.responses.ApiResponses;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.onap.aaf.certservice.certification.configuration.CmpServersConfig;
-import org.onap.aaf.certservice.certification.configuration.CmpServersConfigLoadingException;
-import org.onap.aaf.certservice.certification.exception.ErrorResponseModel;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@Tag(name = "CertificationService")
-public final class ReloadConfigController {
-
- private final CmpServersConfig cmpServersConfig;
-
- @Autowired
- public ReloadConfigController(CmpServersConfig cmpServersConfig) {
- this.cmpServersConfig = cmpServersConfig;
- }
-
- @GetMapping(value = "/reload", produces = "application/json")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200", description = "Configuration has been successfully reloaded"),
- @ApiResponse(responseCode = "500", description = "Something went wrong during configuration loading",
- content = @Content(schema = @Schema(implementation = ErrorResponseModel.class)))
- })
- @Operation(
- summary = "Reload CMPv2 servers configuration from configuration file",
- description = "Web endpoint for performing configuration reload. Used to reload configuration from file.",
- tags = {"CertificationService"})
- public ResponseEntity<String> reloadConfiguration() throws CmpServersConfigLoadingException {
- cmpServersConfig.reloadConfiguration();
- return new ResponseEntity<>(HttpStatus.OK);
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdvice.java b/certService/src/main/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdvice.java
deleted file mode 100644
index a40fea8f..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdvice.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api.advice;
-
-import org.onap.aaf.certservice.api.CertificationController;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ClientAdapterException;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException;
-import org.onap.aaf.certservice.certification.exception.CsrDecryptionException;
-import org.onap.aaf.certservice.certification.exception.ErrorResponseModel;
-import org.onap.aaf.certservice.certification.exception.KeyDecryptionException;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
-
-@RestControllerAdvice(assignableTypes = CertificationController.class)
-public final class CertificationExceptionAdvice {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CertificationExceptionAdvice.class);
-
- @ExceptionHandler(value = CsrDecryptionException.class)
- public ResponseEntity<ErrorResponseModel> handle(CsrDecryptionException exception) {
- LOGGER.error("Exception occurred during decoding certificate sign request:", exception);
- return getErrorResponseEntity(
- "Wrong certificate signing request (CSR) format",
- HttpStatus.BAD_REQUEST
- );
- }
-
- @ExceptionHandler(value = KeyDecryptionException.class)
- public ResponseEntity<ErrorResponseModel> handle(KeyDecryptionException exception) {
- LOGGER.error("Exception occurred during decoding key:", exception);
- return getErrorResponseEntity(
- "Wrong key (PK) format",
- HttpStatus.BAD_REQUEST
- );
- }
-
- @ExceptionHandler(value = Cmpv2ServerNotFoundException.class)
- public ResponseEntity<ErrorResponseModel> handle(Cmpv2ServerNotFoundException exception) {
- LOGGER.error("Exception occurred selecting CMPv2 server:", exception);
- return getErrorResponseEntity(
- "Certification authority not found for given CAName",
- HttpStatus.NOT_FOUND
- );
- }
-
- @ExceptionHandler(value = RuntimeException.class)
- public ResponseEntity<ErrorResponseModel> handle(RuntimeException exception) throws CmpClientException {
- throw new CmpClientException("Runtime exception occurred calling cmp client business logic", exception);
- }
-
- @ExceptionHandler(value = CmpClientException.class)
- public ResponseEntity<ErrorResponseModel> handle(CmpClientException exception) {
- LOGGER.error("Exception occurred calling cmp client:", exception);
- return getErrorResponseEntity(
- "Exception occurred during call to cmp client",
- HttpStatus.INTERNAL_SERVER_ERROR
- );
- }
-
- @ExceptionHandler(value = Cmpv2ClientAdapterException.class)
- public ResponseEntity<ErrorResponseModel> handle(Cmpv2ClientAdapterException exception) {
- LOGGER.error("Exception occurred parsing cmp client response:", exception);
- return getErrorResponseEntity(
- "Exception occurred parsing cmp client response",
- HttpStatus.INTERNAL_SERVER_ERROR
- );
- }
-
- private ResponseEntity<ErrorResponseModel> getErrorResponseEntity(String errorMessage, HttpStatus status) {
- ErrorResponseModel errorResponse = new ErrorResponseModel(errorMessage);
- return new ResponseEntity<>(
- errorResponse,
- status
- );
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdvice.java b/certService/src/main/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdvice.java
deleted file mode 100644
index 4a4073ff..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdvice.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api.advice;
-
-import org.onap.aaf.certservice.api.ReloadConfigController;
-import org.onap.aaf.certservice.certification.configuration.CmpServersConfigLoadingException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
-
-@RestControllerAdvice(assignableTypes = ReloadConfigController.class)
-public final class ReloadConfigExceptionAdvice {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ReloadConfigExceptionAdvice.class);
-
- @ExceptionHandler(value = CmpServersConfigLoadingException.class)
- public ResponseEntity<String> handle(CmpServersConfigLoadingException exception) {
- LOGGER.error(exception.getMessage(), exception.getCause());
- return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/configuration/OpenApiConfig.java b/certService/src/main/java/org/onap/aaf/certservice/api/configuration/OpenApiConfig.java
deleted file mode 100644
index f946598a..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/api/configuration/OpenApiConfig.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api.configuration;
-
-import io.swagger.v3.oas.models.Components;
-import io.swagger.v3.oas.models.OpenAPI;
-import io.swagger.v3.oas.models.info.Info;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class OpenApiConfig {
-
- @Bean
- public OpenAPI customOpenApi() {
- return new OpenAPI()
- .components(new Components())
- .info(
- new Info()
- .title("CertService Documentation")
- .description("Certification service API documentation")
- .version("1.0.1")
- );
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificateFactoryProvider.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificateFactoryProvider.java
deleted file mode 100644
index b633f905..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificateFactoryProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Cert Service
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import java.io.InputStream;
-import java.security.NoSuchProviderException;
-import java.security.Security;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.springframework.stereotype.Component;
-
-@Component
-public class CertificateFactoryProvider {
-
- static {
- Security.addProvider(new BouncyCastleProvider());
- }
-
- X509Certificate generateCertificate(InputStream inStream) throws CertificateException, NoSuchProviderException {
- return (X509Certificate) CertificateFactory.getInstance("X.509", "BC").generateCertificate(inStream);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationData.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationData.java
deleted file mode 100644
index bce72977..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationData.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-
-final class CertificationData {
-
- private CertificationData() {
- }
-
- private static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n";
- private static final String END_CERTIFICATE = "-----END CERTIFICATE-----";
-
- static final String EXTRA_CA_CERT = ""
- + BEGIN_CERTIFICATE
- + "MIIDvzCCAqcCFF5DejiyfoNfPiiMmBXulniBewBGMA0GCSqGSIb3DQEBCwUAMIGb\n"
- + "MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2Fu\n"
- + "LUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwE\n"
- + "T05BUDEVMBMGA1UEAwwMbmV3Lm9uYXAub3JnMR4wHAYJKoZIhvcNAQkBFg90ZXN0\n"
- + "ZXJAb25hcC5vcmcwHhcNMjAwMjEyMDk1OTM3WhcNMjEwMjExMDk1OTM3WjCBmzEL\n"
- + "MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbi1G\n"
- + "cmFuY2lzY28xGTAXBgNVBAoMEExpbnV4LUZvdW5kYXRpb24xDTALBgNVBAsMBE9O\n"
- + "QVAxFTATBgNVBAMMDG5ldy5vbmFwLm9yZzEeMBwGCSqGSIb3DQEJARYPdGVzdGVy\n"
- + "QG9uYXAub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtF4FXeDV\n"
- + "ng/inC/bTACmZnLC9IiC7PyG/vVbMxxN1bvQLRAwC/Hbl3i9zD68Vs/jPPr/SDr9\n"
- + "2rgItdDdUY1V30Y3PT06F11XdEaRb+t++1NX0rDf1AqPaBZgnBmB86s1wbqHdJTr\n"
- + "wEImDZ5xMPfP3fiWy/9Yw/U7iRMIi1/oI0lWuHJV0bn908shuJ6dvInpRCoDnoTX\n"
- + "YP/FiDSZCFVewQcq4TigB7kRqZrDcPZWbSlqHklDMXRwbCxAiFSziuX6TBwru9Rn\n"
- + "HhIeXVSgMU1ZSSopVbJGtQ4zSsU1nvTK5Bhc2UHGcAOZy1xTN5D9EEbTqh7l+Wtx\n"
- + "y8ojkEXvFG8lVwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAE+bUphwHit78LK8sb\n"
- + "OMjt4DiEu32KeSJOpYgPLeBeAIynaNsa7sQrpuxerGNTmQWIcw6olXI0J+OOwkik\n"
- + "II7elrYtd5G1uALxXWdamNsaY0Du34moVL1YjexJ7qQ4oBUxg2tuY8NAQGDK+23I\n"
- + "nCA+ZwzdTJo73TYS6sx64d/YLWkX4nHGUoMlF+xUH34csDyhpuTSzQhC2quB5N8z\n"
- + "tSFdpe4z2jqx07qo2EBFxi03EQ8Q0ex6l421QM2gbs7cZQ66K0DkpPcF2+iHZnyx\n"
- + "xq1lnlsWHklElF2bhyXTn3fPp5wtan00P8IolKx7CAWb92QjkW6M0RvTW/xuwIzh\n"
- + "0rTO\n"
- + END_CERTIFICATE;
-
- static final String CA_CERT = ""
- + BEGIN_CERTIFICATE
- + "MIIDtzCCAp8CFAwqQddh4/iyGfP8UZ3dpXlxfAN8MA0GCSqGSIb3DQEBCwUAMIGX\n"
- + "MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2Fu\n"
- + "LUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwE\n"
- + "T05BUDERMA8GA1UEAwwIb25hcC5vcmcxHjAcBgkqhkiG9w0BCQEWD3Rlc3RlckBv\n"
- + "bmFwLm9yZzAeFw0yMDAyMTIwOTM0MjdaFw0yMTAyMTEwOTM0MjdaMIGXMQswCQYD\n"
- + "VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuLUZyYW5j\n"
- + "aXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwET05BUDER\n"
- + "MA8GA1UEAwwIb25hcC5vcmcxHjAcBgkqhkiG9w0BCQEWD3Rlc3RlckBvbmFwLm9y\n"
- + "ZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMCFrnO7/eT6V+7XkPPd\n"
- + "eiL/6xXreuegvit/1/jTVjG+3AOVcmTn2WXwXXRcQLvkWQfJVPoltsY8E3FqFRti\n"
- + "797XjY6cdQJFVDyzNU0+Fb4vJL9FK5wSvnS6EFjBEn3JvXRlENorDCs/mfjkjJoa\n"
- + "Dl74gXQEJYcg4nsTeNIj7cm3Q7VK3mZt1t7LSJJ+czxv69UJDuNJpmQ/2WOKyLZA\n"
- + "gTtBJ+Hyol45/OLsrqwq1dAn9ZRWIFPvRt/XQYH9bI/6MtqSreRVUrdYCiTe/XpP\n"
- + "B/OM6NEi2+p5QLi3Yi70CEbqP3HqUVbkzF+r7bwIb6M5/HxfqzLmGwLvD+6rYnUn\n"
- + "Bm8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAhXoO65DXth2X/zFRNsCNpLwmDy7r\n"
- + "PxT9ZAIZAzSxx3/aCYiuTrKP1JnqjkO+F2IbikrI4n6sKO49SKnRf9SWTFhd+5dX\n"
- + "vxq5y7MaqxHAY9J7+Qzq33+COVFQnaF7ddel2NbyUVb2b9ZINNsaZkkPXui6DtQ7\n"
- + "/Fb/1tmAGWd3hMp75G2thBSzs816JMKKa9WD+4VGATEs6OSll4sv2fOZEn+0mAD3\n"
- + "9q9c+WtLGIudOwcHwzPb2njtNntQSCK/tVOqbY+vzhMY3JW+p9oSrLDSdGC+pAKK\n"
- + "m/wB+2VPIYcsPMtIhHC4tgoSaiCqjXYptaOh4b8ye8CPBUCpX/AYYkN0Ow==\n"
- + END_CERTIFICATE;
-
- static final String INTERMEDIATE_CERT = ""
- + BEGIN_CERTIFICATE
- + "MIIDqTCCApGgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwgZcxCzAJBgNVBAYTAlVT\n"
- + "MRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw\n"
- + "FwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMREwDwYDVQQD\n"
- + "DAhvbmFwLm9yZzEeMBwGCSqGSIb3DQEJARYPdGVzdGVyQG9uYXAub3JnMB4XDTIw\n"
- + "MDIxMjA5NDAxMloXDTIyMTEwODA5NDAxMlowgYQxCzAJBgNVBAYTAlVTMRMwEQYD\n"
- + "VQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkwFwYDVQQK\n"
- + "DBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQDDBVpbnRl\n"
- + "cm1lZGlhdGUub25hcC5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n"
- + "AQC1oOYMZ6G+2DGDAizYnzdCNiogivlht1s4oqgem7fM1XFPxD2p31ATIibOdqr/\n"
- + "gv1qemO9Q4r1xn6w1Ufq7T1K7PjnMzdSeTqZefurE2JM/HHx2QvW4TjMlz2ILgaD\n"
- + "L1LN60kmMQSOi5VxKJpsrCQxbOsxhvefd212gny5AZMcjJe23kUd9OxUrtvpdLEv\n"
- + "wI3vFEvT7oRUnEUg/XNz7qeg33vf1C39yMR+6O4s6oevgsEebVKjb+yOoS6zzGtz\n"
- + "72wZjm07C54ZlO+4Uy+QAlMjRiU3mgWkKbkOy+4CvwehjhpTikdBs2DX39ZLGHhn\n"
- + "L/0a2NYtGulp9XEqmTvRoI+PAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZI\n"
- + "hvcNAQELBQADggEBADcitdJ6YswiV8jAD9GK0gf3+zqcGegt4kt+79JXlXYbb1sY\n"
- + "q3o6prcB7nSUoClgF2xUPCslFGpM0Er9FCSFElQM/ru0l/KVmJS6kSpwEHvsYIH3\n"
- + "q5anta+Pyk8JSQWAAw+qrind0uBQMnhR8Tn13tgV+Kjvg/xlH/nZIEdN5YtLB1cA\n"
- + "beVsZRyRfVL9DeZU8s/MZ5wC3kgcEp5A4m5lg7HyBxBdqhzFcDr6xiy6OGqW8Yep\n"
- + "xrwfc8Fw8a/lOv4U+tBeGNKPQDYaL9hh+oM+qMkNXsHXDqdJsuEGJtU4i3Wcwzoc\n"
- + "XGN5NWV//4bP+NFmwgcn7AYCdRvz04A8GU/0Cwg=\n"
- + END_CERTIFICATE;
-
- static final String ENTITY_CERT = ""
- + BEGIN_CERTIFICATE
- + "MIIDjDCCAnSgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwgYQxCzAJBgNVBAYTAlVT\n"
- + "MRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw\n"
- + "FwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQD\n"
- + "DBVpbnRlcm1lZGlhdGUub25hcC5vcmcwHhcNMjAwMjEyMDk1MTI2WhcNMjIxMTA4\n"
- + "MDk1MTI2WjB7MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQG\n"
- + "A1UEBwwNU2FuLUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjEN\n"
- + "MAsGA1UECwwET05BUDEVMBMGA1UEAwwMdmlkLm9uYXAub3JnMIIBIjANBgkqhkiG\n"
- + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw+GIRzJzUOh0gtc+wzFJEdTnn+q5F10L0Yhr\n"
- + "G1xKdjPieHIFGsoiXwcuCU8arNSqlz7ocx62KQRkcA8y6edlOAsYtdOEJvqEI9vc\n"
- + "eyTB/HYsbzw3URPGch4AmibrQkKU9QvGwouHtHn4R2Ft2Y0tfEqv9hxj9v4njq4A\n"
- + "EiDLAFLl5FmVyCZu/MtKngSgu1smcaFKTYySPMxytgJZexoa/ALZyyE0gRhsvwHm\n"
- + "NLGCPt1bmE/PEGZybsCqliyTO0S56ncD55The7+D/UDS4kE1Wg0svlWon/YsE6QW\n"
- + "B3oeJDX7Kr8ebDTIAErevIAD7Sm4ee5se2zxYrsYlj0MzHZtvwIDAQABoxAwDjAM\n"
- + "BgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCvQ1pTvjON6vSlcJRKSY4r\n"
- + "8q7L4/9ZaVXWJAjzEYJtPIqsgGiPWz0vGfgklowU6tZxp9zRZFXfMil+mPQSe+yo\n"
- + "ULrZSQ/z48YHPueE/BNO/nT4aaVBEhPLR5aVwC7uQVX8H+m1V1UGT8lk9vdI9rej\n"
- + "CI9l524sLCpdE4dFXiWK2XHEZ0Vfylk221u3IYEogVVA+UMX7BFPSsOnI2vtYK/i\n"
- + "lwZtlri8LtTusNe4oiTkYyq+RSyDhtAswg8ANgvfHolhCHoLFj6w1IkG88UCmbwN\n"
- + "d7BoGMy06y5MJxyXEZG0vR7eNeLey0TIh+rAszAFPsIQvrOHW+HuA+WLQAj1mhnm\n"
- + END_CERTIFICATE;
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java
deleted file mode 100644
index 631d56ef..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.onap.aaf.certservice.certification.configuration.Cmpv2ServerProvider;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.model.CertificationModel;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-@Service
-public class CertificationModelFactory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CertificationModelFactory.class);
-
- private final CsrModelFactory csrModelFactory;
- private final Cmpv2ServerProvider cmpv2ServerProvider;
- private final CertificationProvider certificationProvider;
-
- @Autowired
- CertificationModelFactory(
- CsrModelFactory csrModelFactory,
- Cmpv2ServerProvider cmpv2ServerProvider,
- CertificationProvider certificationProvider
- ) {
- this.cmpv2ServerProvider = cmpv2ServerProvider;
- this.csrModelFactory = csrModelFactory;
- this.certificationProvider = certificationProvider;
- }
-
- public CertificationModel createCertificationModel(String encodedCsr, String encodedPrivateKey, String caName)
- throws DecryptionException, CmpClientException {
- CsrModel csrModel = csrModelFactory.createCsrModel(
- new CsrModelFactory.StringBase64(encodedCsr),
- new CsrModelFactory.StringBase64(encodedPrivateKey)
- );
- LOGGER.debug("Received CSR meta data: \n{}", csrModel);
-
- Cmpv2Server cmpv2Server = cmpv2ServerProvider.getCmpv2Server(caName);
- LOGGER.debug("Found server for given CA name: \n{}", cmpv2Server);
-
- LOGGER.info("Sending sign request for certification model for CA named: {}, and certificate signing request:\n{}",
- caName, csrModel);
- return certificationProvider.signCsr(csrModel, cmpv2Server);
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationProvider.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationProvider.java
deleted file mode 100644
index 2478cc58..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationProvider.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Cert Service
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.bouncycastle.openssl.jcajce.JcaMiscPEMGenerator;
-import org.bouncycastle.util.io.pem.PemObjectGenerator;
-import org.bouncycastle.util.io.pem.PemWriter;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.model.CertificationModel;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-import org.onap.aaf.certservice.cmpv2client.api.CmpClient;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.onap.aaf.certservice.cmpv2client.model.Cmpv2CertificationModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.security.cert.X509Certificate;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@Service
-public class CertificationProvider {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CertificationProvider.class);
-
- private final CmpClient cmpClient;
-
- @Autowired
- public CertificationProvider(CmpClient cmpClient) {
- this.cmpClient = cmpClient;
- }
-
- public CertificationModel signCsr(CsrModel csrModel, Cmpv2Server server)
- throws CmpClientException {
- Cmpv2CertificationModel certificates = cmpClient.createCertificate(csrModel, server);
- return new CertificationModel(convertFromX509CertificateListToPemList(certificates.getCertificateChain()),
- convertFromX509CertificateListToPemList(certificates.getTrustedCertificates()));
- }
-
- private static List<String> convertFromX509CertificateListToPemList(List<X509Certificate> certificates) {
- return certificates.stream().map(CertificationProvider::convertFromX509CertificateToPem).filter(cert -> !cert.isEmpty())
- .collect(Collectors.toList());
- }
-
- private static String convertFromX509CertificateToPem(X509Certificate certificate) {
- StringWriter sw = new StringWriter();
- try (PemWriter pw = new PemWriter(sw)) {
- PemObjectGenerator gen = new JcaMiscPEMGenerator(certificate);
- pw.writeObject(gen);
- } catch (IOException e) {
- LOGGER.error("Exception occurred during convert of X509 certificate", e);
- }
- return sw.toString();
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java
deleted file mode 100644
index b4f94b93..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import java.util.Base64;
-import java.util.Objects;
-import java.util.Optional;
-
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.bouncycastle.util.io.pem.PemObject;
-import org.onap.aaf.certservice.certification.exception.CsrDecryptionException;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.exception.KeyDecryptionException;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-
-@Service
-public class CsrModelFactory {
-
- private final PemObjectFactory pemObjectFactory
- = new PemObjectFactory();
- private final Pkcs10CertificationRequestFactory certificationRequestFactory
- = new Pkcs10CertificationRequestFactory();
-
-
- public CsrModel createCsrModel(StringBase64 csr, StringBase64 privateKey)
- throws DecryptionException {
- PKCS10CertificationRequest decodedCsr = decodeCsr(csr);
- PemObject decodedPrivateKey = decodePrivateKey(privateKey);
- return new CsrModel.CsrModelBuilder(decodedCsr, decodedPrivateKey).build();
- }
-
- private PemObject decodePrivateKey(StringBase64 privateKey)
- throws KeyDecryptionException {
-
- return privateKey.asString()
- .flatMap(pemObjectFactory::createPemObject)
- .orElseThrow(
- () -> new KeyDecryptionException("Incorrect Key, decryption failed")
- );
- }
-
- private PKCS10CertificationRequest decodeCsr(StringBase64 csr)
- throws CsrDecryptionException {
- return csr.asString()
- .flatMap(pemObjectFactory::createPemObject)
- .flatMap(certificationRequestFactory::createPkcs10CertificationRequest)
- .orElseThrow(
- () -> new CsrDecryptionException("Incorrect CSR, decryption failed")
- );
- }
-
- public static class StringBase64 {
- private final String value;
- private final Base64.Decoder decoder = Base64.getDecoder();
- private static final Logger LOGGER = LoggerFactory.getLogger(StringBase64.class);
-
- public StringBase64(String value) {
- this.value = value;
- }
-
- public Optional<String> asString() {
- try {
- String decodedString = new String(decoder.decode(value));
- return Optional.of(decodedString);
- } catch (RuntimeException e) {
- LOGGER.error("Exception occurred during decoding:", e);
- return Optional.empty();
- }
- }
-
- @Override
- public boolean equals(Object otherObject) {
- if (this == otherObject) {
- return true;
- }
- if (otherObject == null || getClass() != otherObject.getClass()) {
- return false;
- }
- StringBase64 that = (StringBase64) otherObject;
- return Objects.equals(value, that.value);
- }
-
- @Override
- public int hashCode() {
- return value.hashCode();
- }
- }
-
-}
-
-
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java
deleted file mode 100644
index 1eb5270f..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Optional;
-
-import org.bouncycastle.util.encoders.DecoderException;
-import org.bouncycastle.util.io.pem.PemObject;
-import org.bouncycastle.util.io.pem.PemReader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class PemObjectFactory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PemObjectFactory.class);
-
- public Optional<PemObject> createPemObject(String pem) {
-
- try (StringReader stringReader = new StringReader(pem);
- PemReader pemReader = new PemReader(stringReader)) {
- return Optional.ofNullable(pemReader.readPemObject());
- } catch (DecoderException | IOException e) {
- LOGGER.error("Exception occurred during creation of PEM:", e);
- return Optional.empty();
- }
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/Pkcs10CertificationRequestFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/Pkcs10CertificationRequestFactory.java
deleted file mode 100644
index 1b00a815..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/Pkcs10CertificationRequestFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.bouncycastle.util.encoders.DecoderException;
-import org.bouncycastle.util.io.pem.PemObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Optional;
-
-public class Pkcs10CertificationRequestFactory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Pkcs10CertificationRequestFactory.class);
-
- public Optional<PKCS10CertificationRequest> createPkcs10CertificationRequest(PemObject pemObject) {
- try {
- LOGGER.debug("Creating certification request from pem object");
- return Optional.of(new PKCS10CertificationRequest(pemObject.getContent()));
- } catch (DecoderException | IOException e) {
- LOGGER.error("Exception occurred during creation of certification request:", e);
- return Optional.empty();
- }
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/RsaContentSignerBuilder.java b/certService/src/main/java/org/onap/aaf/certservice/certification/RsaContentSignerBuilder.java
deleted file mode 100644
index 12f00f9c..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/RsaContentSignerBuilder.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Cert Service
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import java.io.IOException;
-import java.security.PrivateKey;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.crypto.util.PrivateKeyFactory;
-import org.bouncycastle.operator.ContentSigner;
-import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
-import org.bouncycastle.operator.OperatorCreationException;
-import org.bouncycastle.operator.bc.BcRSAContentSignerBuilder;
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.springframework.stereotype.Component;
-
-@Component
-public class RsaContentSignerBuilder {
-
- ContentSigner build(PKCS10CertificationRequest csr, PrivateKey privateKey)
- throws IOException, OperatorCreationException {
- AlgorithmIdentifier sigAlgId = csr.getSignatureAlgorithm();
- AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
-
- return new BcRSAContentSignerBuilder(sigAlgId, digAlgId)
- .build(PrivateKeyFactory.createKey(privateKey.getEncoded()));
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/X509CertificateBuilder.java b/certService/src/main/java/org/onap/aaf/certservice/certification/X509CertificateBuilder.java
deleted file mode 100644
index 5b24c653..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/X509CertificateBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Cert Service
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.SecureRandom;
-import java.time.LocalDateTime;
-import java.time.ZoneOffset;
-import java.util.Date;
-import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.bouncycastle.cert.X509v3CertificateBuilder;
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.springframework.stereotype.Component;
-
-@Component
-public class X509CertificateBuilder {
-
- private static final int SECURE_NEXT_BYTES = 16;
- private static final int VALID_PERIOD_IN_DAYS = 365;
-
- X509v3CertificateBuilder build(PKCS10CertificationRequest csr) throws IOException {
- return new X509v3CertificateBuilder(csr.getSubject(), createSerial(),
- Date.from(LocalDateTime.now().toInstant(ZoneOffset.UTC)),
- Date.from(LocalDateTime.now().plusDays(VALID_PERIOD_IN_DAYS).toInstant(ZoneOffset.UTC)),
- new PKCS10CertificationRequest(csr.getEncoded()).getSubject(),
- SubjectPublicKeyInfo.getInstance(ASN1Sequence.getInstance(csr.getSubjectPublicKeyInfo().getEncoded())));
-
- }
-
- private BigInteger createSerial() {
- byte[] serial = new byte[SECURE_NEXT_BYTES];
- new SecureRandom().nextBytes(serial);
- return new BigInteger(serial).abs();
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpClientConfig.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpClientConfig.java
deleted file mode 100644
index 329098ac..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpClientConfig.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Cert Service
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration;
-
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.onap.aaf.certservice.cmpv2client.api.CmpClient;
-import org.onap.aaf.certservice.cmpv2client.impl.CmpClientImpl;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.context.annotation.RequestScope;
-
-@Configuration
-public class CmpClientConfig {
-
- @Bean
- CmpClient cmpClient(CloseableHttpClient closeableHttpClient) {
- return new CmpClientImpl(closeableHttpClient);
- }
-
- @Bean
- @RequestScope
- CloseableHttpClient closeableHttpClient(HttpClientBuilder httpClientBuilder) {
- return httpClientBuilder.build();
- }
-
- @Bean
- HttpClientBuilder httpClientBuilder() {
- return HttpClientBuilder.create();
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java
deleted file mode 100644
index cea228c1..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class CmpServersConfig {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CmpServersConfig.class);
- private static final String INIT_CONFIGURATION = "Loading initial configuration";
- private static final String RELOADING_CONFIGURATION = "Reloading configuration";
- private static final String LOADING_SUCCESS_MESSAGE = "CMP Servers configuration successfully loaded from file {}";
- private static final String CMP_SERVERS_CONFIG_FILENAME = "cmpServers.json";
-
- private final String configPath;
- private final CmpServersConfigLoader cmpServersConfigLoader;
-
- private List<Cmpv2Server> cmpServers;
- private volatile boolean isReady;
-
- @Autowired
- public CmpServersConfig(@Value("${app.config.path}") String configPath,
- CmpServersConfigLoader cmpServersConfigLoader) {
- this.cmpServersConfigLoader = cmpServersConfigLoader;
- this.configPath = configPath;
- }
-
- @PostConstruct
- void init() {
- try {
- LOGGER.info(INIT_CONFIGURATION);
- loadConfiguration();
- } catch (CmpServersConfigLoadingException e) {
- LOGGER.error(e.getMessage(), e.getCause());
- }
- }
-
- public void reloadConfiguration() throws CmpServersConfigLoadingException {
- LOGGER.info(RELOADING_CONFIGURATION);
- loadConfiguration();
- }
-
-
- synchronized void loadConfiguration() throws CmpServersConfigLoadingException {
- isReady = false;
- String configFilePath = configPath + File.separator + CMP_SERVERS_CONFIG_FILENAME;
- this.cmpServers = Collections.unmodifiableList(cmpServersConfigLoader.load(configFilePath));
- LOGGER.info(LOADING_SUCCESS_MESSAGE, configFilePath);
- isReady = true;
- }
-
- public List<Cmpv2Server> getCmpServers() {
- return cmpServers;
- }
-
- public boolean isReady() {
- return isReady;
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoader.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoader.java
deleted file mode 100644
index 101712e2..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoader.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.File;
-import java.io.IOException;
-import java.security.InvalidParameterException;
-import java.util.List;
-
-import org.onap.aaf.certservice.certification.configuration.model.CmpServers;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.configuration.validation.Cmpv2ServersConfigurationValidator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-class CmpServersConfigLoader {
-
- private static final String LOADING_EXCEPTION_MESSAGE = "Exception occurred during CMP Servers configuration loading";
- private static final String VALIDATION_EXCEPTION_MESSAGE = "Validation of CMPv2 servers configuration failed";
-
- private final Cmpv2ServersConfigurationValidator validator;
-
- @Autowired
- CmpServersConfigLoader(Cmpv2ServersConfigurationValidator validator) {
- this.validator = validator;
- }
-
- List<Cmpv2Server> load(String path) throws CmpServersConfigLoadingException {
- try {
- List<Cmpv2Server> servers = loadConfigFromFile(path).getCmpv2Servers();
- validator.validate(servers);
- return servers;
- } catch (IOException e) {
- throw new CmpServersConfigLoadingException(LOADING_EXCEPTION_MESSAGE, e);
- } catch (InvalidParameterException e) {
- throw new CmpServersConfigLoadingException(VALIDATION_EXCEPTION_MESSAGE, e);
- }
- }
-
- private CmpServers loadConfigFromFile(String path) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- return objectMapper.readValue(new File(path), CmpServers.class);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoadingException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoadingException.java
deleted file mode 100644
index b7c3638d..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoadingException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration;
-
-public class CmpServersConfigLoadingException extends Exception {
-
- public CmpServersConfigLoadingException(String message) {
- super(message);
- }
-
- public CmpServersConfigLoadingException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProvider.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProvider.java
deleted file mode 100644
index 190bb28a..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProvider.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration;
-
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class Cmpv2ServerProvider {
-
- private final CmpServersConfig cmpServersConfig;
-
- @Autowired
- Cmpv2ServerProvider(CmpServersConfig cmpServersConfig) {
- this.cmpServersConfig = cmpServersConfig;
- }
-
- public Cmpv2Server getCmpv2Server(String caName) {
- return cmpServersConfig.getCmpServers().stream().filter(server -> server.getCaName().equals(caName)).findFirst()
- .orElseThrow(() -> new Cmpv2ServerNotFoundException("No server found for given CA name"));
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Authentication.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Authentication.java
deleted file mode 100644
index e4c15518..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Authentication.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.model;
-
-import javax.validation.constraints.NotNull;
-import org.hibernate.validator.constraints.Length;
-
-public class Authentication {
-
- private static final int MAX_IAK_RV_LENGTH = 256;
-
- @NotNull
- @Length(min = 1, max = MAX_IAK_RV_LENGTH)
- private String iak;
- @NotNull
- @Length(min = 1, max = MAX_IAK_RV_LENGTH)
- private String rv;
-
- public String getIak() {
- return iak;
- }
-
- public void setIak(String iak) {
- this.iak = iak;
- }
-
- public String getRv() {
- return rv;
- }
-
- public void setRv(String rv) {
- this.rv = rv;
- }
-
- @Override
- public String toString() {
- return "Authentication{"
- + " iak=*****"
- + ", rv=*****"
- + '}';
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CaMode.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CaMode.java
deleted file mode 100644
index 374feb3b..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CaMode.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.model;
-
-public enum CaMode {
- RA("RA"), CLIENT("Client");
-
- private String profile;
-
- CaMode(String profile) {
- this.profile = profile;
- }
-
- public String getProfile() {
- return profile;
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CmpServers.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CmpServers.java
deleted file mode 100644
index 7fac1887..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CmpServers.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.model;
-
-import java.util.List;
-
-public class CmpServers {
-
- private List<Cmpv2Server> cmpv2Servers;
-
- public List<Cmpv2Server> getCmpv2Servers() {
- return cmpv2Servers;
- }
-
- public void setCmpv2Servers(List<Cmpv2Server> cmpv2Servers) {
- this.cmpv2Servers = cmpv2Servers;
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Cmpv2Server.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Cmpv2Server.java
deleted file mode 100644
index 51d91966..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Cmpv2Server.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.model;
-
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-
-import org.bouncycastle.asn1.x500.X500Name;
-import org.hibernate.validator.constraints.Length;
-import org.onap.aaf.certservice.certification.configuration.validation.constraints.Cmpv2Url;
-
-public class Cmpv2Server {
-
- private static final int MAX_CA_NAME_LENGTH = 128;
-
- @NotNull
- @Valid
- private Authentication authentication;
- @NotNull
- private CaMode caMode;
- @NotNull
- @Length(min = 1, max = MAX_CA_NAME_LENGTH)
- private String caName;
- @NotNull
- private X500Name issuerDN;
- @Cmpv2Url
- private String url;
-
- public Authentication getAuthentication() {
- return authentication;
- }
-
- public void setAuthentication(Authentication authentication) {
- this.authentication = authentication;
- }
-
- public CaMode getCaMode() {
- return caMode;
- }
-
- public void setCaMode(CaMode caMode) {
- this.caMode = caMode;
- }
-
- public String getCaName() {
- return caName;
- }
-
- public void setCaName(String caName) {
- this.caName = caName;
- }
-
- public X500Name getIssuerDN() {
- return issuerDN;
- }
-
- public void setIssuerDN(X500Name issuerDN) {
- this.issuerDN = issuerDN;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- @Override
- public String toString() {
- return "Cmpv2Server{"
- + "authentication=" + authentication
- + ", caMode=" + caMode
- + ", caName='" + caName + '\''
- + ", issuerDN='" + issuerDN + '\''
- + ", url='" + url + '\''
- + '}';
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidator.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidator.java
deleted file mode 100644
index 3cf7fdf7..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidator.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.validation;
-
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-import java.security.InvalidParameterException;
-import java.util.List;
-import java.util.Set;
-
-@Service
-public class Cmpv2ServersConfigurationValidator {
-
- private final Validator validator;
-
- @Autowired
- public Cmpv2ServersConfigurationValidator(Validator validator) {
- this.validator = validator;
- }
-
- public void validate(List<Cmpv2Server> servers) {
- servers.forEach(this::validateServer);
- validateUniqueCaNames(servers);
- }
-
- private void validateServer(Cmpv2Server serverDetails) {
- Set<ConstraintViolation<Cmpv2Server>> violations = validator.validate(serverDetails);
- if (!violations.isEmpty()) {
- throw new InvalidParameterException(violations.toString());
- }
- }
-
- private void validateUniqueCaNames(List<Cmpv2Server> servers) {
- long distinctCAs = getNumberOfUniqueCaNames(servers);
- if (servers.size() != distinctCAs) {
- throw new InvalidParameterException("CA names are not unique within given CMPv2 servers");
- }
- }
-
- private long getNumberOfUniqueCaNames(List<Cmpv2Server> servers) {
- return servers.stream().map(Cmpv2Server::getCaName)
- .distinct()
- .count();
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2Url.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2Url.java
deleted file mode 100644
index a5450a25..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2Url.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.validation.constraints;
-
-import javax.validation.Constraint;
-import javax.validation.Payload;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Target({FIELD, ANNOTATION_TYPE})
-@Retention(RUNTIME)
-@Constraint(validatedBy = Cmpv2UrlValidator.class)
-public @interface Cmpv2Url {
- String message() default "Server URL is invalid.";
-
- Class<?>[] groups() default {};
-
- Class<? extends Payload>[] payload() default {};
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidator.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidator.java
deleted file mode 100644
index 7ce3bb6c..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.onap.aaf.certservice.certification.configuration.validation.constraints;
-
-import org.onap.aaf.certservice.certification.configuration.validation.constraints.violations.PortNumberViolation;
-import org.onap.aaf.certservice.certification.configuration.validation.constraints.violations.RequestTypeViolation;
-import org.onap.aaf.certservice.certification.configuration.validation.constraints.violations.UrlServerViolation;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-class Cmpv2UrlValidator implements ConstraintValidator<Cmpv2Url, String> {
-
- private final List<UrlServerViolation> violations;
-
- Cmpv2UrlValidator() {
- this.violations = Arrays.asList(
- new PortNumberViolation(),
- new RequestTypeViolation()
- );
- }
-
- @Override
- public boolean isValid(String url, ConstraintValidatorContext context) {
- AtomicBoolean isValid = new AtomicBoolean(true);
- violations.forEach(violation -> {
- if (!violation.validate(url)) {
- isValid.set(false);
- }
- });
- return isValid.get();
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolation.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolation.java
deleted file mode 100644
index 96f30149..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolation.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.validation.constraints.violations;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-public class PortNumberViolation implements UrlServerViolation {
-
- private static final int MIN_PORT = 1;
- private static final int MAX_PORT = 65535;
- private static final int PORT_UNDEFINED = -1;
-
- @Override
- public boolean validate(String serverUrl) {
- try {
- URL url = new URL(serverUrl);
- int port = url.getPort();
- return port >= MIN_PORT && port <= MAX_PORT || port == PORT_UNDEFINED;
- } catch (MalformedURLException e) {
- return false;
- }
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolation.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolation.java
deleted file mode 100644
index 67a5c3c4..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolation.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.onap.aaf.certservice.certification.configuration.validation.constraints.violations;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class RequestTypeViolation implements UrlServerViolation {
-
- private static final List<String> VALID_REQUESTS = Collections.singletonList("http");
-
- @Override
- public boolean validate(String serverUrl) {
- try {
- AtomicBoolean isValid = new AtomicBoolean(false);
- String protocol = new URL(serverUrl).getProtocol();
- VALID_REQUESTS.forEach(requestType -> {
- if (protocol.equals(requestType)) {
- isValid.set(true);
- }
- });
- return isValid.get();
- } catch (MalformedURLException e) {
- return false;
- }
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/UrlServerViolation.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/UrlServerViolation.java
deleted file mode 100644
index 5452beb4..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/UrlServerViolation.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.validation.constraints.violations;
-
-public interface UrlServerViolation {
- boolean validate(String url);
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/Cmpv2ClientAdapterException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exception/Cmpv2ClientAdapterException.java
deleted file mode 100644
index 1b26da7b..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/Cmpv2ClientAdapterException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Cert Service
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.exception;
-
-public class Cmpv2ClientAdapterException extends Exception {
-
- public Cmpv2ClientAdapterException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/Cmpv2ServerNotFoundException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exception/Cmpv2ServerNotFoundException.java
deleted file mode 100644
index 35acb0cd..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/Cmpv2ServerNotFoundException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.exception;
-
-public class Cmpv2ServerNotFoundException extends RuntimeException {
- public Cmpv2ServerNotFoundException(String message) {
- super(message);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/CsrDecryptionException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exception/CsrDecryptionException.java
deleted file mode 100644
index ed434e07..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/CsrDecryptionException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.exception;
-
-public class CsrDecryptionException extends DecryptionException {
- public CsrDecryptionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public CsrDecryptionException(String message) {
- super(message);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/DecryptionException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exception/DecryptionException.java
deleted file mode 100644
index 6d8f7073..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/DecryptionException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.exception;
-
-public class DecryptionException extends Exception {
-
- public DecryptionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public DecryptionException(String message) {
- super(message);
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/ErrorResponseModel.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exception/ErrorResponseModel.java
deleted file mode 100644
index 8899f77c..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/ErrorResponseModel.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.exception;
-
-public class ErrorResponseModel {
-
- private final String errorMessage;
-
- public ErrorResponseModel(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
-}
-
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/KeyDecryptionException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exception/KeyDecryptionException.java
deleted file mode 100644
index d4814d6a..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/exception/KeyDecryptionException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.exception;
-
-public class KeyDecryptionException extends DecryptionException {
- public KeyDecryptionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public KeyDecryptionException(String message) {
- super(message);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/model/CertificationModel.java b/certService/src/main/java/org/onap/aaf/certservice/certification/model/CertificationModel.java
deleted file mode 100644
index b851d0d9..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/model/CertificationModel.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.model;
-
-import java.util.Collections;
-import java.util.List;
-
-public class CertificationModel {
-
- private final List<String> certificateChain;
- private final List<String> trustedCertificates;
-
- public CertificationModel(List<String> certificateChain, List<String> trustedCertificates) {
- this.certificateChain = certificateChain;
- this.trustedCertificates = trustedCertificates;
- }
-
- public List<String> getCertificateChain() {
- return Collections.unmodifiableList(certificateChain);
- }
-
- public List<String> getTrustedCertificates() {
- return Collections.unmodifiableList(trustedCertificates);
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/model/CsrModel.java b/certService/src/main/java/org/onap/aaf/certservice/certification/model/CsrModel.java
deleted file mode 100644
index d81da10a..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/model/CsrModel.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.model;
-
-import java.io.IOException;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-import org.bouncycastle.asn1.x500.X500Name;
-import org.bouncycastle.asn1.x509.Extension;
-import org.bouncycastle.asn1.x509.Extensions;
-import org.bouncycastle.asn1.x509.GeneralName;
-import org.bouncycastle.asn1.x509.GeneralNames;
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.bouncycastle.util.io.pem.PemObject;
-
-import org.onap.aaf.certservice.certification.exception.CsrDecryptionException;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.exception.KeyDecryptionException;
-
-
-public class CsrModel {
-
- private final PKCS10CertificationRequest csr;
- private final X500Name subjectData;
- private final PrivateKey privateKey;
- private final PublicKey publicKey;
- private final List<String> sans;
-
- public CsrModel(PKCS10CertificationRequest csr, X500Name subjectData, PrivateKey privateKey, PublicKey publicKey,
- List<String> sans) {
- this.csr = csr;
- this.subjectData = subjectData;
- this.privateKey = privateKey;
- this.publicKey = publicKey;
- this.sans = sans;
- }
-
- public PKCS10CertificationRequest getCsr() {
- return csr;
- }
-
- public X500Name getSubjectData() {
- return subjectData;
- }
-
- public PrivateKey getPrivateKey() {
- return privateKey;
- }
-
- public PublicKey getPublicKey() {
- return publicKey;
- }
-
- public List<String> getSans() {
- return sans;
- }
-
- @Override
- public String toString() {
- return "Subject: { " + subjectData + " ,SANs: " + sans + " }";
- }
-
- public static class CsrModelBuilder {
-
- private final PKCS10CertificationRequest csr;
- private final PemObject privateKey;
-
- public CsrModel build() throws DecryptionException {
-
- X500Name subjectData = getSubjectData();
- PrivateKey javaPrivateKey = convertingPemPrivateKeyToJavaSecurityPrivateKey(getPrivateKey());
- PublicKey javaPublicKey = convertingPemPublicKeyToJavaSecurityPublicKey(getPublicKey());
- List<String> sans = getSansData();
-
- return new CsrModel(csr, subjectData, javaPrivateKey, javaPublicKey, sans);
- }
-
- public CsrModelBuilder(PKCS10CertificationRequest csr, PemObject privateKey) {
- this.csr = csr;
- this.privateKey = privateKey;
- }
-
- private PemObject getPublicKey() throws CsrDecryptionException {
- try {
- return new PemObject("PUBLIC KEY", csr.getSubjectPublicKeyInfo().getEncoded());
- } catch (IOException e) {
- throw new CsrDecryptionException("Reading Public Key from CSR failed", e.getCause());
- }
- }
-
- private PemObject getPrivateKey() {
- return privateKey;
- }
-
- private X500Name getSubjectData() {
- return csr.getSubject();
- }
-
- private List<String> getSansData() {
- if (!isAttrsEmpty() && !isAttrsValuesEmpty()) {
- Extensions extensions = Extensions.getInstance(csr.getAttributes()[0].getAttrValues().getObjectAt(0));
- GeneralName[] arrayOfAlternativeNames =
- GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName).getNames();
- return Arrays.stream(arrayOfAlternativeNames).map(GeneralName::getName).map(Objects::toString)
- .collect(Collectors.toList());
- }
- return Collections.emptyList();
- }
-
- private boolean isAttrsValuesEmpty() {
- return csr.getAttributes()[0].getAttrValues().size() == 0;
- }
-
- private boolean isAttrsEmpty() {
- return csr.getAttributes().length == 0;
- }
-
- private PrivateKey convertingPemPrivateKeyToJavaSecurityPrivateKey(PemObject privateKey)
- throws KeyDecryptionException {
- try {
- KeyFactory factory = KeyFactory.getInstance("RSA");
- PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKey.getContent());
- return factory.generatePrivate(keySpec);
- } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
- throw new KeyDecryptionException("Converting Private Key failed", e.getCause());
- }
- }
-
- private PublicKey convertingPemPublicKeyToJavaSecurityPublicKey(PemObject publicKey)
- throws KeyDecryptionException {
- try {
- KeyFactory factory = KeyFactory.getInstance("RSA");
- X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKey.getContent());
- return factory.generatePublic(keySpec);
- } catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
- throw new KeyDecryptionException("Converting Public Key from CSR failed", e.getCause());
- }
- }
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/api/CmpClient.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/api/CmpClient.java
deleted file mode 100644
index cccb744d..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/api/CmpClient.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.api;
-
-import java.util.Date;
-
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.onap.aaf.certservice.cmpv2client.model.Cmpv2CertificationModel;
-
-/**
- * This class represent CmpV2Client Interface for obtaining X.509 Digital Certificates in a Public
- * Key Infrastructure (PKI), making use of Certificate Management Protocol (CMPv2) operating on
- * newest version: cmp2000(2).
- */
-public interface CmpClient {
-
- /**
- * Requests for a External Root CA Certificate to be created for the passed public keyPair wrapped
- * in a CSRMeta with common details, accepts self-signed certificate. Basic Authentication using
- * IAK/RV, Verification of the signature (proof-of-possession) on the request is performed and an
- * Exception thrown if verification fails or issue encountered in fetching certificate from CA.
- *
- * @param csrModel Certificate Signing Request model. Must not be {@code null}.
- * @param server CMPv2 Server. Must not be {@code null}.
- * @param notBefore An optional validity to set in the created certificate, Certificate not valid
- * before this date.
- * @param notAfter An optional validity to set in the created certificate, Certificate not valid
- * after this date.
- * @return model for certification containing certificate chain and trusted certificates
- * @throws CmpClientException if client error occurs.
- */
- Cmpv2CertificationModel createCertificate(
- CsrModel csrModel,
- Cmpv2Server server,
- Date notBefore,
- Date notAfter)
- throws CmpClientException;
-
- /**
- * Requests for a External Root CA Certificate to be created for the passed public keyPair wrapped
- * in a CSRMeta with common details, accepts self-signed certificate. Basic Authentication using
- * IAK/RV, Verification of the signature (proof-of-possession) on the request is performed and an
- * Exception thrown if verification fails or issue encountered in fetching certificate from CA.
- *
- * @param csrModel Certificate Signing Request Model. Must not be {@code null}.
- * @param server CMPv2 server. Must not be {@code null}.
- * @return model for certification containing certificate chain and trusted certificates
- * @throws CmpClientException if client error occurs.
- */
- Cmpv2CertificationModel createCertificate(
- CsrModel csrModel,
- Cmpv2Server server)
- throws CmpClientException;
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/exceptions/CmpClientException.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/exceptions/CmpClientException.java
deleted file mode 100644
index 2a04306a..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/exceptions/CmpClientException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.exceptions;
-
-/**
- * The CmpClientException wraps all exceptions occur internally to Cmpv2Client Api code.
- */
-public class CmpClientException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Creates a new instance with detail message.
- */
- public CmpClientException(String message) {
- super(message);
- }
-
- /**
- * Creates a new instance with detail Throwable cause.
- */
- public CmpClientException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Creates a new instance with detail message and Throwable cause.
- */
- public CmpClientException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/exceptions/PkiErrorException.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/exceptions/PkiErrorException.java
deleted file mode 100644
index 62411fbd..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/exceptions/PkiErrorException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.exceptions;
-
-public class PkiErrorException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Creates a new instance with detail message.
- */
- public PkiErrorException(String message) {
- super(message);
- }
-
- /**
- * Creates a new instance with detail Throwable cause.
- */
- public PkiErrorException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Creates a new instance with detail message and Throwable cause.
- */
- public PkiErrorException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java
deleted file mode 100644
index 9e95ab2f..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- *
- * Modifications Copyright (C) 2019 IBM.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.certservice.cmpv2client.external;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-
-public final class Factory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Factory.class);
- private static final KeyPairGenerator KEY_PAIR_GENERATOR;
- private static final SecureRandom SECURE_RANDOM;
- private static final String KEY_ALGORITHM = "RSA";
- private static final int KEY_LENGTH = 2048;
-
- static {
- SECURE_RANDOM = new SecureRandom();
- KeyPairGenerator tempKeygen;
- try {
- tempKeygen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
- tempKeygen.initialize(KEY_LENGTH, SECURE_RANDOM);
- } catch (NoSuchAlgorithmException e) {
- tempKeygen = null;
- LOGGER.error("Given KEY_ALGORITHM is invalid.", e);
- }
- KEY_PAIR_GENERATOR = tempKeygen;
- }
-
- private Factory() {
- }
-
- public static KeyPair generateKeyPair() {
- return KEY_PAIR_GENERATOR.generateKeyPair();
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Rdn.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Rdn.java
deleted file mode 100644
index 25017b8a..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Rdn.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- *
- * Modifications Copyright (C) 2019 IBM.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.certservice.cmpv2client.external;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
-import org.bouncycastle.asn1.x500.style.BCStyle;
-import org.bouncycastle.cert.CertException;
-
-public class Rdn {
-
- private String tag;
- private String value;
- private ASN1ObjectIdentifier aoi;
-
- public String getValue() {
- return value;
- }
-
- public Rdn(final String tag, final String value) throws CertException {
- this.tag = tag;
- this.value = value;
- this.aoi = getAoi(tag);
- }
-
- public Rdn(final String tagValue) throws CertException {
- List<String> tv = parseRdn("=", tagValue);
- this.tag = tv.get(0);
- this.value = tv.get(1);
- this.aoi = getAoi(this.tag);
- }
-
- /**
- * Splits RDN as string by given delimiter, then trims every part.
- *
- * @param splitBy Delimiter which splits value
- * @param value Value to be splitted
- * @return List of splitted and trimmed strings
- */
- static List<String> parseRdn(String splitBy, String value) {
- String[] splitted = value.split(splitBy);
- return Arrays.stream(splitted)
- .map(String::trim)
- .collect(Collectors.toList());
- }
- /**
- * Parse various forms of DNs into appropriate RDNs, which have the ASN1ObjectIdentifier
- *
- * @param delim
- * @param dnString
- * @return
- * @throws CertException
- */
-
- public static List<Rdn> parse(final char delim, final String dnString) throws CertException {
- List<Rdn> lrnd = new ArrayList<>();
- StringBuilder sb = new StringBuilder();
- boolean inQuotes = false;
- for (int i = 0; i < dnString.length(); ++i) {
- char currentCharacter = dnString.charAt(i);
- if (inQuotes) {
- if ('"' == currentCharacter) {
- inQuotes = false;
- } else {
- sb.append(dnString.charAt(i));
- }
- } else {
- if ('"' == currentCharacter) {
- inQuotes = true;
- } else if (delim == currentCharacter) {
- if (sb.length() > 0) {
- lrnd.add(new Rdn(sb.toString()));
- sb.setLength(0);
- }
- } else {
- sb.append(dnString.charAt(i));
- }
- }
- }
- if (sb.indexOf("=") > 0) {
- lrnd.add(new Rdn(sb.toString()));
- }
- return lrnd;
- }
-
- @Override
- public String toString() {
- return tag + '=' + value;
- }
-
- ASN1ObjectIdentifier getAoi() {
- return aoi;
- }
-
- ASN1ObjectIdentifier getAoi(String tag) throws CertException {
- switch (tag.toLowerCase()) {
- case "cn":
- return BCStyle.CN;
- case "c":
- return BCStyle.C;
- case "st":
- return BCStyle.ST;
- case "l":
- return BCStyle.L;
- case "o":
- return BCStyle.O;
- case "ou":
- return BCStyle.OU;
- case "dc":
- return BCStyle.DC;
- case "gn":
- return BCStyle.GIVENNAME;
- case "sn":
- return BCStyle.SN;
- case "email":
- case "e":
- case "emailaddress":
- return BCStyle.EmailAddress;
- case "initials":
- return BCStyle.INITIALS;
- case "pseudonym":
- return BCStyle.PSEUDONYM;
- case "generationqualifier":
- return BCStyle.GENERATION;
- case "serialnumber":
- return BCStyle.SERIALNUMBER;
- default:
- throw new CertException(
- "Unknown ASN1ObjectIdentifier for tag " + tag);
- }
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java
deleted file mode 100644
index 87991132..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import java.security.KeyPair;
-import java.security.PublicKey;
-
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpResponseHelper.checkIfCmpResponseContainsError;
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpResponseHelper.getCertFromByteArray;
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore;
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpResponseValidationHelper.checkImplicitConfirm;
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpResponseValidationHelper.verifyPasswordBasedProtection;
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpResponseValidationHelper.verifySignature;
-
-import java.io.IOException;
-import java.security.cert.CertificateParsingException;
-import java.security.cert.X509Certificate;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Objects;
-import java.util.Optional;
-
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.bouncycastle.asn1.cmp.CMPCertificate;
-import org.bouncycastle.asn1.cmp.CertRepMessage;
-import org.bouncycastle.asn1.cmp.CertResponse;
-import org.bouncycastle.asn1.cmp.PKIBody;
-import org.bouncycastle.asn1.cmp.PKIHeader;
-import org.bouncycastle.asn1.cmp.PKIMessage;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.onap.aaf.certservice.certification.configuration.model.CaMode;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.onap.aaf.certservice.cmpv2client.api.CmpClient;
-import org.onap.aaf.certservice.cmpv2client.model.Cmpv2CertificationModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of the CmpClient Interface conforming to RFC4210 (Certificate Management Protocol
- * (CMP)) and RFC4211 (Certificate Request Message Format (CRMF)) standards.
- */
-public class CmpClientImpl implements CmpClient {
-
- private static final Logger LOG = LoggerFactory.getLogger(CmpClientImpl.class);
- private final CloseableHttpClient httpClient;
-
- private static final String DEFAULT_CA_NAME = "Certification Authority";
- private static final String DEFAULT_PROFILE = CaMode.RA.getProfile();
-
- public CmpClientImpl(CloseableHttpClient httpClient) {
- this.httpClient = httpClient;
- }
-
- @Override
- public Cmpv2CertificationModel createCertificate(
- CsrModel csrModel,
- Cmpv2Server server,
- Date notBefore,
- Date notAfter)
- throws CmpClientException {
-
- validate(csrModel, server, httpClient, notBefore, notAfter);
- KeyPair keyPair = new KeyPair(csrModel.getPublicKey(), csrModel.getPrivateKey());
-
- final CreateCertRequest certRequest =
- CmpMessageBuilder.of(CreateCertRequest::new)
- .with(CreateCertRequest::setIssuerDn, server.getIssuerDN())
- .with(CreateCertRequest::setSubjectDn, csrModel.getSubjectData())
- .with(CreateCertRequest::setSansList, csrModel.getSans())
- .with(CreateCertRequest::setSubjectKeyPair, keyPair)
- .with(CreateCertRequest::setNotBefore, notBefore)
- .with(CreateCertRequest::setNotAfter, notAfter)
- .with(CreateCertRequest::setInitAuthPassword, server.getAuthentication().getIak())
- .with(CreateCertRequest::setSenderKid, server.getAuthentication().getRv())
- .build();
-
- final PKIMessage pkiMessage = certRequest.generateCertReq();
- Cmpv2HttpClient cmpv2HttpClient = new Cmpv2HttpClient(httpClient);
- return retrieveCertificates(csrModel, server, pkiMessage, cmpv2HttpClient);
- }
-
- @Override
- public Cmpv2CertificationModel createCertificate(CsrModel csrModel, Cmpv2Server server)
- throws CmpClientException {
- return createCertificate(csrModel, server, null, null);
- }
-
- private void checkCmpResponse(
- final PKIMessage respPkiMessage, final PublicKey publicKey, final String initAuthPassword)
- throws CmpClientException {
- final PKIHeader header = respPkiMessage.getHeader();
- final AlgorithmIdentifier protectionAlgo = header.getProtectionAlg();
- verifySignatureWithPublicKey(respPkiMessage, publicKey);
- verifyProtectionWithProtectionAlgo(respPkiMessage, initAuthPassword, header, protectionAlgo);
- }
-
- private void verifySignatureWithPublicKey(PKIMessage respPkiMessage, PublicKey publicKey)
- throws CmpClientException {
- if (Objects.nonNull(publicKey)) {
- LOG.debug("Verifying signature of the response.");
- verifySignature(respPkiMessage, publicKey);
- } else {
- LOG.error("Public Key is not available, therefore cannot verify signature");
- throw new CmpClientException(
- "Public Key is not available, therefore cannot verify signature");
- }
- }
-
- private void verifyProtectionWithProtectionAlgo(
- PKIMessage respPkiMessage,
- String initAuthPassword,
- PKIHeader header,
- AlgorithmIdentifier protectionAlgo)
- throws CmpClientException {
- if (Objects.nonNull(protectionAlgo)) {
- LOG.debug("Verifying PasswordBased Protection of the Response.");
- verifyPasswordBasedProtection(respPkiMessage, initAuthPassword, protectionAlgo);
- checkImplicitConfirm(header);
- } else {
- LOG.error(
- "Protection Algorithm is not available when expecting PBE protected response containing protection algorithm");
- throw new CmpClientException(
- "Protection Algorithm is not available when expecting PBE protected response containing protection algorithm");
- }
- }
-
- private Cmpv2CertificationModel checkCmpCertRepMessage(final PKIMessage respPkiMessage)
- throws CmpClientException {
- final PKIBody pkiBody = respPkiMessage.getBody();
- if (Objects.nonNull(pkiBody) && pkiBody.getContent() instanceof CertRepMessage) {
- final CertRepMessage certRepMessage = (CertRepMessage) pkiBody.getContent();
- if (Objects.nonNull(certRepMessage)) {
- final CertResponse certResponse =
- getCertificateResponseContainingNewCertificate(certRepMessage);
- try {
- return verifyReturnCertChainAndTrustStore(respPkiMessage, certRepMessage, certResponse);
- } catch (IOException | CertificateParsingException ex) {
- CmpClientException cmpClientException =
- new CmpClientException(
- "Exception occurred while retrieving Certificates from response", ex);
- LOG.error("Exception occurred while retrieving Certificates from response", ex);
- throw cmpClientException;
- }
- } else {
- return new Cmpv2CertificationModel(Collections.emptyList(), Collections.emptyList());
- }
- }
- return new Cmpv2CertificationModel(Collections.emptyList(), Collections.emptyList());
- }
-
- private Cmpv2CertificationModel verifyReturnCertChainAndTrustStore(
- PKIMessage respPkiMessage, CertRepMessage certRepMessage, CertResponse certResponse)
- throws CertificateParsingException, CmpClientException, IOException {
- LOG.info("Verifying certificates returned as part of CertResponse.");
- final CMPCertificate cmpCertificate =
- certResponse.getCertifiedKeyPair().getCertOrEncCert().getCertificate();
- final Optional<X509Certificate> leafCertificate =
- getCertFromByteArray(cmpCertificate.getEncoded(), X509Certificate.class);
- if (leafCertificate.isPresent()) {
- return verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate.get());
- }
- return new Cmpv2CertificationModel(Collections.emptyList(), Collections.emptyList());
- }
-
- private CertResponse getCertificateResponseContainingNewCertificate(
- CertRepMessage certRepMessage) {
- return certRepMessage.getResponse()[0];
- }
-
- /**
- * Validate inputs for Certificate Creation.
- *
- * @param csrModel Certificate Signing Request model. Must not be {@code null}.
- * @param server CMPv2 Server. Must not be {@code null}.
- * @throws IllegalArgumentException if Before Date is set after the After Date.
- */
- private static void validate(
- final CsrModel csrModel,
- final Cmpv2Server server,
- final CloseableHttpClient httpClient,
- final Date notBefore,
- final Date notAfter) {
-
- String caName = CmpUtil.isNullOrEmpty(server.getCaName()) ? server.getCaName() : DEFAULT_CA_NAME;
- String profile = server.getCaMode() != null ? server.getCaMode().getProfile() : DEFAULT_PROFILE;
- LOG.info(
- "Validate before creating Certificate Request for CA :{} in Mode {} ", caName, profile);
-
- CmpUtil.notNull(csrModel, "CsrModel Instance");
- CmpUtil.notNull(csrModel.getSubjectData(), "Subject DN");
- CmpUtil.notNull(csrModel.getPrivateKey(), "Subject private key");
- CmpUtil.notNull(csrModel.getPublicKey(), "Subject public key");
- CmpUtil.notNull(server.getIssuerDN(), "Issuer DN");
- CmpUtil.notNull(server.getUrl(), "External CA URL");
- CmpUtil.notNull(server.getAuthentication().getIak(), "IAK/RV Password");
- CmpUtil.notNull(httpClient, "Closeable Http Client");
-
- if (notBefore != null && notAfter != null && notBefore.compareTo(notAfter) > 0) {
- throw new IllegalArgumentException("Before Date is set after the After Date");
- }
- }
-
- private Cmpv2CertificationModel retrieveCertificates(
- CsrModel csrModel, Cmpv2Server server, PKIMessage pkiMessage, Cmpv2HttpClient cmpv2HttpClient)
- throws CmpClientException {
- final byte[] respBytes = cmpv2HttpClient.postRequest(pkiMessage, server.getUrl(), server.getCaName());
- try {
- final PKIMessage respPkiMessage = PKIMessage.getInstance(respBytes);
- LOG.info("Received response from Server");
- checkIfCmpResponseContainsError(respPkiMessage);
- checkCmpResponse(respPkiMessage, csrModel.getPublicKey(), server.getAuthentication().getIak());
- return checkCmpCertRepMessage(respPkiMessage);
- } catch (IllegalArgumentException iae) {
- CmpClientException cmpClientException =
- new CmpClientException(
- "Error encountered while processing response from CA server ", iae);
- LOG.error("Error encountered while processing response from CA server ", iae);
- throw cmpClientException;
- }
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpMessageBuilder.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpMessageBuilder.java
deleted file mode 100644
index 1f370f93..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpMessageBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-
-/**
- * Generic Builder Class for creating CMP Message.
- */
-public final class CmpMessageBuilder<T> {
-
- private final Supplier<T> instantiator;
- private final List<Consumer<T>> instanceModifiers = new ArrayList<>();
-
- public CmpMessageBuilder(Supplier<T> instantiator) {
- this.instantiator = instantiator;
- }
-
- public static <T> CmpMessageBuilder<T> of(Supplier<T> instantiator) {
- return new CmpMessageBuilder<>(instantiator);
- }
-
- public <U> CmpMessageBuilder<T> with(BiConsumer<T, U> consumer, U value) {
- Consumer<T> valueConsumer = instance -> consumer.accept(instance, value);
- instanceModifiers.add(valueConsumer);
- return this;
- }
-
- public T build() {
- T value = instantiator.get();
- instanceModifiers.forEach(modifier -> modifier.accept(value));
- instanceModifiers.clear();
- return value;
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpMessageHelper.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpMessageHelper.java
deleted file mode 100644
index 6fcc5f14..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpMessageHelper.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpUtil.generateProtectedBytes;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.KeyPair;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import javax.crypto.Mac;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.bouncycastle.asn1.ASN1EncodableVector;
-import org.bouncycastle.asn1.ASN1Integer;
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
-import org.bouncycastle.asn1.DERBitString;
-import org.bouncycastle.asn1.DEROctetString;
-import org.bouncycastle.asn1.DEROutputStream;
-import org.bouncycastle.asn1.DERSequence;
-import org.bouncycastle.asn1.DERTaggedObject;
-import org.bouncycastle.asn1.cmp.PBMParameter;
-import org.bouncycastle.asn1.cmp.PKIBody;
-import org.bouncycastle.asn1.cmp.PKIHeader;
-import org.bouncycastle.asn1.cmp.PKIMessage;
-import org.bouncycastle.asn1.crmf.CertRequest;
-import org.bouncycastle.asn1.crmf.OptionalValidity;
-import org.bouncycastle.asn1.crmf.POPOSigningKey;
-import org.bouncycastle.asn1.crmf.ProofOfPossession;
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.asn1.x509.Extension;
-import org.bouncycastle.asn1.x509.Extensions;
-import org.bouncycastle.asn1.x509.ExtensionsGenerator;
-import org.bouncycastle.asn1.x509.GeneralName;
-import org.bouncycastle.asn1.x509.GeneralNames;
-import org.bouncycastle.asn1.x509.KeyUsage;
-import org.bouncycastle.asn1.x509.Time;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class CmpMessageHelper {
-
- private static final Logger LOG = LoggerFactory.getLogger(CmpMessageHelper.class);
- private static final AlgorithmIdentifier OWF_ALGORITHM =
- new AlgorithmIdentifier(new ASN1ObjectIdentifier("1.3.14.3.2.26"));
- private static final AlgorithmIdentifier MAC_ALGORITHM =
- new AlgorithmIdentifier(new ASN1ObjectIdentifier("1.2.840.113549.2.9"));
- private static final ASN1ObjectIdentifier PASSWORD_BASED_MAC =
- new ASN1ObjectIdentifier("1.2.840.113533.7.66.13");
-
- private CmpMessageHelper() {
- }
-
- /**
- * Creates an Optional Validity, which is used to specify how long the returned cert should be
- * valid for.
- *
- * @param notBefore Date specifying certificate is not valid before this date.
- * @param notAfter Date specifying certificate is not valid after this date.
- * @return {@link OptionalValidity} that can be set for certificate on external CA.
- */
- public static OptionalValidity generateOptionalValidity(
- final Date notBefore, final Date notAfter) {
- LOG.info("Generating Optional Validity from Date objects");
- ASN1EncodableVector optionalValidityV = new ASN1EncodableVector();
- if (notBefore != null) {
- Time nb = new Time(notBefore);
- optionalValidityV.add(new DERTaggedObject(true, 0, nb));
- }
- if (notAfter != null) {
- Time na = new Time(notAfter);
- optionalValidityV.add(new DERTaggedObject(true, 1, na));
- }
- return OptionalValidity.getInstance(new DERSequence(optionalValidityV));
- }
-
- /**
- * Create Extensions from Subject Alternative Names.
- *
- * @return {@link Extensions}.
- */
- public static Extensions generateExtension(final List<String> sansList)
- throws CmpClientException {
- LOG.info("Generating Extensions from Subject Alternative Names");
- final ExtensionsGenerator extGenerator = new ExtensionsGenerator();
- final GeneralName[] sansGeneralNames = getGeneralNames(sansList);
- // KeyUsage
- try {
- final KeyUsage keyUsage =
- new KeyUsage(
- KeyUsage.digitalSignature | KeyUsage.keyEncipherment | KeyUsage.nonRepudiation);
- extGenerator.addExtension(Extension.keyUsage, false, new DERBitString(keyUsage));
- extGenerator.addExtension(
- Extension.subjectAlternativeName, false, new GeneralNames(sansGeneralNames));
- } catch (IOException ioe) {
- CmpClientException cmpClientException =
- new CmpClientException(
- "Exception occurred while creating extensions for PKIMessage", ioe);
- LOG.error("Exception occurred while creating extensions for PKIMessage");
- throw cmpClientException;
- }
- return extGenerator.generate();
- }
-
- public static GeneralName[] getGeneralNames(List<String> sansList) {
- final List<GeneralName> nameList = new ArrayList<>();
- for (String san : sansList) {
- nameList.add(new GeneralName(GeneralName.dNSName, san));
- }
- final GeneralName[] sansGeneralNames = new GeneralName[nameList.size()];
- nameList.toArray(sansGeneralNames);
- return sansGeneralNames;
- }
-
- /**
- * Method generates Proof-of-Possession (POP) of Private Key. To allow a CA/RA to properly
- * validity binding between an End Entity and a Key Pair, the PKI Operations specified here make
- * it possible for an End Entity to prove that it has possession of the Private Key corresponding
- * to the Public Key for which a Certificate is requested.
- *
- * @param certRequest Certificate request that requires proof of possession
- * @param keypair keypair associated with the subject sending the certificate request
- * @return {@link ProofOfPossession}.
- * @throws CmpClientException A general-purpose Cmp client exception.
- */
- public static ProofOfPossession generateProofOfPossession(
- final CertRequest certRequest, final KeyPair keypair) throws CmpClientException {
- ProofOfPossession proofOfPossession;
- try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
- final DEROutputStream derOutputStream = new DEROutputStream(byteArrayOutputStream);
- derOutputStream.writeObject(certRequest);
-
- byte[] popoProtectionBytes = byteArrayOutputStream.toByteArray();
- final String sigalg = PKCSObjectIdentifiers.sha256WithRSAEncryption.getId();
- final Signature signature = Signature.getInstance(sigalg, BouncyCastleProvider.PROVIDER_NAME);
- signature.initSign(keypair.getPrivate());
- signature.update(popoProtectionBytes);
- DERBitString bs = new DERBitString(signature.sign());
-
- proofOfPossession =
- new ProofOfPossession(
- new POPOSigningKey(
- null, new AlgorithmIdentifier(new ASN1ObjectIdentifier(sigalg)), bs));
- } catch (IOException
- | NoSuchProviderException
- | NoSuchAlgorithmException
- | InvalidKeyException
- | SignatureException ex) {
- CmpClientException cmpClientException =
- new CmpClientException(
- "Exception occurred while creating proof of possession for PKIMessage", ex);
- LOG.error("Exception occurred while creating proof of possession for PKIMessage");
- throw cmpClientException;
- }
- return proofOfPossession;
- }
-
- /**
- * Generic code to create Algorithm Identifier for protection of PKIMessage.
- *
- * @return Algorithm Identifier
- */
- public static AlgorithmIdentifier protectionAlgoIdentifier(int iterations, byte[] salt) {
- ASN1Integer iteration = new ASN1Integer(iterations);
- DEROctetString derSalt = new DEROctetString(salt);
-
- PBMParameter pp = new PBMParameter(derSalt, OWF_ALGORITHM, iteration, MAC_ALGORITHM);
- return new AlgorithmIdentifier(PASSWORD_BASED_MAC, pp);
- }
-
- /**
- * Adds protection to the PKIMessage via a specified protection algorithm.
- *
- * @param password password used to authenticate PkiMessage with external CA
- * @param pkiHeader Header of PKIMessage containing generic details for any PKIMessage
- * @param pkiBody Body of PKIMessage containing specific details for certificate request
- * @return Protected Pki Message
- * @throws CmpClientException Wraps several exceptions into one general-purpose exception.
- */
- public static PKIMessage protectPkiMessage(
- PKIHeader pkiHeader, PKIBody pkiBody, String password, int iterations, byte[] salt)
- throws CmpClientException {
-
- byte[] raSecret = password.getBytes();
- byte[] basekey = new byte[raSecret.length + salt.length];
- System.arraycopy(raSecret, 0, basekey, 0, raSecret.length);
- System.arraycopy(salt, 0, basekey, raSecret.length, salt.length);
- byte[] out;
- try {
- MessageDigest dig =
- MessageDigest.getInstance(
- OWF_ALGORITHM.getAlgorithm().getId(), BouncyCastleProvider.PROVIDER_NAME);
- for (int i = 0; i < iterations; i++) {
- basekey = dig.digest(basekey);
- dig.reset();
- }
- byte[] protectedBytes = generateProtectedBytes(pkiHeader, pkiBody);
- Mac mac =
- Mac.getInstance(MAC_ALGORITHM.getAlgorithm().getId(), BouncyCastleProvider.PROVIDER_NAME);
- SecretKey key = new SecretKeySpec(basekey, MAC_ALGORITHM.getAlgorithm().getId());
- mac.init(key);
- mac.reset();
- mac.update(protectedBytes, 0, protectedBytes.length);
- out = mac.doFinal();
- } catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidKeyException ex) {
- CmpClientException cmpClientException =
- new CmpClientException(
- "Exception occurred while generating proof of possession for PKIMessage", ex);
- LOG.error("Exception occured while generating the proof of possession for PKIMessage");
- throw cmpClientException;
- }
- DERBitString bs = new DERBitString(out);
-
- return new PKIMessage(pkiHeader, pkiBody, bs);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseHelper.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseHelper.java
deleted file mode 100644
index 3cb0b0c5..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseHelper.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.cert.CertPath;
-import java.security.cert.CertPathValidator;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.CertificateParsingException;
-import java.security.cert.PKIXCertPathChecker;
-import java.security.cert.PKIXCertPathValidatorResult;
-import java.security.cert.PKIXParameters;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-import org.bouncycastle.asn1.cmp.CMPCertificate;
-import org.bouncycastle.asn1.cmp.CertRepMessage;
-import org.bouncycastle.asn1.cmp.ErrorMsgContent;
-import org.bouncycastle.asn1.cmp.PKIBody;
-import org.bouncycastle.asn1.cmp.PKIMessage;
-import org.bouncycastle.asn1.x500.X500Name;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.onap.aaf.certservice.cmpv2client.exceptions.PkiErrorException;
-import org.onap.aaf.certservice.cmpv2client.model.Cmpv2CertificationModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class CmpResponseHelper {
-
- private static final Logger LOG = LoggerFactory.getLogger(CmpResponseHelper.class);
-
- private CmpResponseHelper() {
- }
-
- static void checkIfCmpResponseContainsError(PKIMessage respPkiMessage)
- throws CmpClientException {
- if (respPkiMessage.getBody().getType() == PKIBody.TYPE_ERROR) {
- final ErrorMsgContent errorMsgContent =
- (ErrorMsgContent) respPkiMessage.getBody().getContent();
- PkiErrorException pkiErrorException =
- new PkiErrorException(
- errorMsgContent.getPKIStatusInfo().getStatusString().getStringAt(0).getString());
- CmpClientException cmpClientException =
- new CmpClientException("Error in the PkiMessage response", pkiErrorException);
- LOG.error("Error in the PkiMessage response: {} ", pkiErrorException.getMessage());
- throw cmpClientException;
- }
- }
-
-
- /**
- * Puts together certChain and Trust store and verifies the certChain
- *
- * @param respPkiMessage PKIMessage that may contain extra certs used for certchain
- * @param certRepMessage CertRepMessage that should contain rootCA for certchain
- * @param leafCertificate certificate returned from our original Cert Request
- * @return model for certification containing certificate chain and trusted certificates
- * @throws CertificateParsingException thrown if error occurs while parsing certificate
- * @throws IOException thrown if IOException occurs while parsing certificate
- * @throws CmpClientException thrown if error occurs during the verification of the certChain
- */
- static Cmpv2CertificationModel verifyAndReturnCertChainAndTrustSTore(
- PKIMessage respPkiMessage, CertRepMessage certRepMessage, X509Certificate leafCertificate)
- throws CertificateParsingException, IOException, CmpClientException {
- Map<X500Name, X509Certificate> certificates = mapAllCertificates(respPkiMessage, certRepMessage);
- return extractCertificationModel(certificates, leafCertificate);
- }
-
- private static Map<X500Name, X509Certificate> mapAllCertificates(
- PKIMessage respPkiMessage, CertRepMessage certRepMessage
- )
- throws IOException, CertificateParsingException, CmpClientException {
-
- Map<X500Name, X509Certificate> certificates = new HashMap<>();
-
- CMPCertificate[] extraCerts = respPkiMessage.getExtraCerts();
- certificates.putAll(mapCertificates(extraCerts));
-
- CMPCertificate[] caPubsCerts = certRepMessage.getCaPubs();
- certificates.putAll(mapCertificates(caPubsCerts));
-
- return certificates;
- }
-
- private static Map<X500Name, X509Certificate> mapCertificates(
- CMPCertificate[] cmpCertificates)
- throws CertificateParsingException, CmpClientException, IOException {
-
- Map<X500Name, X509Certificate> certificates = new HashMap<>();
- if (cmpCertificates != null) {
- for (CMPCertificate certificate : cmpCertificates) {
- getCertFromByteArray(certificate.getEncoded(), X509Certificate.class)
- .ifPresent(x509Certificate ->
- certificates.put(extractSubjectDn(x509Certificate), x509Certificate)
- );
- }
- }
-
- return certificates;
- }
-
- private static Cmpv2CertificationModel extractCertificationModel(
- Map<X500Name, X509Certificate> certificates, X509Certificate leafCertificate
- )
- throws CmpClientException {
- List<X509Certificate> certificateChain = new ArrayList<>();
- X509Certificate previousCertificateInChain;
- X509Certificate nextCertificateInChain = leafCertificate;
- do {
- certificateChain.add(nextCertificateInChain);
- certificates.remove(extractSubjectDn(nextCertificateInChain));
- previousCertificateInChain = nextCertificateInChain;
- nextCertificateInChain = certificates.get(extractIssuerDn(nextCertificateInChain));
- verify(previousCertificateInChain, nextCertificateInChain, null);
- }
- while (!isSelfSign(nextCertificateInChain));
- List<X509Certificate> trustedCertificates = new ArrayList<>(certificates.values());
-
- return new Cmpv2CertificationModel(certificateChain, trustedCertificates);
- }
-
- private static boolean isSelfSign(X509Certificate certificate) {
- return extractIssuerDn(certificate).equals(extractSubjectDn(certificate));
- }
-
- private static X500Name extractIssuerDn(X509Certificate x509Certificate) {
- return X500Name.getInstance(x509Certificate.getIssuerDN());
- }
-
- private static X500Name extractSubjectDn(X509Certificate x509Certificate) {
- return X500Name.getInstance(x509Certificate.getSubjectDN());
- }
-
-
- /**
- * Check the certificate with CA certificate.
- *
- * @param certificate X.509 certificate to verify. May not be null.
- * @param caCertChain Collection of X509Certificates. May not be null, an empty list or a
- * Collection with null entries.
- * @param date Date to verify at, or null to use current time.
- * @param pkixCertPathCheckers optional PKIXCertPathChecker implementations to use during cert
- * path validation
- * @throws CmpClientException if certificate could not be validated
- */
- private static void verify(
- X509Certificate certificate,
- X509Certificate caCertChain,
- Date date,
- PKIXCertPathChecker... pkixCertPathCheckers)
- throws CmpClientException {
- try {
- verifyCertificates(certificate, caCertChain, date, pkixCertPathCheckers);
- } catch (CertPathValidatorException cpve) {
- CmpClientException cmpClientException =
- new CmpClientException(
- "Invalid certificate or certificate not issued by specified CA: ", cpve);
- LOG.error("Invalid certificate or certificate not issued by specified CA: ", cpve);
- throw cmpClientException;
- } catch (CertificateException ce) {
- CmpClientException cmpClientException =
- new CmpClientException("Something was wrong with the supplied certificate", ce);
- LOG.error("Something was wrong with the supplied certificate", ce);
- throw cmpClientException;
- } catch (NoSuchProviderException nspe) {
- CmpClientException cmpClientException =
- new CmpClientException("BouncyCastle provider not found.", nspe);
- LOG.error("BouncyCastle provider not found.", nspe);
- throw cmpClientException;
- } catch (NoSuchAlgorithmException nsae) {
- CmpClientException cmpClientException =
- new CmpClientException("Algorithm PKIX was not found.", nsae);
- LOG.error("Algorithm PKIX was not found.", nsae);
- throw cmpClientException;
- } catch (InvalidAlgorithmParameterException iape) {
- CmpClientException cmpClientException =
- new CmpClientException(
- "Either ca certificate chain was empty,"
- + " or the certificate was on an inappropriate type for a PKIX path checker.",
- iape);
- LOG.error(
- "Either ca certificate chain was empty, "
- + "or the certificate was on an inappropriate type for a PKIX path checker.",
- iape);
- throw cmpClientException;
- }
- }
-
- private static void verifyCertificates(
- X509Certificate certificate,
- X509Certificate caCertChain,
- Date date,
- PKIXCertPathChecker[] pkixCertPathCheckers)
- throws CertificateException, NoSuchProviderException, InvalidAlgorithmParameterException,
- NoSuchAlgorithmException, CertPathValidatorException {
- if (caCertChain == null) {
- final String noRootCaCertificateMessage = "Server response does not contain proper root CA certificate";
- throw new CertificateException(noRootCaCertificateMessage);
- }
- LOG.debug(
- "Verifying certificate {} as part of cert chain with certificate {}",
- certificate.getSubjectDN().getName(),
- caCertChain.getSubjectDN().getName());
- CertPath cp = getCertPath(certificate);
- PKIXParameters params = getPkixParameters(caCertChain, date, pkixCertPathCheckers);
- CertPathValidator cpv =
- CertPathValidator.getInstance("PKIX", BouncyCastleProvider.PROVIDER_NAME);
- PKIXCertPathValidatorResult result = (PKIXCertPathValidatorResult) cpv.validate(cp, params);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Certificate verify result:{} ", result);
- }
- }
-
- private static PKIXParameters getPkixParameters(
- X509Certificate caCertChain, Date date, PKIXCertPathChecker[] pkixCertPathCheckers)
- throws InvalidAlgorithmParameterException {
- TrustAnchor anchor = new TrustAnchor(caCertChain, null);
- PKIXParameters params = new PKIXParameters(Collections.singleton(anchor));
- for (final PKIXCertPathChecker pkixCertPathChecker : pkixCertPathCheckers) {
- params.addCertPathChecker(pkixCertPathChecker);
- }
- params.setRevocationEnabled(false);
- params.setDate(date);
- return params;
- }
-
- private static CertPath getCertPath(X509Certificate certificate)
- throws CertificateException, NoSuchProviderException {
- ArrayList<X509Certificate> certlist = new ArrayList<>();
- certlist.add(certificate);
- return CertificateFactory.getInstance("X.509", BouncyCastleProvider.PROVIDER_NAME)
- .generateCertPath(certlist);
- }
-
- /**
- * Returns a CertificateFactory that can be used to create certificates from byte arrays and such.
- *
- * @param provider Security provider that should be used to create certificates, default BC is
- * null is passed.
- * @return CertificateFactory for creating certificate
- */
- private static CertificateFactory getCertificateFactory(final String provider)
- throws CmpClientException {
- LOG.debug("Creating certificate Factory to generate certificate using provider {}", provider);
- final String prov;
- prov = Objects.requireNonNullElse(provider, BouncyCastleProvider.PROVIDER_NAME);
- try {
- return CertificateFactory.getInstance("X.509", prov);
- } catch (NoSuchProviderException nspe) {
- CmpClientException cmpClientException = new CmpClientException("NoSuchProvider: ", nspe);
- LOG.error("NoSuchProvider: ", nspe);
- throw cmpClientException;
- } catch (CertificateException ce) {
- CmpClientException cmpClientException = new CmpClientException("CertificateException: ", ce);
- LOG.error("CertificateException: ", ce);
- throw cmpClientException;
- }
- }
-
- /**
- * @param cert byte array that contains certificate
- * @param returnType the type of Certificate to be returned, for example X509Certificate.class.
- * Certificate.class can be used if certificate type is unknown.
- * @throws CertificateParsingException if the byte array does not contain a proper certificate.
- */
- static <T extends Certificate> Optional<X509Certificate> getCertFromByteArray(
- byte[] cert, Class<T> returnType) throws CertificateParsingException, CmpClientException {
- LOG.debug("Retrieving certificate of type {} from byte array.", returnType);
- String prov = BouncyCastleProvider.PROVIDER_NAME;
-
- if (returnType.equals(X509Certificate.class)) {
- return parseX509Certificate(prov, cert);
- } else {
- LOG.debug("Certificate of type {} was skipped, because type of certificate is not 'X509Certificate'.", returnType);
- return Optional.empty();
- }
- }
-
-
- /**
- * Parse a X509Certificate from an array of bytes
- *
- * @param provider a provider name
- * @param cert a byte array containing an encoded certificate
- * @return a decoded X509Certificate
- * @throws CertificateParsingException if the byte array wasn't valid, or contained a certificate
- * other than an X509 Certificate.
- */
- private static Optional<X509Certificate> parseX509Certificate(String provider, byte[] cert)
- throws CertificateParsingException, CmpClientException {
- LOG.debug("Parsing X509Certificate from bytes with provider {}", provider);
- final CertificateFactory cf = getCertificateFactory(provider);
- X509Certificate result;
- try {
- result = (X509Certificate) Objects.requireNonNull(cf).generateCertificate(new ByteArrayInputStream(cert));
- return Optional.ofNullable(result);
- } catch (CertificateException ce) {
- throw new CertificateParsingException("Could not parse byte array as X509Certificate ", ce);
- }
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseValidationHelper.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseValidationHelper.java
deleted file mode 100644
index 4b9f2cd1..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseValidationHelper.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PublicKey;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.util.Arrays;
-import java.util.Objects;
-import javax.crypto.Mac;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.bouncycastle.asn1.ASN1Encodable;
-import org.bouncycastle.asn1.ASN1EncodableVector;
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
-import org.bouncycastle.asn1.DERBitString;
-import org.bouncycastle.asn1.DEROutputStream;
-import org.bouncycastle.asn1.DERSequence;
-import org.bouncycastle.asn1.cmp.CMPObjectIdentifiers;
-import org.bouncycastle.asn1.cmp.InfoTypeAndValue;
-import org.bouncycastle.asn1.cmp.PBMParameter;
-import org.bouncycastle.asn1.cmp.PKIBody;
-import org.bouncycastle.asn1.cmp.PKIHeader;
-import org.bouncycastle.asn1.cmp.PKIMessage;
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class CmpResponseValidationHelper {
-
- private static final Logger LOG = LoggerFactory.getLogger(CmpResponseValidationHelper.class);
-
- private CmpResponseValidationHelper() {
- }
-
- /**
- * Create a base key to use for verifying the PasswordBasedMac on a PKIMessage
- *
- * @param pbmParamSeq parameters recieved in PKIMessage used with password
- * @param initAuthPassword password used to decrypt the basekey
- * @return bytes representing the basekey
- * @throws CmpClientException thrown if algorithem exceptions occur for the message digest
- */
- public static byte[] getBaseKeyFromPbmParameters(
- PBMParameter pbmParamSeq, String initAuthPassword) throws CmpClientException {
- final int iterationCount = pbmParamSeq.getIterationCount().getPositiveValue().intValue();
- LOG.info("Iteration count is: {}", iterationCount);
- final AlgorithmIdentifier owfAlg = pbmParamSeq.getOwf();
- LOG.info("One Way Function type is: {}", owfAlg.getAlgorithm().getId());
- final byte[] salt = pbmParamSeq.getSalt().getOctets();
- final byte[] raSecret = initAuthPassword != null ? initAuthPassword.getBytes() : new byte[0];
- byte[] basekey = new byte[raSecret.length + salt.length];
- System.arraycopy(raSecret, 0, basekey, 0, raSecret.length);
- System.arraycopy(salt, 0, basekey, raSecret.length, salt.length);
- try {
- final MessageDigest messageDigest =
- MessageDigest.getInstance(
- owfAlg.getAlgorithm().getId(), BouncyCastleProvider.PROVIDER_NAME);
- for (int i = 0; i < iterationCount; i++) {
- basekey = messageDigest.digest(basekey);
- messageDigest.reset();
- }
- } catch (NoSuchAlgorithmException | NoSuchProviderException ex) {
- LOG.error("ProtectionBytes don't match passwordBasedProtection, authentication failed");
- throw new CmpClientException(
- "ProtectionBytes don't match passwordBasedProtection, authentication failed", ex);
- }
- return basekey;
- }
-
- /**
- * Verifies the signature of the response message using our public key
- *
- * @param respPkiMessage PKIMessage we wish to verify signature for
- * @param pk public key used to verify signature.
- * @throws CmpClientException
- */
- public static void verifySignature(PKIMessage respPkiMessage, PublicKey pk)
- throws CmpClientException {
- final byte[] protBytes = getProtectedBytes(respPkiMessage);
- final DERBitString derBitString = respPkiMessage.getProtection();
- try {
- final Signature signature =
- Signature.getInstance(
- PKCSObjectIdentifiers.sha256WithRSAEncryption.getId(),
- BouncyCastleProvider.PROVIDER_NAME);
- signature.initVerify(pk);
- signature.update(protBytes);
- signature.verify(derBitString.getBytes());
- } catch (NoSuchAlgorithmException
- | NoSuchProviderException
- | InvalidKeyException
- | SignatureException e) {
- CmpClientException clientException =
- new CmpClientException("Signature Verification failed", e);
- LOG.error("Signature Verification failed", e);
- throw clientException;
- }
- }
-
- /**
- * Converts the header and the body of a PKIMessage to an ASN1Encodable and returns the as a byte
- * array
- *
- * @param msg PKIMessage to get protected bytes from
- * @return the PKIMessage's header and body in byte array
- */
- public static byte[] getProtectedBytes(PKIMessage msg) throws CmpClientException {
- return getProtectedBytes(msg.getHeader(), msg.getBody());
- }
-
- /**
- * Converts the header and the body of a PKIMessage to an ASN1Encodable and returns the as a byte
- * array
- *
- * @param header PKIHeader to be converted
- * @param body PKIMessage to be converted
- * @return the PKIMessage's header and body in byte array
- */
- public static byte[] getProtectedBytes(PKIHeader header, PKIBody body) throws CmpClientException {
- byte[] res;
- ASN1EncodableVector encodableVector = new ASN1EncodableVector();
- encodableVector.add(header);
- encodableVector.add(body);
- ASN1Encodable protectedPart = new DERSequence(encodableVector);
- try {
- ByteArrayOutputStream bao = new ByteArrayOutputStream();
- DEROutputStream out = new DEROutputStream(bao);
- out.writeObject(protectedPart);
- res = bao.toByteArray();
- } catch (IOException ioe) {
- CmpClientException cmpClientException =
- new CmpClientException("Error occured while getting protected bytes", ioe);
- LOG.error("Error occured while getting protected bytes", ioe);
- throw cmpClientException;
- }
- return res;
- }
-
- /**
- * verify the password based protection within the response message
- *
- * @param respPkiMessage PKIMessage we want to verify password based protection for
- * @param initAuthPassword password used to decrypt protection
- * @param protectionAlgo protection algorithm we can use to decrypt protection
- * @throws CmpClientException
- */
- public static void verifyPasswordBasedProtection(
- PKIMessage respPkiMessage, String initAuthPassword, AlgorithmIdentifier protectionAlgo)
- throws CmpClientException {
- final byte[] protectedBytes = getProtectedBytes(respPkiMessage);
- final PBMParameter pbmParamSeq = PBMParameter.getInstance(protectionAlgo.getParameters());
- if (Objects.nonNull(pbmParamSeq)) {
- try {
- byte[] basekey = getBaseKeyFromPbmParameters(pbmParamSeq, initAuthPassword);
- final Mac mac = getMac(protectedBytes, pbmParamSeq, basekey);
- final byte[] outBytes = mac.doFinal();
- final byte[] protectionBytes = respPkiMessage.getProtection().getBytes();
- if (!Arrays.equals(outBytes, protectionBytes)) {
- LOG.error("protectionBytes don't match passwordBasedProtection, authentication failed");
- throw new CmpClientException(
- "protectionBytes don't match passwordBasedProtection, authentication failed");
- }
- } catch (NoSuchProviderException | NoSuchAlgorithmException | InvalidKeyException ex) {
- CmpClientException cmpClientException =
- new CmpClientException("Error while validating CMP response ", ex);
- LOG.error("Error while validating CMP response ", ex);
- throw cmpClientException;
- }
- }
- }
-
- public static void checkImplicitConfirm(PKIHeader header) {
- InfoTypeAndValue[] infos = header.getGeneralInfo();
- if (Objects.nonNull(infos)) {
- if (CMPObjectIdentifiers.it_implicitConfirm.equals(getImplicitConfirm(infos))) {
- LOG.info("Implicit Confirm on certificate from server.");
- } else {
- LOG.debug("No Implicit confirm in Response");
- }
- } else {
- LOG.debug("No general Info in header of response, cannot verify implicit confirm");
- }
- }
-
- public static ASN1ObjectIdentifier getImplicitConfirm(InfoTypeAndValue[] info) {
- return info[0].getInfoType();
- }
-
- /**
- * Get cryptographical Mac we can use to decrypt our PKIMessage
- *
- * @param protectedBytes Protected bytes representing the PKIMessage
- * @param pbmParamSeq Parameters used to decrypt PKIMessage, including mac algorithm used
- * @param basekey Key used alongside mac Oid to create secret key for decrypting PKIMessage
- * @return Mac that's ready to return decrypted bytes
- * @throws NoSuchAlgorithmException Possibly thrown trying to get mac instance
- * @throws NoSuchProviderException Possibly thrown trying to get mac instance
- * @throws InvalidKeyException Possibly thrown trying to initialize mac using secretkey
- */
- public static Mac getMac(byte[] protectedBytes, PBMParameter pbmParamSeq, byte[] basekey)
- throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException {
- final AlgorithmIdentifier macAlg = pbmParamSeq.getMac();
- LOG.info("Mac type is: {}", macAlg.getAlgorithm().getId());
- final String macOid = macAlg.getAlgorithm().getId();
- final Mac mac = Mac.getInstance(macOid, BouncyCastleProvider.PROVIDER_NAME);
- final SecretKey key = new SecretKeySpec(basekey, macOid);
- mac.init(key);
- mac.reset();
- mac.update(protectedBytes, 0, protectedBytes.length);
- return mac;
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpUtil.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpUtil.java
deleted file mode 100644
index ced0fed0..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpUtil.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.SecureRandom;
-import java.util.Date;
-import java.util.Objects;
-
-import org.bouncycastle.asn1.ASN1Encodable;
-import org.bouncycastle.asn1.ASN1EncodableVector;
-import org.bouncycastle.asn1.ASN1GeneralizedTime;
-import org.bouncycastle.asn1.DEROctetString;
-import org.bouncycastle.asn1.DEROutputStream;
-import org.bouncycastle.asn1.DERSequence;
-import org.bouncycastle.asn1.cmp.CMPObjectIdentifiers;
-import org.bouncycastle.asn1.cmp.InfoTypeAndValue;
-import org.bouncycastle.asn1.cmp.PKIBody;
-import org.bouncycastle.asn1.cmp.PKIHeader;
-import org.bouncycastle.asn1.cmp.PKIHeaderBuilder;
-import org.bouncycastle.asn1.x500.X500Name;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.asn1.x509.GeneralName;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class CmpUtil {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CmpUtil.class);
- private static final SecureRandom SECURE_RANDOM = new SecureRandom();
- public static final int RANDOM_BYTE_LENGTH = 16;
- public static final int RANDOM_SEED = 1000;
-
- private CmpUtil() {
- }
-
- /**
- * Validates specified object reference is not null.
- *
- * @param argument T - the type of the reference.
- * @param message message - detail message to be used in the event that a NullPointerException is
- * thrown.
- * @return The Object if not null
- */
- public static <T> T notNull(T argument, String message) {
- return Objects.requireNonNull(argument, message + " must not be null");
- }
-
- /**
- * Validates String object reference is not null and not empty.
- *
- * @param stringArg String Object that need to be validated.
- * @return boolean
- */
- public static boolean isNullOrEmpty(String stringArg) {
- return (stringArg != null && !stringArg.trim().isEmpty());
- }
-
- /**
- * Creates a random number than can be used for sendernonce, transactionId and salts.
- *
- * @return bytes containing a random number string representing a nonce
- */
- static byte[] createRandomBytes() {
- LOGGER.info("Generating random array of bytes");
- byte[] randomBytes = new byte[RANDOM_BYTE_LENGTH];
- SECURE_RANDOM.nextBytes(randomBytes);
- return randomBytes;
- }
-
- /**
- * Creates a random integer than can be used to represent a transactionId or determine the number
- * iterations in a protection algorithm.
- *
- * @return bytes containing a random number string representing a nonce
- */
- static int createRandomInt(int range) {
- LOGGER.info("Generating random integer");
- return SECURE_RANDOM.nextInt(range) + RANDOM_SEED;
- }
-
- /**
- * Generates protected bytes of a combined PKIHeader and PKIBody.
- *
- * @param header Header of PKIMessage containing common parameters
- * @param body Body of PKIMessage containing specific information for message
- * @return bytes representing the PKIHeader and PKIBody thats to be protected
- */
- static byte[] generateProtectedBytes(PKIHeader header, PKIBody body) throws CmpClientException {
- LOGGER.info("Generating array of bytes representing PkiHeader and PkiBody");
- byte[] res;
- ASN1EncodableVector vector = new ASN1EncodableVector();
- vector.add(header);
- vector.add(body);
- ASN1Encodable protectedPart = new DERSequence(vector);
- try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
- DEROutputStream out = new DEROutputStream(baos);
- out.writeObject(protectedPart);
- res = baos.toByteArray();
- } catch (IOException ioe) {
- CmpClientException cmpClientException =
- new CmpClientException("IOException occurred while creating protectedBytes", ioe);
- LOGGER.error("IOException occurred while creating protectedBytes");
- throw cmpClientException;
- }
- return res;
- }
-
- /**
- * Generates a PKIHeader Builder object.
- *
- * @param subjectDn distinguished name of Subject
- * @param issuerDn distinguished name of external CA
- * @param protectionAlg protection Algorithm used to protect PKIMessage
- * @return PKIHeaderBuilder
- */
- static PKIHeader generatePkiHeader(
- X500Name subjectDn, X500Name issuerDn, AlgorithmIdentifier protectionAlg, String senderKid) {
- LOGGER.info("Generating a Pki Header Builder");
- PKIHeaderBuilder pkiHeaderBuilder =
- new PKIHeaderBuilder(
- PKIHeader.CMP_2000, new GeneralName(subjectDn), new GeneralName(issuerDn));
-
- pkiHeaderBuilder.setMessageTime(new ASN1GeneralizedTime(new Date()));
- pkiHeaderBuilder.setSenderNonce(new DEROctetString(createRandomBytes()));
- pkiHeaderBuilder.setTransactionID(new DEROctetString(createRandomBytes()));
- pkiHeaderBuilder.setProtectionAlg(protectionAlg);
- pkiHeaderBuilder.setGeneralInfo(new InfoTypeAndValue(CMPObjectIdentifiers.it_implicitConfirm));
- pkiHeaderBuilder.setSenderKID(new DEROctetString(senderKid.getBytes()));
-
- return pkiHeaderBuilder.build();
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/Cmpv2HttpClient.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/Cmpv2HttpClient.java
deleted file mode 100644
index 68c743d2..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/Cmpv2HttpClient.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.bouncycastle.asn1.cmp.PKIMessage;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class Cmpv2HttpClient {
-
- private static final Logger LOG = LoggerFactory.getLogger(Cmpv2HttpClient.class);
-
- private static final String CONTENT_TYPE = "Content-type";
- private static final String CMP_REQUEST_MIMETYPE = "application/pkixcmp";
- private final CloseableHttpClient httpClient;
-
- /**
- * constructor for Cmpv2HttpClient
- *
- * @param httpClient CloseableHttpClient used for sending/recieve request.
- */
- Cmpv2HttpClient(CloseableHttpClient httpClient) {
- this.httpClient = httpClient;
- }
-
- /**
- * Send Post Request to Server
- *
- * @param pkiMessage PKIMessage to send to server
- * @param urlString url for the server we're sending request
- * @param caName name of CA server
- * @return PKIMessage received from CMPServer
- * @throws CmpClientException thrown if problems with connecting or parsing response to server
- */
- public byte[] postRequest(
- final PKIMessage pkiMessage, final String urlString, final String caName)
- throws CmpClientException {
- try (ByteArrayOutputStream byteArrOutputStream = new ByteArrayOutputStream()) {
- final HttpPost postRequest = new HttpPost(urlString);
- final byte[] requestBytes = pkiMessage.getEncoded();
-
- postRequest.setEntity(new ByteArrayEntity(requestBytes));
- postRequest.setHeader(CONTENT_TYPE, CMP_REQUEST_MIMETYPE);
-
- try (CloseableHttpResponse response = httpClient.execute(postRequest)) {
- response.getEntity().writeTo(byteArrOutputStream);
- }
- return byteArrOutputStream.toByteArray();
- } catch (IOException ioe) {
- CmpClientException cmpClientException =
- new CmpClientException(
- String.format("IOException error while trying to connect CA %s", caName), ioe);
- LOG.error("IOException error {}, while trying to connect CA {}", ioe.getMessage(), caName);
- throw cmpClientException;
- }
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CreateCertRequest.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CreateCertRequest.java
deleted file mode 100644
index 74380d84..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CreateCertRequest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpUtil.createRandomBytes;
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpUtil.createRandomInt;
-import static org.onap.aaf.certservice.cmpv2client.impl.CmpUtil.generatePkiHeader;
-
-import java.security.KeyPair;
-import java.util.Date;
-import java.util.List;
-
-import org.bouncycastle.asn1.cmp.PKIBody;
-import org.bouncycastle.asn1.cmp.PKIHeader;
-import org.bouncycastle.asn1.cmp.PKIMessage;
-import org.bouncycastle.asn1.crmf.CertReqMessages;
-import org.bouncycastle.asn1.crmf.CertReqMsg;
-import org.bouncycastle.asn1.crmf.CertRequest;
-import org.bouncycastle.asn1.crmf.CertTemplateBuilder;
-import org.bouncycastle.asn1.crmf.ProofOfPossession;
-import org.bouncycastle.asn1.x500.X500Name;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-
-/**
- * Implementation of the CmpClient Interface conforming to RFC4210 (Certificate Management Protocol
- * (CMP)) and RFC4211 (Certificate Request Message Format (CRMF)) standards.
- */
-class CreateCertRequest {
-
- private X500Name issuerDn;
- private X500Name subjectDn;
- private List<String> sansList;
- private KeyPair subjectKeyPair;
- private Date notBefore;
- private Date notAfter;
- private String initAuthPassword;
- private String senderKid;
-
- private static final int ITERATIONS = createRandomInt(5000);
- private static final byte[] SALT = createRandomBytes();
- private final int certReqId = createRandomInt(Integer.MAX_VALUE);
-
- public void setIssuerDn(X500Name issuerDn) {
- this.issuerDn = issuerDn;
- }
-
- public void setSubjectDn(X500Name subjectDn) {
- this.subjectDn = subjectDn;
- }
-
- public void setSansList(List<String> sansList) {
- this.sansList = sansList;
- }
-
- public void setSubjectKeyPair(KeyPair subjectKeyPair) {
- this.subjectKeyPair = subjectKeyPair;
- }
-
- public void setNotBefore(Date notBefore) {
- this.notBefore = notBefore;
- }
-
- public void setNotAfter(Date notAfter) {
- this.notAfter = notAfter;
- }
-
- public void setInitAuthPassword(String initAuthPassword) {
- this.initAuthPassword = initAuthPassword;
- }
-
- public void setSenderKid(String senderKid) {
- this.senderKid = senderKid;
- }
-
- /**
- * Method to create {@link PKIMessage} from {@link CertRequest},{@link ProofOfPossession}, {@link
- * CertReqMsg}, {@link CertReqMessages}, {@link PKIHeader} and {@link PKIBody}.
- *
- * @return {@link PKIMessage}
- */
- public PKIMessage generateCertReq() throws CmpClientException {
- final CertTemplateBuilder certTemplateBuilder =
- new CertTemplateBuilder()
- .setIssuer(issuerDn)
- .setSubject(subjectDn)
- .setExtensions(CmpMessageHelper.generateExtension(sansList))
- .setValidity(CmpMessageHelper.generateOptionalValidity(notBefore, notAfter))
- .setPublicKey(
- SubjectPublicKeyInfo.getInstance(subjectKeyPair.getPublic().getEncoded()));
-
- final CertRequest certRequest = new CertRequest(certReqId, certTemplateBuilder.build(), null);
- final ProofOfPossession proofOfPossession =
- CmpMessageHelper.generateProofOfPossession(certRequest, subjectKeyPair);
-
- final CertReqMsg certReqMsg = new CertReqMsg(certRequest, proofOfPossession, null);
- final CertReqMessages certReqMessages = new CertReqMessages(certReqMsg);
-
- final PKIHeader pkiHeader =
- generatePkiHeader(
- subjectDn,
- issuerDn,
- CmpMessageHelper.protectionAlgoIdentifier(ITERATIONS, SALT),
- senderKid);
- final PKIBody pkiBody = new PKIBody(PKIBody.TYPE_INIT_REQ, certReqMessages);
-
- return CmpMessageHelper.protectPkiMessage(
- pkiHeader, pkiBody, initAuthPassword, ITERATIONS, SALT);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/model/Cmpv2CertificationModel.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/model/Cmpv2CertificationModel.java
deleted file mode 100644
index 5d48b978..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/model/Cmpv2CertificationModel.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.model;
-
-import java.security.cert.X509Certificate;
-import java.util.Collections;
-import java.util.List;
-
-public class Cmpv2CertificationModel {
-
- private final List<X509Certificate> certificateChain;
- private final List<X509Certificate> trustedCertificates;
-
- public Cmpv2CertificationModel(List<X509Certificate> certificateChain, List<X509Certificate> trustedCertificates) {
- this.certificateChain = certificateChain;
- this.trustedCertificates = trustedCertificates;
- }
-
- public List<X509Certificate> getCertificateChain() {
- return Collections.unmodifiableList(certificateChain);
- }
-
- public List<X509Certificate> getTrustedCertificates() {
- return Collections.unmodifiableList(trustedCertificates);
- }
-}
diff --git a/certService/src/main/resources/application.properties b/certService/src/main/resources/application.properties
deleted file mode 100644
index c5d14370..00000000
--- a/certService/src/main/resources/application.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-# Actuator configuration
-management.endpoints.enabled-by-default=true
-management.endpoint.configprops.enabled=true
-management.endpoints.web.exposure.include=health
-
-# Swagger configuration
-springdoc.show-actuator=true
-springdoc.swagger-ui.path=/docs
-
-# AAF CertService app specific configuration
-app.config.path=/etc/onap/aaf/certservice
-
-# Mutual TLS configuration
-server.ssl.enabled=true
-server.ssl.client-auth=need
-server.port=${HTTPS_PORT:8443}
-
-server.ssl.key-store=${KEYSTORE_PATH:/etc/onap/aaf/certservice/certs/certServiceServer-keystore.jks}
-server.ssl.key-store-password=${KEYSTORE_PASSWORD:secret}
-
-server.ssl.trust-store=${TRUSTSTORE_PATH:/etc/onap/aaf/certservice/certs/truststore.jks}
-server.ssl.trust-store-password=${TRUSTSTORE_PASSWORD:secret}
diff --git a/certService/src/main/resources/log4j2.xml b/certService/src/main/resources/log4j2.xml
deleted file mode 100644
index f814b4bd..00000000
--- a/certService/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<Configuration status="INFO">
-
- <Appenders>
-
- <Console name="CONSOLE" target="SYSTEM_OUT">
- <LevelRangeFilter maxLevel="DEBUG" minLevel="ERROR"/>
- <PatternLayout
- pattern="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} %highlight{${LOG_LEVEL_PATTERN:-%5p}}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=green, DEBUG=green bold, TRACE=blue} %style{${sys:PID}}{magenta} [%15.15t] %style{%-40.40C{1.}}{cyan} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
- </Console>
-
- <RollingFile fileName="var/log/onap/aaf/certservice/error.log" filePattern="logs/error-%d{yyyy-MM-dd}-%i.log" name="ERROR_LOG">
- <LevelRangeFilter maxLevel="ERROR" minLevel="ERROR"/>
- <PatternLayout pattern="[%d{ISO8601}][%-5p][%-5c] %m%n"/>
- <Policies>
- <SizeBasedTriggeringPolicy size="50 MB"/>
- </Policies>
- <DefaultRolloverStrategy max="10"/>
- </RollingFile>
-
- <RollingFile fileName="var/log/onap/aaf/certservice/debug.log" filePattern="logs/debug-%d{yyyy-MM-dd}-%i.log" name="DEBUG_LOG">
- <LevelRangeFilter maxLevel="DEBUG" minLevel="ERROR"/>
- <PatternLayout pattern="[%d{ISO8601}][%-5p][%-5c] %m%n"/>
- <Policies>
- <SizeBasedTriggeringPolicy size="50 MB"/>
- </Policies>
- </RollingFile>
-
- <RollingFile fileName="var/log/onap/aaf/certservice/audit.log" filePattern="logs/audit-%d{yyyy-MM-dd}-%i.log" name="AUDIT_LOG">
- <LevelRangeFilter maxLevel="INFO" minLevel="INFO"/>
- <PatternLayout pattern="[%d{ISO8601}][%-5p][%-5c] %m%n"/>
- <Policies>
- <SizeBasedTriggeringPolicy size="50 MB"/>
- </Policies>
- <DefaultRolloverStrategy max="10"/>
- </RollingFile>
-
- </Appenders>
-
- <Loggers>
-
- <Logger name="org.springframework" level="ERROR"/>
- <Logger name="org.springdoc" level="ERROR"/>
- <Logger name="org.hibernate" level="ERROR"/>
- <Logger name="org.apache" level="ERROR"/>
- <Logger name="io.micrometer" level="ERROR"/>
- <Logger name="io.swagger" level="ERROR"/>
-
- <Root additivity="false" level="DEBUG">
- <AppenderRef ref="CONSOLE"/>
- <AppenderRef ref="ERROR_LOG"/>
- <AppenderRef ref="DEBUG_LOG"/>
- <AppenderRef ref="AUDIT_LOG"/>
- </Root>
-
- </Loggers>
-
-</Configuration>
diff --git a/certService/src/test/java/org/onap/aaf/certservice/CertServiceApplicationTests.java b/certService/src/test/java/org/onap/aaf/certservice/CertServiceApplicationTests.java
deleted file mode 100644
index 0dc60aa5..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/CertServiceApplicationTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class CertServiceApplicationTests {
-
- @Test
- // We are excluding this line in Sonar due to fact that
- // this test checks if Spring context is loaded and does not require assertion
- void contextLoads() { // NOSONAR
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/api/CertificationControllerTest.java b/certService/src/test/java/org/onap/aaf/certservice/api/CertificationControllerTest.java
deleted file mode 100644
index 449670c3..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/api/CertificationControllerTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.aaf.certservice.certification.CertificationModelFactory;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ClientAdapterException;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException;
-import org.onap.aaf.certservice.certification.exception.CsrDecryptionException;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.exception.KeyDecryptionException;
-import org.onap.aaf.certservice.certification.model.CertificationModel;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-@ExtendWith(MockitoExtension.class)
-class CertificationControllerTest {
-
- private static final String TEST_CA_NAME = "TestCa";
- private static final String TEST_ENCODED_CSR = "encodedCSR";
- private static final String TEST_ENCODED_PK = "encodedPK";
- private static final String TEST_WRONG_ENCODED_CSR = "wrongEncodedCSR";
- private static final String TEST_WRONG_ENCODED_PK = "wrongEncodedPK";
- private static final String TEST_WRONG_CA_NAME = "wrongTestCa";
-
- private CertificationController certificationController;
-
- @Mock
- private CertificationModelFactory certificationModelFactory;
-
- @BeforeEach
- void serUp() {
- certificationController = new CertificationController(certificationModelFactory);
- }
-
- @Test
- void shouldReturnDataAboutCsrBaseOnEncodedParameters()
- throws DecryptionException, CmpClientException, Cmpv2ClientAdapterException {
- // Given
- CertificationModel testCertificationModel = new CertificationModel(
- Arrays.asList("ENTITY_CERT", "INTERMEDIATE_CERT"),
- Arrays.asList("CA_CERT", "EXTRA_CA_CERT")
- );
- when(certificationModelFactory.createCertificationModel(TEST_ENCODED_CSR, TEST_ENCODED_PK, TEST_CA_NAME))
- .thenReturn(testCertificationModel);
-
- // When
- ResponseEntity<CertificationModel> responseCertificationModel =
- certificationController.signCertificate(TEST_CA_NAME, TEST_ENCODED_CSR, TEST_ENCODED_PK);
-
- // Then
- assertEquals(HttpStatus.OK, responseCertificationModel.getStatusCode());
- assertThat(responseCertificationModel.getBody()
- ).isEqualToComparingFieldByField(testCertificationModel);
-
- }
-
- @Test
- void shouldThrowCsrDecryptionExceptionWhenCreatingCsrModelFails()
- throws DecryptionException, CmpClientException, Cmpv2ClientAdapterException {
- // Given
- String expectedMessage = "Incorrect CSR, decryption failed";
- when(certificationModelFactory.createCertificationModel(TEST_WRONG_ENCODED_CSR, TEST_ENCODED_PK, TEST_CA_NAME))
- .thenThrow(new CsrDecryptionException(expectedMessage));
-
- // When
- Exception exception = assertThrows(
- CsrDecryptionException.class, () ->
- certificationController.signCertificate(TEST_CA_NAME, TEST_WRONG_ENCODED_CSR, TEST_ENCODED_PK)
- );
-
- String actualMessage = exception.getMessage();
-
- // Then
- assertEquals(expectedMessage, actualMessage);
- }
-
- @Test
- void shouldThrowPemDecryptionExceptionWhenCreatingPemModelFails()
- throws DecryptionException, CmpClientException, Cmpv2ClientAdapterException {
- // Given
- String expectedMessage = "Incorrect PEM, decryption failed";
- when(certificationModelFactory.createCertificationModel(TEST_ENCODED_CSR, TEST_WRONG_ENCODED_PK, TEST_CA_NAME))
- .thenThrow(new KeyDecryptionException(expectedMessage));
-
- // When
- Exception exception = assertThrows(
- KeyDecryptionException.class, () ->
- certificationController.signCertificate(TEST_CA_NAME, TEST_ENCODED_CSR, TEST_WRONG_ENCODED_PK)
- );
-
- String actualMessage = exception.getMessage();
-
- // Then
- assertEquals(expectedMessage, actualMessage);
- }
-
- @Test
- void shouldThrowCmpv2ServerNotFoundWhenGivenWrongCaName()
- throws DecryptionException, CmpClientException, Cmpv2ClientAdapterException {
- // Given
- String expectedMessage = "No server found for given CA name";
- when(certificationModelFactory.createCertificationModel(TEST_ENCODED_CSR, TEST_ENCODED_PK, TEST_WRONG_CA_NAME))
- .thenThrow(new Cmpv2ServerNotFoundException(expectedMessage));
-
- // When
- Exception exception = assertThrows(
- Cmpv2ServerNotFoundException.class, () ->
- certificationController.signCertificate(TEST_WRONG_CA_NAME, TEST_ENCODED_CSR, TEST_ENCODED_PK)
- );
-
- String actualMessage = exception.getMessage();
-
- // Then
- assertEquals(expectedMessage, actualMessage);
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/api/ReadinessControllerTest.java b/certService/src/test/java/org/onap/aaf/certservice/api/ReadinessControllerTest.java
deleted file mode 100644
index d3ed7301..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/api/ReadinessControllerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.aaf.certservice.certification.configuration.CmpServersConfig;
-import org.springframework.http.HttpStatus;
-
-@ExtendWith(MockitoExtension.class)
-public class ReadinessControllerTest {
-
- @Mock
- private CmpServersConfig cmpServersConfig;
-
- @Test
- public void shouldReturnStatusOkWhenConfigIsReady() {
- // Given
- Mockito.when(cmpServersConfig.isReady()).thenReturn(true);
-
- // Then
- assertThat(new ReadinessController(cmpServersConfig).checkReady().getStatusCode()).isEqualTo(HttpStatus.OK);
- ;
- }
-
- @Test
- public void shouldReturnStatusServiceUnavailableWhenConfigIsNotReady() {
- // Given
- Mockito.when(cmpServersConfig.isReady()).thenReturn(false);
-
- // Then
- assertThat(new ReadinessController(cmpServersConfig).checkReady().getStatusCode()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE);
- ;
- }
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/api/ReloadConfigControllerTest.java b/certService/src/test/java/org/onap/aaf/certservice/api/ReloadConfigControllerTest.java
deleted file mode 100644
index 92c18e16..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/api/ReloadConfigControllerTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api;
-
-import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.doThrow;
-
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.aaf.certservice.certification.configuration.CmpServersConfig;
-import org.onap.aaf.certservice.certification.configuration.CmpServersConfigLoadingException;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-@ExtendWith(MockitoExtension.class)
-public class ReloadConfigControllerTest {
-
- private static final String ERROR_MESSAGE = "Exception occurred during CMP Servers configuration loading";
-
- private ReloadConfigController reloadConfigController;
-
- @Mock
- public CmpServersConfig cmpServersConfig;
-
- @BeforeEach
- void setUp() {
- this.reloadConfigController = new ReloadConfigController(cmpServersConfig);
- }
-
- @Test
- void shouldReturnStatusOkWhenSuccessfullyReloaded() throws CmpServersConfigLoadingException {
- // When
- ResponseEntity<String> response = reloadConfigController.reloadConfiguration();
-
- // Then
- assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
- }
-
- @Test
- void shouldRethrowSameErrorWhenFailedToReload() throws CmpServersConfigLoadingException {
- // Given
- doThrow(new CmpServersConfigLoadingException(ERROR_MESSAGE)).when(cmpServersConfig).reloadConfiguration();
-
- // When
- Exception exception = assertThrows(
- CmpServersConfigLoadingException.class,
- () -> reloadConfigController.reloadConfiguration());
-
- // Then
- Assertions.assertThat(exception.getMessage()).isEqualTo(ERROR_MESSAGE);
- }
-
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdviceTest.java b/certService/src/test/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdviceTest.java
deleted file mode 100644
index f3c4ec7f..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdviceTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api.advice;
-
-import com.google.gson.Gson;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ClientAdapterException;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException;
-import org.onap.aaf.certservice.certification.exception.CsrDecryptionException;
-import org.onap.aaf.certservice.certification.exception.ErrorResponseModel;
-import org.onap.aaf.certservice.certification.exception.KeyDecryptionException;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class CertificationExceptionAdviceTest {
-
- private CertificationExceptionAdvice certificationExceptionAdvice;
-
- @BeforeEach
- void setUp() {
- certificationExceptionAdvice =
- new CertificationExceptionAdvice();
- }
-
- @Test
- void shouldReturnResponseEntityWithAppropriateErrorMessageWhenGivenCsrDecryptionException() {
- // Given
- String expectedMessage = "Wrong certificate signing request (CSR) format";
- CsrDecryptionException csrDecryptionException = new CsrDecryptionException("test csr exception");
-
- // When
- ResponseEntity<ErrorResponseModel> response = certificationExceptionAdvice.handle(csrDecryptionException);
-
- // Then
- assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
- assertEquals(expectedMessage, response.getBody().getErrorMessage());
- }
-
- @Test
- void shouldReturnResponseEntityWithAppropriateErrorMessageWhenGivenKeyDecryptionException() {
- // Given
- String expectedMessage = "Wrong key (PK) format";
- KeyDecryptionException csrDecryptionException = new KeyDecryptionException("test pk exception");
-
- // When
- ResponseEntity<ErrorResponseModel> response = certificationExceptionAdvice.handle(csrDecryptionException);
-
- // Then
- assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
- assertEquals(expectedMessage, response.getBody().getErrorMessage());
- }
-
- @Test
- void shouldReturnResponseEntityWithAppropriateErrorMessageWhenGivenCaNameIsNotPresentInConfig() {
- // Given
- String expectedMessage = "Certification authority not found for given CAName";
- Cmpv2ServerNotFoundException csrDecryptionException = new Cmpv2ServerNotFoundException("test Ca exception");
-
- // When
- ResponseEntity<ErrorResponseModel> response = certificationExceptionAdvice.handle(csrDecryptionException);
-
- // Then
- assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
- assertEquals(expectedMessage, response.getBody().getErrorMessage());
- }
-
- @Test
- void shouldReturnResponseEntityWithAppropriateErrorMessageWhenCallingCmpClientFail() {
- // Given
- String expectedMessage = "Exception occurred during call to cmp client";
- CmpClientException cmpClientException = new CmpClientException("Calling CMPv2 client failed");
-
- // When
- ResponseEntity<ErrorResponseModel> response = certificationExceptionAdvice.handle(cmpClientException);
-
- // Then
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
- assertEquals(expectedMessage, response.getBody().getErrorMessage());
- }
-
- @Test
- void shouldReturnResponseEntityWithAppropriateErrorMessageWhenModelTransformationInAdapterFail() {
- // Given
- String expectedMessage = "Exception occurred parsing cmp client response";
- Cmpv2ClientAdapterException cmpv2ClientAdapterException = new Cmpv2ClientAdapterException(new Throwable());
-
- // When
- ResponseEntity<ErrorResponseModel> response = certificationExceptionAdvice.handle(cmpv2ClientAdapterException);
-
- // Then
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
- assertEquals(expectedMessage, response.getBody().getErrorMessage());
- }
-
- @Test
- void shouldThrowCmpClientExceptionWhenNotHandledRunTimeExceptionOccur() {
- // Given
- String expectedMessage = "Runtime exception occurred calling cmp client business logic";
- RuntimeException runtimeException = new RuntimeException("Unknown runtime exception");
-
- // When
- Exception exception = assertThrows(
- CmpClientException.class, () ->
- certificationExceptionAdvice.handle(runtimeException)
- );
-
- // Then
- assertEquals(expectedMessage, exception.getMessage());
- }
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdviceTest.java b/certService/src/test/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdviceTest.java
deleted file mode 100644
index 9abecec9..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdviceTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.api.advice;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.certification.configuration.CmpServersConfigLoadingException;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-class ReloadConfigExceptionAdviceTest {
-
- private static final String ERROR_MESSAGE = "Exception occurred during CMP Servers configuration loading";
-
- private ReloadConfigExceptionAdvice reloadConfigExceptionAdvice;
-
- @BeforeEach
- void setUp() {
- reloadConfigExceptionAdvice =
- new ReloadConfigExceptionAdvice();
- }
-
- @Test
- void shouldReturnErrorStatusAndMessageWhenExceptionOccurred() {
- // Given
- CmpServersConfigLoadingException exception = new CmpServersConfigLoadingException(ERROR_MESSAGE);
-
- // When
- ResponseEntity<String> response = reloadConfigExceptionAdvice.handle(exception);
-
- // Then
- assertEquals(ERROR_MESSAGE, response.getBody());
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
- }
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/CertificationModelFactoryTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/CertificationModelFactoryTest.java
deleted file mode 100644
index a63c8e0e..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/CertificationModelFactoryTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.aaf.certservice.certification.configuration.Cmpv2ServerProvider;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ClientAdapterException;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException;
-import org.onap.aaf.certservice.certification.exception.CsrDecryptionException;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.model.CertificationModel;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.onap.aaf.certservice.certification.CertificationData.CA_CERT;
-import static org.onap.aaf.certservice.certification.CertificationData.ENTITY_CERT;
-import static org.onap.aaf.certservice.certification.CertificationData.INTERMEDIATE_CERT;
-import static org.onap.aaf.certservice.certification.CertificationData.EXTRA_CA_CERT;
-import static org.onap.aaf.certservice.certification.TestData.TEST_CSR;
-import static org.onap.aaf.certservice.certification.TestData.TEST_PK;
-import static org.onap.aaf.certservice.certification.TestData.TEST_WRONG_CSR;
-import static org.onap.aaf.certservice.certification.TestData.TEST_WRONG_PEM;
-
-@ExtendWith(MockitoExtension.class)
-class CertificationModelFactoryTest {
-
- private static final String TEST_CA = "testCA";
- private static final String ENCODED_CSR = getEncodedString(TEST_CSR);
- private static final String ENCODED_PK = getEncodedString(TEST_PK);
- private static final String ENCODED_WRONG_CSR = getEncodedString(TEST_WRONG_CSR);
- private static final String ENCODED_WRONG_PK = getEncodedString(TEST_WRONG_PEM);
-
- private CertificationModelFactory certificationModelFactory;
-
- @Mock
- private Cmpv2ServerProvider cmpv2ServerProvider;
- @Mock
- private CsrModelFactory csrModelFactory;
- @Mock
- private CertificationProvider certificationProvider;
-
-
- private static String getEncodedString(String testCsr) {
- return Base64.getEncoder().encodeToString(testCsr.getBytes());
- }
-
- @BeforeEach
- void setUp() {
- certificationModelFactory =
- new CertificationModelFactory(csrModelFactory, cmpv2ServerProvider, certificationProvider);
- }
-
- @Test
- void shouldCreateProperCertificationModelWhenGivenProperCsrModelAndCaName()
- throws CmpClientException, DecryptionException, Cmpv2ClientAdapterException {
-
- // Given
- CsrModel csrModel = mockCsrFactoryModelCreation();
- Cmpv2Server testServer = mockCmpv2ProviderServerSelection();
- mockCertificateProviderCertificateSigning(csrModel, testServer);
-
- // When
- CertificationModel certificationModel =
- certificationModelFactory.createCertificationModel(ENCODED_CSR, ENCODED_PK, TEST_CA);
-
- // Then
- assertEquals(2, certificationModel.getCertificateChain().size());
- assertThat(certificationModel.getCertificateChain()).contains(INTERMEDIATE_CERT, ENTITY_CERT);
- assertEquals(2, certificationModel.getTrustedCertificates().size());
- assertThat(certificationModel.getTrustedCertificates()).contains(CA_CERT, EXTRA_CA_CERT);
- }
-
- @Test
- void shouldThrowDecryptionExceptionWhenGivenWrongEncodedCsr()
- throws DecryptionException {
- // Given
- String expectedMessage = "Incorrect CSR, decryption failed";
- when(
- csrModelFactory.createCsrModel(
- eq(new CsrModelFactory.StringBase64(ENCODED_WRONG_CSR)),
- eq(new CsrModelFactory.StringBase64(ENCODED_WRONG_PK))
- )
- ).thenThrow(
- new CsrDecryptionException(expectedMessage)
- );
-
- // When
- Exception exception = assertThrows(
- DecryptionException.class, () ->
- certificationModelFactory.createCertificationModel(ENCODED_WRONG_CSR, ENCODED_WRONG_PK, TEST_CA)
- );
-
- // Then
- assertTrue(exception.getMessage().contains(expectedMessage));
- }
-
- @Test
- void shouldThrowCmpv2ServerNotFoundExceptionWhenGivenWrongCaName()
- throws DecryptionException {
- // Given
- String expectedMessage = "CA not found";
- mockCsrFactoryModelCreation();
- when(
- cmpv2ServerProvider.getCmpv2Server(TEST_CA)
- ).thenThrow(
- new Cmpv2ServerNotFoundException(expectedMessage)
- );
-
- // When
- Exception exception = assertThrows(
- Cmpv2ServerNotFoundException.class, () ->
- certificationModelFactory.createCertificationModel(ENCODED_CSR, ENCODED_PK, TEST_CA)
- );
-
- // Then
- assertTrue(exception.getMessage().contains(expectedMessage));
- }
-
- @Test
- void shouldThrowCmpClientExceptionWhenSigningCsrFailed()
- throws DecryptionException, CmpClientException, Cmpv2ClientAdapterException {
- // Given
- String expectedMessage = "failed to sign certificate";
- CsrModel csrModel = mockCsrFactoryModelCreation();
- Cmpv2Server testServer = mockCmpv2ProviderServerSelection();
- when(
- certificationProvider.signCsr(eq(csrModel), eq(testServer))
- ).thenThrow(
- new CmpClientException(expectedMessage)
- );
-
- // When
- Exception exception = assertThrows(
- CmpClientException.class, () ->
- certificationModelFactory.createCertificationModel(ENCODED_CSR, ENCODED_PK, TEST_CA)
- );
-
- // Then
- assertTrue(exception.getMessage().contains(expectedMessage));
- }
-
-
- private void mockCertificateProviderCertificateSigning(CsrModel csrModel, Cmpv2Server testServer)
- throws CmpClientException, Cmpv2ClientAdapterException {
- CertificationModel expectedCertificationModel = getCertificationModel();
- when(
- certificationProvider.signCsr(eq(csrModel), eq(testServer))
- ).thenReturn(expectedCertificationModel);
- }
-
- private Cmpv2Server mockCmpv2ProviderServerSelection() {
- Cmpv2Server testServer = getCmpv2Server();
- when(
- cmpv2ServerProvider.getCmpv2Server(eq(TEST_CA))
- ).thenReturn(testServer);
- return testServer;
- }
-
- private CsrModel mockCsrFactoryModelCreation()
- throws DecryptionException {
- CsrModel csrModel = getCsrModel();
- when(
- csrModelFactory.createCsrModel(
- eq(new CsrModelFactory.StringBase64(ENCODED_CSR)),
- eq(new CsrModelFactory.StringBase64(ENCODED_PK))
- )
- ).thenReturn(csrModel);
- return csrModel;
- }
-
- private Cmpv2Server getCmpv2Server() {
- return new Cmpv2Server();
- }
-
- private CsrModel getCsrModel() {
- return mock(CsrModel.class);
- }
-
- private CertificationModel getCertificationModel() {
- List<String> testTrustedCertificates = Arrays.asList(CA_CERT, EXTRA_CA_CERT);
- List<String> testCertificationChain = Arrays.asList(INTERMEDIATE_CERT, ENTITY_CERT);
- return new CertificationModel(testCertificationChain, testTrustedCertificates);
- }
-
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/CertificationProviderTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/CertificationProviderTest.java
deleted file mode 100644
index a590c5ea..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/CertificationProviderTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * AAF Certification Service
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.model.CertificationModel;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-import org.onap.aaf.certservice.cmpv2client.api.CmpClient;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.onap.aaf.certservice.cmpv2client.model.Cmpv2CertificationModel;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.security.NoSuchProviderException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.Collections;
-import java.util.Objects;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(MockitoExtension.class)
-class CertificationProviderTest {
-
- @Mock
- private CsrModel csrModel;
- @Mock
- private Cmpv2Server server;
- @Mock
- private CsrModel testCsrModel;
- @Mock
- private Cmpv2Server testServer;
- @Mock
- private CmpClient cmpClient;
-
- private CertificationProvider certificationProvider;
-
- @BeforeEach
- public void init() {
- certificationProvider = new CertificationProvider(cmpClient);
- }
-
- @Test
- void shouldConvertToCertificationModel()
- throws CertificateException, NoSuchProviderException, IOException, CmpClientException {
- // When
- when(
- cmpClient.createCertificate(any(CsrModel.class), any(Cmpv2Server.class))
- ).thenReturn(createCorrectClientResponse());
-
- CertificationModel certificationModel = certificationProvider.signCsr(csrModel, server);
-
- // Then
- InputStream certificate = getClass().getClassLoader().getResourceAsStream("certificateModelChain.first");
- InputStream trustedCertificate =
- getClass().getClassLoader().getResourceAsStream("trustedCertificatesModel.first");
- String certificateModel = removeLineEndings(certificationModel.getCertificateChain().get(0));
- String expectedCertificate =
- removeLineEndings(IOUtils.toString(Objects.requireNonNull(certificate), StandardCharsets.UTF_8));
- String trustedCertificateModel = removeLineEndings(certificationModel.getTrustedCertificates().get(0));
- String expectedTrustedCertificate =
- removeLineEndings(IOUtils.toString(Objects.requireNonNull(trustedCertificate), StandardCharsets.UTF_8));
-
- assertThat(certificateModel).isEqualTo(expectedCertificate);
- assertThat(trustedCertificateModel).isEqualTo(expectedTrustedCertificate);
- }
-
-
- @Test
- void certificationProviderThrowCmpClientWhenCallingClientFails()
- throws CmpClientException {
- // Given
- String expectedErrorMessage = "connecting to CMP client failed";
-
- when(
- cmpClient.createCertificate(any(CsrModel.class), any(Cmpv2Server.class))
- ).thenThrow(new CmpClientException(expectedErrorMessage));
-
- // When
- Exception exception = assertThrows(
- CmpClientException.class, () ->
- certificationProvider.signCsr(testCsrModel, testServer)
- );
-
- // Then
- assertThat(exception.getMessage()).isEqualTo(expectedErrorMessage);
- }
-
- private Cmpv2CertificationModel createCorrectClientResponse()
- throws CertificateException, NoSuchProviderException {
- InputStream certificateChain = getClass().getClassLoader().getResourceAsStream("certificateChain.first");
- InputStream trustedCertificate = getClass().getClassLoader().getResourceAsStream("trustedCertificates.first");
- X509Certificate x509Certificate = new CertificateFactoryProvider().generateCertificate(certificateChain);
- X509Certificate x509TrustedCertificate =
- new CertificateFactoryProvider().generateCertificate(trustedCertificate);
- return new Cmpv2CertificationModel(
- Collections.singletonList(x509Certificate),
- Collections.singletonList(x509TrustedCertificate));
- }
-
- private String removeLineEndings(String string) {
- return string.replace("\n", "").replace("\r", "");
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/CsrModelFactoryTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/CsrModelFactoryTest.java
deleted file mode 100644
index d2c3c54c..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/CsrModelFactoryTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.bouncycastle.util.encoders.Base64;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.certification.CsrModelFactory.StringBase64;
-import org.onap.aaf.certservice.certification.exception.CsrDecryptionException;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.exception.KeyDecryptionException;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.onap.aaf.certservice.certification.TestData.TEST_CSR;
-import static org.onap.aaf.certservice.certification.TestData.TEST_PK;
-import static org.onap.aaf.certservice.certification.TestData.TEST_WRONG_CSR;
-import static org.onap.aaf.certservice.certification.TestData.TEST_WRONG_PEM;
-
-
-class CsrModelFactoryTest {
-
- private CsrModelFactory csrModelFactory;
-
- @BeforeEach
- void setUp() {
- csrModelFactory = new CsrModelFactory();
- }
-
- @Test
- void shouldDecryptCsrAndReturnStringWithDataAboutIt() throws DecryptionException {
- // given
- String encoderCsr = new String(Base64.encode(TEST_CSR.getBytes()));
- String encoderPK = new String(Base64.encode(TEST_PK.getBytes()));
-
- // when
- CsrModel decryptedCsr = csrModelFactory
- .createCsrModel(new StringBase64(encoderCsr), new StringBase64(encoderPK));
-
- // then
- assertTrue(
- decryptedCsr.toString()
- .contains(
- "C=US,ST=California,L=San-Francisco,O=Linux-Foundation,"
- + "OU=ONAP,CN=onap.org,E=tester@onap.org")
- &&
- decryptedCsr.toString()
- .contains("SANs: [gerrit.onap.org, test.onap.org, onap.com]")
- );
- }
-
- @Test
- void shouldThrowCsrDecryptionExceptionWhenCsrIsIncorrect() {
- // given
- String encoderPK = new String(Base64.encode(TEST_PK.getBytes()));
- String wrongCsr = new String(Base64.encode(TEST_WRONG_CSR.getBytes()));
-
- // when
- Exception exception = assertThrows(
- CsrDecryptionException.class, () -> csrModelFactory
- .createCsrModel(new StringBase64(wrongCsr), new StringBase64(encoderPK))
- );
-
- String expectedMessage = "Incorrect CSR, decryption failed";
- String actualMessage = exception.getMessage();
-
- // then
- assertTrue(actualMessage.contains(expectedMessage));
- }
-
- @Test
- void shouldThrowKeyDecryptionExceptionWhenKeyIsIncorrect() {
- // given
- String encoderPK = new String(Base64.encode(TEST_WRONG_PEM.getBytes()));
- String wrongCsr = new String(Base64.encode(TEST_CSR.getBytes()));
-
- // when
- Exception exception = assertThrows(
- KeyDecryptionException.class, () -> csrModelFactory
- .createCsrModel(new StringBase64(wrongCsr), new StringBase64(encoderPK))
- );
-
- String expectedMessage = "Incorrect Key, decryption failed";
- String actualMessage = exception.getMessage();
-
- // then
- assertTrue(actualMessage.contains(expectedMessage));
- }
-
-
- @Test
- void shouldThrowCsrDecryptionExceptionWhenCsrIsNotInBase64Encoding() {
- // given
- String encoderPK = new String(Base64.encode(TEST_PK.getBytes()));
- String wrongCsr = "Not Base 64 Csr";
-
- // when
- Exception exception = assertThrows(
- CsrDecryptionException.class, () -> csrModelFactory
- .createCsrModel(new StringBase64(wrongCsr), new StringBase64(encoderPK))
- );
-
- String expectedMessage = "Incorrect CSR, decryption failed";
- String actualMessage = exception.getMessage();
-
- // then
- assertTrue(actualMessage.contains(expectedMessage));
- }
-
- @Test
- void shouldThrowKeyDecryptionExceptionWhenPkIsNotInBase64Encoding() {
- // given
- String encoderPK = "Not Base64 Key";
- String wrongCsr = new String(Base64.encode(TEST_CSR.getBytes()));
-
- // when
- Exception exception = assertThrows(
- KeyDecryptionException.class, () -> csrModelFactory
- .createCsrModel(new StringBase64(wrongCsr), new StringBase64(encoderPK))
- );
-
- String expectedMessage = "Incorrect Key, decryption failed";
- String actualMessage = exception.getMessage();
-
- // then
- assertTrue(actualMessage.contains(expectedMessage));
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java
deleted file mode 100644
index 90151b6d..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.bouncycastle.util.io.pem.PemObject;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.onap.aaf.certservice.certification.TestData.TEST_PEM;
-import static org.onap.aaf.certservice.certification.TestData.TEST_WRONG_PEM;
-import static org.onap.aaf.certservice.certification.TestUtils.pemObjectToString;
-
-
-class PemObjectFactoryTest {
-
-
- private PemObjectFactory pemObjectFactory;
-
- @BeforeEach
- void setUp() {
- pemObjectFactory = new PemObjectFactory();
- }
-
- @Test
- void shouldTransformStringInToPemObjectAndBackToString() throws DecryptionException {
- // when
- PemObject pemObject = pemObjectFactory.createPemObject(TEST_PEM).orElseThrow(
- () -> new DecryptionException("Pem decryption failed")
- );
- String parsedPemObject = pemObjectToString(pemObject);
-
- // then
- assertEquals(TEST_PEM, parsedPemObject);
- }
-
- @Test
- void shouldThrowExceptionWhenParsingPemFailed() {
- // given
- String expectedMessage = "Unable to create PEM";
-
- // when
- Exception exception = assertThrows(
- DecryptionException.class, () -> pemObjectFactory.createPemObject(TEST_WRONG_PEM).orElseThrow(
- () -> new DecryptionException(expectedMessage)
- )
- );
-
- String actualMessage = exception.getMessage();
-
- // then
- assertTrue(actualMessage.contains(expectedMessage));
- }
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/RsaContentSignerBuilderTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/RsaContentSignerBuilderTest.java
deleted file mode 100644
index 0083968d..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/RsaContentSignerBuilderTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.bouncycastle.operator.ContentSigner;
-import org.bouncycastle.operator.OperatorCreationException;
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.certification.RsaContentSignerBuilder;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-
-import java.io.IOException;
-import java.security.PrivateKey;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.onap.aaf.certservice.certification.TestUtils.createCsrModel;
-
-class RsaContentSignerBuilderTest {
-
- private RsaContentSignerBuilder rsaContentSignerBuilder;
-
- @BeforeEach
- void setUp() {
- rsaContentSignerBuilder = new RsaContentSignerBuilder();
- }
-
- @Test
- void shouldBuildProperContentSignerWhenProvidedCertificationRequestAndPrivateKey()
- throws IOException, OperatorCreationException, DecryptionException {
- // Given
- CsrModel testCsrModel = createCsrModel();
- PKCS10CertificationRequest testCertificationRequest = testCsrModel.getCsr();
- PrivateKey testPrivateKey = testCsrModel.getPrivateKey();
-
- // When
- ContentSigner createdContentSigner = rsaContentSignerBuilder.build(testCertificationRequest, testPrivateKey);
-
- // Then
- assertThat(createdContentSigner.getAlgorithmIdentifier())
- .isEqualTo(testCertificationRequest.getSignatureAlgorithm());
- }
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/TestData.java b/certService/src/test/java/org/onap/aaf/certservice/certification/TestData.java
deleted file mode 100644
index 6fea5b5a..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/TestData.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-public final class TestData {
-
- private TestData() {
- }
-
- public static final String TEST_CSR = ""
- + "-----BEGIN CERTIFICATE REQUEST-----\n"
- + "MIIDIzCCAgsCAQAwgZcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlh\n"
- + "MRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkwFwYDVQQKDBBMaW51eC1Gb3VuZGF0\n"
- + "aW9uMQ0wCwYDVQQLDARPTkFQMREwDwYDVQQDDAhvbmFwLm9yZzEeMBwGCSqGSIb3\n"
- + "DQEJARYPdGVzdGVyQG9uYXAub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n"
- + "CgKCAQEA13K1LrQ1L6eL7B8K4kucNct0sSjZe7Ww91V40s6mjcWajeFJk+pObZKz\n"
- + "BfnImkVJwxdNMDD6tX16wykbGfQPyh4BBiAjLVk9XSeoPHFRBQ4LKTuyPtXhEXyr\n"
- + "qwatYXGWZE554qq64pbReddOUJHgMc38SrOk/eMAKxB0uRrXpA0mPH7zwIZ4X8g2\n"
- + "PoxJKI1BSYc8kOvvujsGSMw3e5nS8A+doFUwVi3jJMnaVCoZrvJbtREfXHZqBLQ5\n"
- + "XQ8mNpIFfmGYF/tvW/O6LBdlZkuAQ9i4FBgf5+HdIVZOXrn09ksIZxW6vxIvAVi0\n"
- + "5AOSgXictyphcNP2i/erBeCQCVB7MwIDAQABoEYwRAYJKoZIhvcNAQkOMTcwNTAz\n"
- + "BgNVHREELDAqgg9nZXJyaXQub25hcC5vcmeCDXRlc3Qub25hcC5vcmeCCG9uYXAu\n"
- + "Y29tMA0GCSqGSIb3DQEBCwUAA4IBAQBXH2nRwodQRJTuyrLe/VSg3PUdcPyAx2Ew\n"
- + "63tWiGO+qWo8rK2a9Rr/t/zkQe2lx6NHqcMc2Rt6NeKGbrAvHGxTiYM35gktBdxG\n"
- + "UaQS1ymrBWHAwbC+kv78r+5lCfafNm/EVdhUZbEw+crsw2wx4iKEW0byS4Ln0o5g\n"
- + "aXVUW3i4G5FaYiYBUIDsujDdnH1IoxunEA6pDzDv1h6R9/TYu6Se8HToREIjOPBZ\n"
- + "pDI5lDRu0YmI8r+TmAU3tTT1sY2WVxYDnhJut9ofegfMPQV4FIohxtPcCfoLSWti\n"
- + "ml6jbcFqDvlzq3B3CXH9HU3jdJt33iSjCQGsSqy6bmCOdMS6XTPU\n"
- + "-----END CERTIFICATE REQUEST-----\n";
-
- public static final String TEST_WRONG_CSR = ""
- + "-----BEGIN CERTIFICATE REQUEST-----\n"
- + "MIIDIzCCAgsCAQAwgZcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlh\n"
- + "MRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkwFwYDVQQKDBBMaW51eC1Gb3VuZGF0\n"
- + "aW9uMQ0wCwYDVQQLDARPTkFQMREwDwYDVQQDDAhvbmFwLm9yZzEeMBwGCSqGSIb3\n"
- + "-----END CERTIFICATE REQUEST-----\n";
-
- public static final String TEST_PK = "-----BEGIN PRIVATE KEY-----\n"
- + "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDXcrUutDUvp4vs\n"
- + "HwriS5w1y3SxKNl7tbD3VXjSzqaNxZqN4UmT6k5tkrMF+ciaRUnDF00wMPq1fXrD\n"
- + "KRsZ9A/KHgEGICMtWT1dJ6g8cVEFDgspO7I+1eERfKurBq1hcZZkTnniqrriltF5\n"
- + "105QkeAxzfxKs6T94wArEHS5GtekDSY8fvPAhnhfyDY+jEkojUFJhzyQ6++6OwZI\n"
- + "zDd7mdLwD52gVTBWLeMkydpUKhmu8lu1ER9cdmoEtDldDyY2kgV+YZgX+29b87os\n"
- + "F2VmS4BD2LgUGB/n4d0hVk5eufT2SwhnFbq/Ei8BWLTkA5KBeJy3KmFw0/aL96sF\n"
- + "4JAJUHszAgMBAAECggEAJ1StdsU3IGf5xzUzi3Q6JCfsOZs3eLoGgGB+Gh3XkfIM\n"
- + "8PG7uOEBSEeLnv+me2NCv/a1BKMsYY1yp8YNSIOhjkhD75ZWVaUA6syejcox/DZA\n"
- + "G1rmg0oQOF0GCcbCSBOwXMdmwNZiH5Ng0llX1qWKxAzSjeCVsjOKiFIMvO4Fh9D4\n"
- + "9Io6/dRRNCxB6MEs1GT5IDfCV2PGDIalJ3znFqDnfdu9RDEDfNVHSUr6Jdu3Hrf5\n"
- + "3qCcSEkMGuXYLotCNtTP1x0H0wW5gVpcbQEb29qdmHL1qkp3UiA3afsHnO/3k0gv\n"
- + "gV5FxaldugyZAjqUGERdKaY6BMDJkDuu0qD0tPQK4QKBgQDuP5X5BcQ4iHNej+il\n"
- + "xxT8QaEcZj0YEzcXzfm3ztZP7g+Jc1MbQXh6BuHLkXG5LeCwdnmk+LUD0MLoUSm3\n"
- + "N2ZdtVuOHX7VEBrhrTwK/kMDpC7ganQzfvgOr9WQGmgGMRiUYAyK1J/x78yX967Z\n"
- + "IAzdVZ/JSDdsyA983JckLL7CPQKBgQDngDkEJKYGfDt2mfItD8c8nhczGbDdoyYh\n"
- + "s93ppTtgzFoNgFL4y/DOvisWMGgoeeYXSgH5uoPv6yY7IIkQzYySY6qQ3gmk1/X+\n"
- + "bO+IsKVtlHBzqqojFteg3MfVojisMoAx6y5aBw1BXE2nAU8yWBTtuk+3KgGn9Oxk\n"
- + "+Z4rdP06LwKBgA4b09zIW6NhaTubWBKhJHv/wvO0lj+bu7J8LyKUbBqVpXPlUXGW\n"
- + "wfSv/aUZetuVfO3WRkPfupB8R16Ml+TSsgwwljhnRMCHUKA2qwyXnA5WJbSCeVkn\n"
- + "Vrc/8Gy1M53SQHtg6L079DDWm44QS9ltzXU6Adlgnm+htVEWmxi4UZ+dAoGAfr6z\n"
- + "+LG7+GcCA2AruEIgOe7wErkpHV+am+8nOymMxeV8FFJCmxbFQ9vYKTDdhfOfZvbM\n"
- + "+BYG8E8VQmAAyyNOqENK+j+mlgrrEp4/0t2r5L/VhW5V8hoqelcGTc+gKZ8IkswJ\n"
- + "N58Owc8wcJQF8TFKXBGaXVTxTSyKVIpZ778AeV8CgYAAvuicDkdwWv5EhDFf3aTI\n"
- + "wfRFYflA6oiygnI63HzVyY4a+SyZs+nQpB5HBDo+Lyz8RaVRC5E7jQ8kiXJpxAu7\n"
- + "1wnspz+pa3q61yR32N+zGuub71FXdLWSOlys6rzJqvqYihKxY22C2TyDyBCR2tMj\n"
- + "mdnshXNAJfKkfghkJhFHrg==\n"
- + "-----END PRIVATE KEY-----";
-
- public static final String TEST_PEM = ""
- + "-----BEGIN CERTIFICATE REQUEST-----\n"
- + "MIIDIzCCAgsCAQAwgZcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlh\n"
- + "-----END CERTIFICATE REQUEST-----\n";
-
- public static final String TEST_WRONG_PEM = ""
- + "-----BEGIN WRONG REQUEST-----"
- + "MIIDIzCCAgsCAQAwgZcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlh"
- + "-----END WRONG REQUEST-----";
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/TestUtils.java b/certService/src/test/java/org/onap/aaf/certservice/certification/TestUtils.java
deleted file mode 100644
index a6e55c57..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/TestUtils.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.bouncycastle.util.encoders.Base64;
-import org.bouncycastle.util.io.pem.PemObject;
-import org.bouncycastle.util.io.pem.PemWriter;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.exception.KeyDecryptionException;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-
-import java.io.IOException;
-import java.io.StringWriter;
-
-import static org.onap.aaf.certservice.certification.TestData.TEST_CSR;
-import static org.onap.aaf.certservice.certification.TestData.TEST_PK;
-
-
-public final class TestUtils {
-
- private TestUtils() {
- }
-
- public static String pemObjectToString(PemObject pemObject) throws KeyDecryptionException {
- try (StringWriter output = new StringWriter()) {
- PemWriter pemWriter = new PemWriter(output);
- pemWriter.writeObject(pemObject);
- pemWriter.close();
- return output.getBuffer().toString();
-
- } catch (IOException e) {
- throw new KeyDecryptionException("Writing PAM Object to string failed", e);
- }
- }
-
- public static CsrModel createCsrModel() throws DecryptionException {
- CsrModelFactory csrModelFactory = new CsrModelFactory();
- String encoderCsr = new String(Base64.encode(TEST_CSR.getBytes()));
- String encoderPK = new String(Base64.encode(TEST_PK.getBytes()));
- return csrModelFactory
- .createCsrModel(new CsrModelFactory.StringBase64(encoderCsr), new CsrModelFactory.StringBase64(encoderPK));
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/X509CertificateBuilderTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/X509CertificateBuilderTest.java
deleted file mode 100644
index 067f2f5f..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/X509CertificateBuilderTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification;
-
-import org.bouncycastle.cert.X509CertificateHolder;
-import org.bouncycastle.cert.X509v3CertificateBuilder;
-import org.bouncycastle.operator.ContentSigner;
-import org.bouncycastle.operator.OperatorCreationException;
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-
-import java.io.IOException;
-import java.security.PrivateKey;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.onap.aaf.certservice.certification.TestUtils.createCsrModel;
-
-public class X509CertificateBuilderTest {
-
- private X509CertificateBuilder certificateBuilder;
-
-
- @BeforeEach
- void setUp() {
- certificateBuilder = new X509CertificateBuilder();
- }
-
- @Test
- void shouldBuildCertificateBuilderWhenGivenProperCertificationRequest()
- throws DecryptionException, IOException, OperatorCreationException {
- // Given
- CsrModel testCsrModel = createCsrModel();
- PKCS10CertificationRequest testCertificationRequest = testCsrModel.getCsr();
- PrivateKey testPrivateKey = testCsrModel.getPrivateKey();
- RsaContentSignerBuilder rsaContentSignerBuilder = new RsaContentSignerBuilder();
- ContentSigner createdContentSigner = rsaContentSignerBuilder.build(testCertificationRequest, testPrivateKey);
-
- // When
- X509v3CertificateBuilder certificateBuilder = this.certificateBuilder.build(testCertificationRequest);
- X509CertificateHolder certificateHolder = certificateBuilder.build(createdContentSigner);
-
- // Then
- assertThat(certificateHolder.getIssuer())
- .isEqualToComparingFieldByField(testCsrModel.getSubjectData());
- assertThat(certificateHolder.getSubjectPublicKeyInfo())
- .isEqualToComparingFieldByField(testCertificationRequest.getSubjectPublicKeyInfo());
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoaderTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoaderTest.java
deleted file mode 100644
index 87964295..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoaderTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.util.List;
-import java.util.Map;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.onap.aaf.certservice.CertServiceApplication;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-@ExtendWith(SpringExtension.class)
-@ContextConfiguration(classes = CertServiceApplication.class)
-class CmpServersConfigLoaderTest {
- private static final String EXISTING_CONFIG_FILENAME = "cmpServers.json";
- private static final String INVALID_CONFIG_FILENAME = "invalidCmpServers.json";
- private static final String NONEXISTENT_CONFIG_FILENAME = "nonExistingCmpServers.json";
-
- private static final Map<String, String> EXPECTED_FIRST_CMP_SERVER = Map.of(
- "CA_NAME", "TEST",
- "URL", "http://127.0.0.1/ejbca/publicweb/cmp/cmp",
- "ISSUER_DN", "CN=ManagementCA",
- "CA_MODE", "CLIENT",
- "IAK", "xxx",
- "RV", "yyy"
- );
- private static final Map<String, String> EXPECTED_SECOND_CMP_SERVER = Map.of(
- "CA_NAME", "TEST2",
- "URL", "http://127.0.0.1/ejbca/publicweb/cmp/cmpRA",
- "ISSUER_DN", "CN=ManagementCA2",
- "CA_MODE", "RA",
- "IAK", "xxx",
- "RV", "yyy"
- );
-
- @Autowired
- private CmpServersConfigLoader configLoader;
-
- @Test
- void shouldLoadCmpServersConfigWhenFileAvailable() throws CmpServersConfigLoadingException {
- // Given
- String path = getResourcePath(EXISTING_CONFIG_FILENAME);
-
- // When
- List<Cmpv2Server> cmpServers = configLoader.load(path);
-
- // Then
- assertThat(cmpServers).isNotNull();
- assertThat(cmpServers).hasSize(2);
- verifyThatCmpServerEquals(cmpServers.get(0), EXPECTED_FIRST_CMP_SERVER);
- verifyThatCmpServerEquals(cmpServers.get(1), EXPECTED_SECOND_CMP_SERVER);
- }
-
- @Test
- void shouldThrowExceptionWhenFileMissing() {
- // When
- Exception exception = assertThrows(
- CmpServersConfigLoadingException.class,
- () -> configLoader.load(NONEXISTENT_CONFIG_FILENAME));
-
- // Then
- assertThat(exception.getMessage()).contains("Exception occurred during CMP Servers configuration loading");
- }
-
- @Test
- void shouldThrowExceptionWhenConfigurationIsInvalid() {
- // Given
- String path = getResourcePath(INVALID_CONFIG_FILENAME);
-
- // When
- Exception exception = assertThrows(
- CmpServersConfigLoadingException.class,
- () -> configLoader.load(path));
-
- // Then
- assertThat(exception.getMessage()).contains("Validation of CMPv2 servers configuration failed");
- assertThat(exception.getCause().getMessage()).contains("authentication");
- }
-
- private String getResourcePath(String configFilename) {
- return getClass().getClassLoader().getResource(configFilename).getFile();
- }
-
- private void verifyThatCmpServerEquals(Cmpv2Server cmpv2Server, Map<String, String> expected) {
- assertThat(cmpv2Server.getCaName()).isEqualTo(expected.get("CA_NAME"));
- assertThat(cmpv2Server.getUrl()).isEqualTo(expected.get("URL"));
- assertThat(cmpv2Server.getIssuerDN().toString()).isEqualTo(expected.get("ISSUER_DN"));
- assertThat(cmpv2Server.getCaMode().name()).isEqualTo(expected.get("CA_MODE"));
- assertThat(cmpv2Server.getAuthentication().getIak()).isEqualTo(expected.get("IAK"));
- assertThat(cmpv2Server.getAuthentication().getRv()).isEqualTo(expected.get("RV"));
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigTest.java
deleted file mode 100644
index 511c3966..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.startsWith;
-
-import java.util.List;
-
-import org.bouncycastle.asn1.x500.X500Name;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.aaf.certservice.certification.configuration.model.Authentication;
-import org.onap.aaf.certservice.certification.configuration.model.CaMode;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-
-@ExtendWith(MockitoExtension.class)
-class CmpServersConfigTest {
-
- private static final String ERROR_MESSAGE = "Exception occurred during CMP Servers configuration loading";
- private static final String APP_CONFIG_PATH = "/fake/path/to/config";
- private static final List<Cmpv2Server> SAMPLE_CMP_SERVERS = generateTestConfiguration();
-
- @Mock
- private CmpServersConfigLoader cmpServersConfigLoader;
-
- private CmpServersConfig cmpServersConfig;
-
- @BeforeEach
- void setUp() {
- cmpServersConfig = new CmpServersConfig(APP_CONFIG_PATH, cmpServersConfigLoader);
- }
-
- @Test
- void shouldCallLoaderWithPathFromPropertiesWhenCreated() throws CmpServersConfigLoadingException {
- // When
- this.cmpServersConfig.init(); // Manual PostConstruct call
-
- // Then
- Mockito.verify(cmpServersConfigLoader).load(startsWith(APP_CONFIG_PATH));
- }
-
- @Test
- void shouldReturnLoadedServersWhenGetCalled() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenReturn(SAMPLE_CMP_SERVERS);
- this.cmpServersConfig.init(); // Manual PostConstruct call
-
- // When
- List<Cmpv2Server> receivedCmpServers = this.cmpServersConfig.getCmpServers();
-
- // Then
- assertThat(receivedCmpServers).containsAll(SAMPLE_CMP_SERVERS);
- }
-
- @Test
- void shouldReturnLoadedServersAfterReloadWhenGetCalled() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenReturn(SAMPLE_CMP_SERVERS);
- List<Cmpv2Server> receivedCmpServers = this.cmpServersConfig.getCmpServers();
- assertThat(receivedCmpServers).isNull();
-
- // When
- this.cmpServersConfig.reloadConfiguration();
- receivedCmpServers = this.cmpServersConfig.getCmpServers();
-
- // Then
- assertThat(receivedCmpServers).containsAll(SAMPLE_CMP_SERVERS);
- }
-
- @Test
- void shouldRethrowExceptionWhenReloaded() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenThrow(new CmpServersConfigLoadingException(
- ERROR_MESSAGE));
-
- // Then
- assertThrows(
- CmpServersConfigLoadingException.class,
- () -> cmpServersConfig.reloadConfiguration());
- }
-
- @Test
- void shouldPassMessageToRethrownErrorWhenReloadingFails() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenThrow(new CmpServersConfigLoadingException(ERROR_MESSAGE));
-
- // When
- Exception exception = assertThrows(
- CmpServersConfigLoadingException.class,
- () -> cmpServersConfig.reloadConfiguration());
-
- // Then
- assertThat(exception.getMessage()).isEqualTo(ERROR_MESSAGE);
- }
-
- @Test
- void shouldNotReturnIakAndRvWhenToStringMethodIsUsed() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenReturn(SAMPLE_CMP_SERVERS);
- this.cmpServersConfig.init(); // Manual PostConstruct call
-
- // When
- List<Cmpv2Server> receivedCmpServers = this.cmpServersConfig.getCmpServers();
-
- // Then
- receivedCmpServers.forEach((server) -> assertThat(server.toString())
- .doesNotContain(
- server.getAuthentication().getIak(),
- server.getAuthentication().getRv()
- ));
- }
-
- @Test
- void shouldRethrowErrorWhenLoadingFails() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenThrow(new CmpServersConfigLoadingException(ERROR_MESSAGE));
-
- // Then
- assertThrows(
- CmpServersConfigLoadingException.class,
- () -> cmpServersConfig.loadConfiguration());
- }
-
- @Test
- void shouldPassMessageToRethrownErrorWhenLoadingFails() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenThrow(new CmpServersConfigLoadingException(ERROR_MESSAGE));
-
- // When
- Exception exception = assertThrows(
- CmpServersConfigLoadingException.class,
- () -> cmpServersConfig.loadConfiguration());
-
- // Then
- assertThat(exception.getMessage()).isEqualTo(ERROR_MESSAGE);
- }
-
- @Test
- void shouldBeNotReadyWhenCreated() {
- assertThat(cmpServersConfig.isReady()).isFalse();
- }
-
- @Test
- void shouldBeReadyWhenSuccessfullyInitialized() {
- // When
- this.cmpServersConfig.init(); // Manual PostConstruct call
-
- // Then
- assertThat(cmpServersConfig.isReady()).isTrue();
- }
-
- @Test
- void shouldNotBeReadyWhenFailedToInitialize() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenThrow(new CmpServersConfigLoadingException(ERROR_MESSAGE));
-
- // When
- this.cmpServersConfig.init(); // Manual PostConstruct call
-
- // Then
- assertThat(cmpServersConfig.isReady()).isFalse();
- }
-
- @Test
- void shouldBeReadyWhenSuccessfullyReloaded() throws CmpServersConfigLoadingException {
- // When
- this.cmpServersConfig.reloadConfiguration();
-
- // Then
- assertThat(cmpServersConfig.isReady()).isTrue();
- }
-
- @Test
- void shouldNotBeReadyWhenFailedToReload() throws CmpServersConfigLoadingException {
- // Given
- Mockito.when(cmpServersConfigLoader.load(any())).thenThrow(new CmpServersConfigLoadingException(ERROR_MESSAGE));
-
- // When
- assertThrows(
- CmpServersConfigLoadingException.class,
- () -> cmpServersConfig.loadConfiguration());
-
- // Then
- assertThat(cmpServersConfig.isReady()).isFalse();
- }
-
- private static List<Cmpv2Server> generateTestConfiguration() {
- Cmpv2Server testServer1 = new Cmpv2Server();
- testServer1.setCaName("TEST_CA1");
- testServer1.setIssuerDN(new X500Name("CN=testIssuer"));
- testServer1.setUrl("http://test.ca.server");
- Authentication testAuthentication1 = new Authentication();
- testAuthentication1.setIak("testIak");
- testAuthentication1.setRv("testRv");
- testServer1.setAuthentication(testAuthentication1);
- testServer1.setCaMode(CaMode.RA);
-
- Cmpv2Server testServer2 = new Cmpv2Server();
- testServer2.setCaName("TEST_CA2");
- testServer2.setIssuerDN(new X500Name("CN=testIssuer2"));
- testServer2.setUrl("http://test.ca.server");
- Authentication testAuthentication2 = new Authentication();
- testAuthentication2.setIak("test2Iak");
- testAuthentication2.setRv("test2Rv");
- testServer2.setAuthentication(testAuthentication2);
- testServer2.setCaMode(CaMode.CLIENT);
-
- return List.of(testServer1, testServer2);
- }
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java
deleted file mode 100644
index b83fb9aa..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration;
-
-import org.bouncycastle.asn1.x500.X500Name;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.aaf.certservice.certification.configuration.model.Authentication;
-import org.onap.aaf.certservice.certification.configuration.model.CaMode;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException;
-
-import java.util.Collections;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(MockitoExtension.class)
-class Cmpv2ServerProviderTest {
-
- private static final String TEST_CA = "testCA";
-
- private Cmpv2ServerProvider cmpv2ServerProvider;
-
- @Mock
- private CmpServersConfig cmpServersConfig;
-
- @BeforeEach
- void setUp() {
- cmpv2ServerProvider =
- new Cmpv2ServerProvider(cmpServersConfig);
- }
-
- @Test
- void shouldReturnOptionalWithServerWhenServerWithGivenCaNameIsPresentInConfig() {
- // Given
- Cmpv2Server testServer = createTestServer();
- when(cmpServersConfig.getCmpServers()).thenReturn(Collections.singletonList(testServer));
-
- // When
- Cmpv2Server receivedServer = cmpv2ServerProvider
- .getCmpv2Server(TEST_CA);
-
- // Then
- assertThat(receivedServer).isEqualToComparingFieldByField(testServer);
- }
-
- @Test
- void shouldReturnEmptyOptionalWhenServerWithGivenCaNameIsNotPresentInConfig() {
- // Given
- String expectedMessage = "No server found for given CA name";
- when(cmpServersConfig.getCmpServers()).thenReturn(Collections.emptyList());
-
- // When
- Exception exception = assertThrows(
- Cmpv2ServerNotFoundException.class, () ->
- cmpv2ServerProvider.getCmpv2Server(TEST_CA)
- );
-
- // Then
- assertTrue(exception.getMessage().contains(expectedMessage));
- }
-
- private Cmpv2Server createTestServer() {
- Cmpv2Server testServer = new Cmpv2Server();
- testServer.setCaName(TEST_CA);
- testServer.setIssuerDN(new X500Name("CN=testIssuer"));
- testServer.setUrl("http://test.ca.server");
- Authentication testAuthentication = new Authentication();
- testAuthentication.setIak("testIak");
- testAuthentication.setRv("testRv");
- testServer.setAuthentication(testAuthentication);
- testServer.setCaMode(CaMode.RA);
-
- return testServer;
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidatorTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidatorTest.java
deleted file mode 100644
index 6db77753..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidatorTest.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.validation;
-
-
-import org.bouncycastle.asn1.x500.X500Name;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.onap.aaf.certservice.CertServiceApplication;
-import org.onap.aaf.certservice.certification.configuration.model.Authentication;
-import org.onap.aaf.certservice.certification.configuration.model.CaMode;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.security.InvalidParameterException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-@ExtendWith(SpringExtension.class)
-@ContextConfiguration(classes = CertServiceApplication.class)
-class Cmpv2ServersConfigurationValidatorTest {
-
- private static final String EMPTY_STRING = "";
-
- @Autowired
- private Cmpv2ServersConfigurationValidator validator;
-
- private Authentication authentication;
- private Cmpv2Server server;
- private List<Cmpv2Server> servers;
-
- @BeforeEach
- private void init() {
- setAuthentication();
- setServerConfiguration();
- servers = new ArrayList<>();
- servers.add(server);
- }
-
- @Test
- void shouldThrowExceptionWhenCaNamesAreNotUnique() {
- // Given
- servers.add(server);
-
- // When
- Exception exception = assertThrows(
- InvalidParameterException.class,
- () -> validator.validate(servers));
-
- // Then
- assertThat(exception.getMessage()).contains("CA names are not unique within given CMPv2 servers");
- }
-
- @Test
- void shouldThrowExceptionWhenWrongProtocolInUrl() {
- // Given
- server.setUrl("https://test.test.test:60000/");
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenWrongPortInUrl() {
- // Given
- server.setUrl("http://test.test.test:70000/");
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenWrongCaNameLength() {
- // Given
- server.setCaName(EMPTY_STRING);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenWrongRvLength() {
- // Given
- authentication.setRv(EMPTY_STRING);
-
- // Then
- assertExceptionIsThrown();
- }
-
-
- @Test
- void shouldThrowExceptionWhenWrongIakLength() {
- // Given
- authentication.setIak(EMPTY_STRING);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenCaNameIsNull() {
- // Given
- server.setCaName(null);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenIssuerDnIsNull() {
- // Given
- server.setIssuerDN(null);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenCaModeIsNull() {
- // Given
- server.setCaMode(null);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenUrlIsNull() {
- // Given
- server.setUrl(null);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenAuthenticationIsNull() {
- // Given
- server.setAuthentication(null);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenIakIsNull() {
- // Given
- authentication.setIak(null);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldThrowExceptionWhenRvIsNull() {
- // Given
- authentication.setRv(null);
-
- // Then
- assertExceptionIsThrown();
- }
-
- @Test
- void shouldNotThrowExceptionWhenServerConfigurationIsValid() {
- // Then
- assertDoesNotThrow(() -> validator.validate(servers));
- }
-
- private void assertExceptionIsThrown() {
- assertThrows(IllegalArgumentException.class, () -> validator.validate(servers));
- }
-
- private void setServerConfiguration() {
- server = new Cmpv2Server();
- server.setCaMode(CaMode.CLIENT);
- server.setCaName("TEST");
- server.setIssuerDN(new X500Name("CN=ManagementCA"));
- server.setUrl("http://127.0.0.1/ejbca/publicweb/cmp/cmp");
- server.setAuthentication(authentication);
- }
-
- private void setAuthentication() {
- authentication = new Authentication();
- authentication.setRv("testRV");
- authentication.setIak("testIAK");
- }
-
-} \ No newline at end of file
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidatorTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidatorTest.java
deleted file mode 100644
index 7082626f..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidatorTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.onap.aaf.certservice.certification.configuration.validation.constraints;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-
-class Cmpv2UrlValidatorTest {
-
- private final Cmpv2UrlValidator validator = new Cmpv2UrlValidator();
-
- @Test
- void givenCorrectUrlWhenValidatingShouldReturnTrue() {
- //given
- String url = "http://127.0.0.1/ejbca/publicweb/cmp/cmp";
-
- //when
- boolean result = validator.isValid(url, null);
-
- //then
- assertTrue(result);
- }
-
- @Test
- void givenIncorrectUrlWhenValidatingShouldReturnFalse() {
- //given
- String url = "httttp://127.0.0.1:80000/ejbca/publicweb/cmp/cmp";
-
- //when
- boolean result = validator.isValid(url, null);
-
- //then
- assertFalse(result);
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolationTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolationTest.java
deleted file mode 100644
index e729c738..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolationTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.validation.constraints.violations;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class PortNumberViolationTest {
-
- private final PortNumberViolation violation = new PortNumberViolation();
-
- @Test
- void givenValidPortShouldReturnTrue() {
- //given
- String validUrl1 = "http://127.0.0.1:8080/ejbca/publicweb/cmp/cmp";
- String validUrl2 = "http://127.0.0.1:1/ejbca/publicweb/cmp/cmp";
- String validUrl3 = "http://127.0.0.1:65535/ejbca/publicweb/cmp/cmp";
-
- //when
- boolean result1 = violation.validate(validUrl1);
- boolean result2 = violation.validate(validUrl2);
- boolean result3 = violation.validate(validUrl3);
-
- //then
- assertTrue(result1);
- assertTrue(result2);
- assertTrue(result3);
- }
-
- @Test
- void givenEmptyPortShouldReturnTrue() {
- //given
- String validUrl = "http://127.0.0.1/ejbca/publicweb/cmp/cmp";
-
- //when
- boolean result = violation.validate(validUrl);
-
- //then
- assertTrue(result);
- }
-
- @Test
- void givenInvalidPortShouldReturnFalse() {
- //given
- String invalidUrl1 = "http://127.0.0.1:0/ejbca/publicweb/cmp/cmp";
- String invalidUrl2 = "http://127.0.0.1:65536/ejbca/publicweb/cmp/cmp";
-
- //when
- boolean result1 = violation.validate(invalidUrl1);
- boolean result2 = violation.validate(invalidUrl2);
-
- //then
- assertFalse(result1);
- assertFalse(result2);
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolationTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolationTest.java
deleted file mode 100644
index dce66d52..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolationTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.configuration.validation.constraints.violations;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-
-class RequestTypeViolationTest {
-
- private final RequestTypeViolation violation = new RequestTypeViolation();
-
- @Test
- void givenValidRequestTypeShouldReturnTrue() {
- //given
- String validUrl = "http://127.0.0.1/ejbca/publicweb/cmp/cmp";
-
- //when
- boolean result = violation.validate(validUrl);
-
- //then
- assertTrue(result);
- }
-
- @Test
- void givenInvalidRequestTypeShouldReturnFalse() {
- //given
- String invalidUrl = "htestps://127.0.0.1/ejbca/publicweb/cmp/cmp";
-
- //when
- boolean result = violation.validate(invalidUrl);
-
- //then
- assertFalse(result);
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java
deleted file mode 100644
index 08bc3368..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.certification.model;
-
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.bouncycastle.util.io.pem.PemObject;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.certification.Pkcs10CertificationRequestFactory;
-import org.onap.aaf.certservice.certification.PemObjectFactory;
-import org.onap.aaf.certservice.certification.exception.CsrDecryptionException;
-import org.onap.aaf.certservice.certification.exception.DecryptionException;
-import org.onap.aaf.certservice.certification.exception.KeyDecryptionException;
-
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.onap.aaf.certservice.certification.TestData.TEST_CSR;
-import static org.onap.aaf.certservice.certification.TestData.TEST_PEM;
-import static org.onap.aaf.certservice.certification.TestData.TEST_PK;
-
-
-class CsrModelTest {
-
- private final Pkcs10CertificationRequestFactory certificationRequestFactory
- = new Pkcs10CertificationRequestFactory();
- private final PemObjectFactory pemObjectFactory
- = new PemObjectFactory();
-
- @Test
- void shouldByConstructedAndReturnProperFields() throws DecryptionException, IOException {
- // Given
- PemObject testPrivateKey = getPemPrivateKey();
- PemObject testPublicKey = generateTestPublicKey();
- PKCS10CertificationRequest testCsr = generateTestCertificationRequest();
-
- // When
- CsrModel csrModel = generateTestCsrModel(testCsr);
-
- // Then
- assertThat(csrModel.getCsr())
- .isEqualTo(testCsr);
- assertThat(csrModel.getPrivateKey().getEncoded())
- .contains(testPrivateKey.getContent());
- assertThat(csrModel.getPublicKey().getEncoded())
- .contains(testPublicKey.getContent());
- assertThat(csrModel.getSans())
- .contains(
- "gerrit.onap.org", "test.onap.org", "onap.com");
- assertThat(csrModel.getSubjectData().toString())
- .contains(
- "C=US,ST=California,L=San-Francisco,O=Linux-Foundation,OU=ONAP,CN=onap.org,E=tester@onap.org");
- }
-
- @Test
- void shouldThrowExceptionWhenPublicKeyIsNotCorrect() throws DecryptionException, IOException {
- // Given
- PemObject testPrivateKey = getPemPrivateKey();
- PKCS10CertificationRequest testCsr = mock(PKCS10CertificationRequest.class);
- SubjectPublicKeyInfo wrongKryInfo = mock(SubjectPublicKeyInfo.class);
- when(testCsr.getSubjectPublicKeyInfo())
- .thenReturn(wrongKryInfo);
- when(wrongKryInfo.getEncoded())
- .thenThrow(new IOException());
-
- // When
- Exception exception = assertThrows(
- CsrDecryptionException.class,
- () -> new CsrModel.CsrModelBuilder(testCsr, testPrivateKey).build()
- );
-
- String expectedMessage = "Reading Public Key from CSR failed";
- String actualMessage = exception.getMessage();
-
- // Then
- assertTrue(actualMessage.contains(expectedMessage));
- }
-
- @Test
- void shouldThrowExceptionWhenPrivateKeyPemIsNotProperPrivateKey() throws KeyDecryptionException, IOException {
- // Given
- PemObject testPrivateKey = getPemWrongKey();
- PKCS10CertificationRequest testCsr = mock(PKCS10CertificationRequest.class);
- SubjectPublicKeyInfo wrongKryInfo = mock(SubjectPublicKeyInfo.class);
- when(testCsr.getSubjectPublicKeyInfo())
- .thenReturn(wrongKryInfo);
- when(wrongKryInfo.getEncoded())
- .thenThrow(new IOException());
-
- // When
- Exception exception = assertThrows(
- KeyDecryptionException.class,
- () -> new CsrModel.CsrModelBuilder(testCsr, testPrivateKey).build()
- );
-
- String expectedMessage = "Converting Private Key failed";
- String actualMessage = exception.getMessage();
-
- // Then
- assertTrue(actualMessage.contains(expectedMessage));
- }
-
- @Test
- void shouldThrowExceptionWhenPublicKeyPemIsNotProperPublicKey() throws KeyDecryptionException, IOException {
- // Given
- PemObject testPrivateKey = getPemPrivateKey();
- PemObject testPublicKey = getPemWrongKey();
- PKCS10CertificationRequest testCsr = mock(PKCS10CertificationRequest.class);
- SubjectPublicKeyInfo wrongKryInfo = mock(SubjectPublicKeyInfo.class);
- when(testCsr.getSubjectPublicKeyInfo())
- .thenReturn(wrongKryInfo);
- when(wrongKryInfo.getEncoded())
- .thenReturn(testPublicKey.getContent());
-
- // When
- Exception exception = assertThrows(
- KeyDecryptionException.class,
- () -> new CsrModel.CsrModelBuilder(testCsr, testPrivateKey).build()
- );
-
- String expectedMessage = "Converting Public Key from CSR failed";
- String actualMessage = exception.getMessage();
-
- // Then
- assertTrue(actualMessage.contains(expectedMessage));
- }
-
- private PemObject getPemPrivateKey() throws KeyDecryptionException {
- PemObjectFactory pemObjectFactory = new PemObjectFactory();
- return pemObjectFactory.createPemObject(TEST_PK).orElseThrow(
- () -> new KeyDecryptionException("Private key decoding fail")
- );
- }
-
- private PemObject getPemWrongKey() throws KeyDecryptionException {
- PemObjectFactory pemObjectFactory = new PemObjectFactory();
- return pemObjectFactory.createPemObject(TEST_PEM).orElseThrow(
- () -> new KeyDecryptionException("Private key decoding fail")
- );
- }
-
- private CsrModel generateTestCsrModel(PKCS10CertificationRequest testCsr) throws DecryptionException {
- PemObject testPrivateKey = pemObjectFactory.createPemObject(TEST_PK).orElseThrow(
- () -> new DecryptionException("Incorrect Private Key, decryption failed")
- );
- return new CsrModel.CsrModelBuilder(testCsr, testPrivateKey).build();
- }
-
- private PemObject generateTestPublicKey() throws DecryptionException, IOException {
- PKCS10CertificationRequest testCsr = generateTestCertificationRequest();
- return new PemObject("PUBLIC KEY", testCsr.getSubjectPublicKeyInfo().getEncoded());
- }
-
- private PKCS10CertificationRequest generateTestCertificationRequest() throws DecryptionException {
- return pemObjectFactory.createPemObject(TEST_CSR)
- .flatMap(
- certificationRequestFactory::createPkcs10CertificationRequest
- ).orElseThrow(
- () -> new DecryptionException("Incorrect CSR, decryption failed")
- );
- }
-
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/Cmpv2ClientTest.java b/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/Cmpv2ClientTest.java
deleted file mode 100644
index 05bda54b..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/Cmpv2ClientTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2019 Ericsson Software Technology AB. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package org.onap.aaf.certservice.cmpv2client;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.KeyFactory;
-import java.security.KeyPair;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.Security;
-import java.security.cert.X509Certificate;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.bouncycastle.asn1.x500.X500Name;
-import org.bouncycastle.asn1.x500.X500NameBuilder;
-import org.bouncycastle.asn1.x500.style.BCStyle;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
-import org.onap.aaf.certservice.certification.configuration.model.Authentication;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.model.CsrModel;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.onap.aaf.certservice.cmpv2client.impl.CmpClientImpl;
-import org.onap.aaf.certservice.cmpv2client.model.Cmpv2CertificationModel;
-
-class Cmpv2ClientTest {
-
- static {
- Security.addProvider(new BouncyCastleProvider());
- }
-
- private CsrModel csrModel;
- private Cmpv2Server server;
- private Date notBefore;
- private Date notAfter;
- private X500Name dn;
-
- @Mock
- X509Certificate cert;
-
- @Mock
- CloseableHttpClient httpClient;
-
- @Mock
- CloseableHttpResponse httpResponse;
-
- @Mock
- HttpEntity httpEntity;
-
- private static KeyPair keyPair;
-
- @BeforeEach
- void setUp()
- throws NoSuchProviderException, NoSuchAlgorithmException, IOException,
- InvalidKeySpecException {
- keyPair = loadKeyPair();
- dn = new X500NameBuilder()
- .addRDN(BCStyle.O, "TestOrganization")
- .build();
- initMocks(this);
- }
-
- public KeyPair loadKeyPair()
- throws IOException, NoSuchAlgorithmException, InvalidKeySpecException,
- NoSuchProviderException {
-
- final InputStream privateInputStream = this.getClass().getResourceAsStream("/privateKey");
- final InputStream publicInputStream = this.getClass().getResourceAsStream("/publicKey");
- BufferedInputStream bis = new BufferedInputStream(privateInputStream);
- byte[] privateBytes = IOUtils.toByteArray(bis);
- bis = new BufferedInputStream(publicInputStream);
- byte[] publicBytes = IOUtils.toByteArray(bis);
-
- KeyFactory keyFactory = KeyFactory.getInstance("RSA", BouncyCastleProvider.PROVIDER_NAME);
- X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicBytes);
- PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);
-
- PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(privateBytes);
- PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);
-
- return new KeyPair(publicKey, privateKey);
- }
-
- @Test
- void shouldReturnValidPkiMessageWhenCreateCertificateRequestMessageMethodCalledWithValidCsr()
- throws Exception {
- // given
- Date beforeDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2019/11/11 12:00:00");
- Date afterDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2020/11/11 12:00:00");
- setCsrModelAndServerValues(
- "mypassword",
- "senderKID",
- "http://127.0.0.1/ejbca/publicweb/cmp/cmp",
- beforeDate,
- afterDate);
- when(httpClient.execute(any())).thenReturn(httpResponse);
- when(httpResponse.getEntity()).thenReturn(httpEntity);
-
- try (final InputStream is =
- this.getClass().getResourceAsStream("/ReturnedSuccessPKIMessageWithCertificateFile");
- BufferedInputStream bis = new BufferedInputStream(is)) {
-
- byte[] ba = IOUtils.toByteArray(bis);
- doAnswer(
- invocation -> {
- OutputStream os = (ByteArrayOutputStream) invocation.getArguments()[0];
- os.write(ba);
- return null;
- })
- .when(httpEntity)
- .writeTo(any(OutputStream.class));
- }
- CmpClientImpl cmpClient = spy(new CmpClientImpl(httpClient));
- // when
- Cmpv2CertificationModel cmpClientResult =
- cmpClient.createCertificate(csrModel, server, notBefore, notAfter);
- // then
- assertNotNull(cmpClientResult);
- }
-
- @Test
- void
- shouldThrowCmpClientExceptionWhenCreateCertificateRequestMessageMethodCalledWithWrongProtectedBytesInResponse()
- throws Exception {
- // given
- Date beforeDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2019/11/11 12:00:00");
- Date afterDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2020/11/11 12:00:00");
- setCsrModelAndServerValues(
- "password",
- "senderKID",
- "http://127.0.0.1/ejbca/publicweb/cmp/cmp",
- beforeDate,
- afterDate);
- when(httpClient.execute(any())).thenReturn(httpResponse);
- when(httpResponse.getEntity()).thenReturn(httpEntity);
-
- try (final InputStream is =
- this.getClass().getResourceAsStream("/ReturnedSuccessPKIMessageWithCertificateFile");
- BufferedInputStream bis = new BufferedInputStream(is)) {
-
- byte[] ba = IOUtils.toByteArray(bis);
- doAnswer(
- invocation -> {
- OutputStream os = (ByteArrayOutputStream) invocation.getArguments()[0];
- os.write(ba);
- return null;
- })
- .when(httpEntity)
- .writeTo(any(OutputStream.class));
- }
- CmpClientImpl cmpClient = spy(new CmpClientImpl(httpClient));
- // then
- Assertions.assertThrows(
- CmpClientException.class,
- () -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter));
- }
-
- @Test
- void shouldThrowCmpClientExceptionWithPkiErrorExceptionWhenCmpClientCalledWithBadPassword()
- throws Exception {
- // given
- Date beforeDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2019/11/11 12:00:00");
- Date afterDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2020/11/11 12:00:00");
- setCsrModelAndServerValues(
- "password",
- "senderKID",
- "http://127.0.0.1/ejbca/publicweb/cmp/cmp",
- beforeDate,
- afterDate);
- when(httpClient.execute(any())).thenReturn(httpResponse);
- when(httpResponse.getEntity()).thenReturn(httpEntity);
-
- try (final InputStream is =
- this.getClass().getResourceAsStream("/ReturnedFailurePKIMessageBadPassword");
- BufferedInputStream bis = new BufferedInputStream(is)) {
-
- byte[] ba = IOUtils.toByteArray(bis);
- doAnswer(
- invocation -> {
- OutputStream os = (ByteArrayOutputStream) invocation.getArguments()[0];
- os.write(ba);
- return null;
- })
- .when(httpEntity)
- .writeTo(any(OutputStream.class));
- }
- CmpClientImpl cmpClient = spy(new CmpClientImpl(httpClient));
-
- // then
- Assertions.assertThrows(
- CmpClientException.class,
- () -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter));
- }
-
- @Test
- void shouldThrowIllegalArgumentExceptionWhencreateCertificateCalledWithInvalidCsr()
- throws ParseException {
- // given
- Date beforeDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2020/11/11 12:00:00");
- Date afterDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2019/11/11 12:00:00");
- setCsrModelAndServerValues(
- "password",
- "senderKID",
- "http://127.0.0.1/ejbca/publicweb/cmp/cmp",
- beforeDate,
- afterDate);
- CmpClientImpl cmpClient = new CmpClientImpl(httpClient);
- // then
- Assertions.assertThrows(
- IllegalArgumentException.class,
- () -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter));
- }
-
- @Test
- void shouldThrowIoExceptionWhenCreateCertificateCalledWithNoServerAvailable()
- throws IOException, ParseException {
- // given
- Date beforeDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2019/11/11 12:00:00");
- Date afterDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2020/11/11 12:00:00");
- setCsrModelAndServerValues(
- "myPassword",
- "sender",
- "http://127.0.0.1/ejbca/publicweb/cmp/cmpTest",
- beforeDate,
- afterDate);
- when(httpClient.execute(any())).thenThrow(IOException.class);
- CmpClientImpl cmpClient = spy(new CmpClientImpl(httpClient));
- // then
- Assertions.assertThrows(
- CmpClientException.class,
- () -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter));
- }
-
- private void setCsrModelAndServerValues(String iak, String rv, String externalCaUrl, Date notBefore, Date notAfter) {
- csrModel = new CsrModel(null, dn, keyPair.getPrivate(), keyPair.getPublic(), Collections.emptyList());
-
- Authentication authentication = new Authentication();
- authentication.setIak(iak);
- authentication.setRv(rv);
- server = new Cmpv2Server();
- server.setAuthentication(authentication);
- server.setUrl(externalCaUrl);
- server.setIssuerDN(dn);
- this.notBefore = notBefore;
- this.notAfter = notAfter;
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/external/RdnTest.java b/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/external/RdnTest.java
deleted file mode 100644
index 6e42afe8..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/external/RdnTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.external;
-
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
-import org.bouncycastle.asn1.x500.style.BCStyle;
-import org.bouncycastle.cert.CertException;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class RdnTest {
-
- @Test
- void shouldCreateCorrectRdn() throws CertException {
- // given
- final String expectedValue = "ManagmentCA";
- final ASN1ObjectIdentifier expectedAoi = BCStyle.CN;
-
- //when
- Rdn rdn1 = new Rdn("CN=ManagmentCA");
- Rdn rdn2 = new Rdn("CN = ManagmentCA ");
- Rdn rdn3 = new Rdn("CN", "ManagmentCA");
-
- //then
- assertEquals(expectedValue, rdn1.getValue());
- assertEquals(expectedValue, rdn2.getValue());
- assertEquals(expectedValue, rdn3.getValue());
- assertEquals(expectedAoi, rdn1.getAoi());
- assertEquals(expectedAoi, rdn2.getAoi());
- assertEquals(expectedAoi, rdn3.getAoi());
- }
-
- @Test
- void shouldCorrectlySplitAndTrimString() {
- //given
- String value1 = " T = Test";
- List<String> expected1 = Arrays.asList("T", "Test");
-
- String value2 = "This 123 is 99 tested 12345 string";
- List<String> expected2 = Arrays.asList("This", "is 99 tested", "string");
-
- //when
- List<String> actual1 = Rdn.parseRdn("=", value1);
- List<String> actual2 = Rdn.parseRdn("[0-9]{3,}", value2);
-
- //then
- assertEquals(expected1, actual1);
- assertEquals(expected2, actual2);
- }
-
- @Test
- void shouldConvertAoiStringToEnum() throws CertException {
- Rdn rdn = new Rdn("CN", "ManagmentCA");
-
- assertEquals(BCStyle.CN, rdn.getAoi("CN"));
- assertEquals(BCStyle.C, rdn.getAoi("C"));
- assertEquals(BCStyle.ST, rdn.getAoi("ST"));
- assertEquals(BCStyle.L, rdn.getAoi("L"));
- assertEquals(BCStyle.O, rdn.getAoi("O"));
- assertEquals(BCStyle.OU, rdn.getAoi("OU"));
- assertEquals(BCStyle.DC, rdn.getAoi("DC"));
- assertEquals(BCStyle.GIVENNAME, rdn.getAoi("GN"));
- assertEquals(BCStyle.SN, rdn.getAoi("SN"));
- assertEquals(BCStyle.E, rdn.getAoi("E"));
- assertEquals(BCStyle.E, rdn.getAoi("EMAIL"));
- assertEquals(BCStyle.E, rdn.getAoi("EMAILADDRESS"));
- assertEquals(BCStyle.INITIALS, rdn.getAoi("INITIALS"));
- assertEquals(BCStyle.PSEUDONYM, rdn.getAoi("PSEUDONYM"));
- assertEquals(BCStyle.GENERATION, rdn.getAoi("GENERATIONQUALIFIER"));
- assertEquals(BCStyle.SERIALNUMBER, rdn.getAoi("SERIALNUMBER"));
- assertThrows(CertException.class, () -> rdn.getAoi("INVALIDTAG"));
- }
-}
diff --git a/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseHelperTest.java b/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseHelperTest.java
deleted file mode 100644
index c41d6364..00000000
--- a/certService/src/test/java/org/onap/aaf/certservice/cmpv2client/impl/CmpResponseHelperTest.java
+++ /dev/null
@@ -1,609 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.cmpv2client.impl;
-
-import org.bouncycastle.asn1.cmp.CMPCertificate;
-import org.bouncycastle.asn1.cmp.CertRepMessage;
-import org.bouncycastle.asn1.cmp.PKIMessage;
-import org.bouncycastle.util.io.pem.PemObject;
-import org.bouncycastle.util.io.pem.PemReader;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
-import org.onap.aaf.certservice.cmpv2client.model.Cmpv2CertificationModel;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.security.NoSuchProviderException;
-import java.security.Security;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-
-import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-class CmpResponseHelperTest {
-
-
- private static final String EXPECTED_ERROR_MESSAGE = "Something was wrong with the supplied certificate";
-
- private static final String TEST_1LAYER_ENTITY_CERT = ""
- + "-----BEGIN CERTIFICATE-----\n"
- + "MIIEqDCCAxCgAwIBAgIUFioEkVJsxfZGGDMEyCA8Rin3uhQwDQYJKoZIhvcNAQEL\n"
- + "BQAwYTEjMCEGCgmSJomT8ixkAQEME2MtMDM1ZDk4NTAwYzhiN2JiMjIxFTATBgNV\n"
- + "BAMMDE1hbmFnZW1lbnRDQTEjMCEGA1UECgwaRUpCQ0EgQ29udGFpbmVyIFF1aWNr\n"
- + "c3RhcnQwHhcNMjAwMzI0MTEzNTU0WhcNMjIwMzI0MTEzNTU0WjCBljEgMB4GCSqG\n"
- + "SIb3DQEJARYRQ29tbW9uTmFtZUBjbi5jb20xDjAMBgNVBAMMBUNsMTIzMQ0wCwYD\n"
- + "VQQLDARPTkFQMRkwFwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMRYwFAYDVQQHDA1T\n"
- + "YW4tRnJhbmNpc2NvMRMwEQYDVQQIDApDYWxpZm9ybmlhMQswCQYDVQQGEwJVUzCC\n"
- + "ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL94FcmRn/g9Y9ZrEL+jKiud\n"
- + "xzDdtVLoF0ijZOGG0rnzyimzzwOjd8LA0jiZlYtpoDef95bbMeZJMKzE3bA8EMFp\n"
- + "hynqUHs/KdsLBV+o3J6EzlpYHrwypX7kOriw9o4dmPAxvJHXTu3HC2SejJjHHArk\n"
- + "FyahEJ03ypvCJx3iPvGXkLI9tZetobiVXslBJd5t0hQj+JQxzAlTwS0fV+xMowFT\n"
- + "css2IlGXfQgd88cdhXBVOE0//qln1ko3G3KeH58iIWLqh9KG660SCeoTCop7bO1N\n"
- + "abVrcXlgdE06hAvzTj3FoBxqO5KEWDPo2Dr11qRdq8bLP2T0EbTzAw4DPUwE+H8C\n"
- + "AwEAAaOBoTCBnjAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFDPaBc+EX/hCLe5c\n"
- + "d+oZIxcQZ1tHMB8GA1UdEQQYMBaCBUNsMTIzgg10ZXN0Lm9uYXAub3JnMB0GA1Ud\n"
- + "JQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDBDAdBgNVHQ4EFgQU4dP1HuV9O+sHInl+\n"
- + "WuvdDJ63lp8wDgYDVR0PAQH/BAQDAgXgMA0GCSqGSIb3DQEBCwUAA4IBgQBWTF8C\n"
- + "sH0ir4bj7rTlJMf5o7apkXFeQ/c7+zXnSLCfXqwM6ad0EDh3FixfTC8IpW5CaENt\n"
- + "zTR7IGJr06ccwLgsigR7FxJKnEkxJiBxzkE3zFOEel3KAnV2b7KvOP7cJAzsCdcS\n"
- + "iZU475XHOw4Ox3k8fHzhTJJa0Tzw5EjQ3GO99HTiUClGrjJuYDLfen1q7IQSNuTY\n"
- + "FzxJZjyqzi34pkKeCNSPRj8Z8Q5aZiWqlmzSJmZRT83xzzeW/pQ1JwvIrWwrbEjR\n"
- + "FPXBlUa1n2HztkDgeBQfRyMAj5ixFV+s1Jj+cEYl3pjbugnuHfgBdSJokXFGBo6N\n"
- + "8PTd1CnMGWcWiMyhbTwNm2UiSr5KhQbjABjiUzDp4C7jFhIzmu/4/tm2uA+y0xPN\n"
- + "342uEZC0ZSZmpCIbQMhPaBNjSHeHj8NaLHjnt5jppLkMxScayRqMvSW07eNew2+k\n"
- + "VYJD6z6gfy4y+Y5MSLfvddq1JdPDU86TFprtD1ydcUBS5tduYQG2+1bLgpE="
- + "\n-----END CERTIFICATE-----\n";
-
- private static final String TEST_1LAYER_CA_CERT = ""
- + "-----BEGIN CERTIFICATE-----\n"
- + "MIIEszCCAxugAwIBAgIUEhkh+zJtXZN3K3kzQYcbp2smyIkwDQYJKoZIhvcNAQEL\n"
- + "BQAwYTEjMCEGCgmSJomT8ixkAQEME2MtMDM1ZDk4NTAwYzhiN2JiMjIxFTATBgNV\n"
- + "BAMMDE1hbmFnZW1lbnRDQTEjMCEGA1UECgwaRUpCQ0EgQ29udGFpbmVyIFF1aWNr\n"
- + "c3RhcnQwHhcNMjAwMzI0MTAyODQyWhcNMzAwMzI0MTAyODQyWjBhMSMwIQYKCZIm\n"
- + "iZPyLGQBAQwTYy0wMzVkOTg1MDBjOGI3YmIyMjEVMBMGA1UEAwwMTWFuYWdlbWVu\n"
- + "dENBMSMwIQYDVQQKDBpFSkJDQSBDb250YWluZXIgUXVpY2tzdGFydDCCAaIwDQYJ\n"
- + "KoZIhvcNAQEBBQADggGPADCCAYoCggGBAJyKZyKIRyW6cbga/I1YFJGCEEgs9JVU\n"
- + "sV7MD5/yF4SIkJlZqFjJ9kfw8D5thg68zAx2vEWIpNTMroqb1eptIn/XsFoyM//6\n"
- + "HzKrY3UUYWHx9sQMDZPenTL8LTRx+4szSen7rzrozH2pJat7kfX4EODEtQ6q7RQ2\n"
- + "hmXoo7heeSgiHoeHsPGZixPGzcB27WBaY00Z/sP/n+f0CFaE04MKLw8WeQmq/RkC\n"
- + "pj628+eBK0lGtEmUcT7z4CBy4x3hbhn9XHOb0+RlDk7rqFbsc09vHoZK2BfQ/r6e\n"
- + "HguZjBQ5Ebqf6PiLF3HqkSW73toIdIy/olvQ2dLbOEyI4OnlObc+8xs/1AC7l9xX\n"
- + "FkXY+NBv24KG1C2POXx14+ufHhWY0k2nIRUUlkUIJ7WGMWbuiNUXc1wSE1VrmY/c\n"
- + "iXlhsJERqFc6bL/STlhOGuwmkdAD1/K8WS+o/QmIIX6cXlOR0U9bHMbD40F9fur6\n"
- + "PV8wSKcQQNd0VHRLhmFwo4kkhZpDpuUp4QIDAQABo2MwYTAPBgNVHRMBAf8EBTAD\n"
- + "AQH/MB8GA1UdIwQYMBaAFDPaBc+EX/hCLe5cd+oZIxcQZ1tHMB0GA1UdDgQWBBQz\n"
- + "2gXPhF/4Qi3uXHfqGSMXEGdbRzAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL\n"
- + "BQADggGBAFGsyu5nWycdk8iva+uY98QnPQe/M6uaUGUis0vGn9UYxoz5ddtpF3Z+\n"
- + "MsHgbS51BH9iRYn4ZkQoRoukIjt1iO86d6sgpUS5AStCXsylL4DwAY5G/K5i/Qw5\n"
- + "x0lP/tRYwqh2tUhmnx1xZLOWbRFZ63A0YHdguj3CqaXQ/cxafYZe0zcNhX3iH3gf\n"
- + "5kHH8E682RT0x4ibb1JtPioQ48+pweyfMlOJkJ7WmZEfiVQitQSSNOnw1hRORiUz\n"
- + "oFb0MlYHqe/9lIb9nmzD8QQ9q0H8J6RBCFsntx/Z6oUM8GHr80zAvNjqFfR14lOo\n"
- + "jp05w2mr7wxIHFpM6h1HGY1QaeGp6W/fi+N7+gSL3nu1LzXVCYNCTcGkBDeasovB\n"
- + "ma70KHGO4ZyRcEMKFCxxE8y4GZnw/EhMhDDevXAVsHEzr6XsBCJkC8e2l3iW5IKH\n"
- + "4N/f/k06d4kS5pL290dJ450zx/mBxYGJm+pPHZfDszqVeKn1m1ZhGT80150OePGQ\n"
- + "Cc2ir84HwQ=="
- + "\n-----END CERTIFICATE-----\n";
-
- private static final String TEST_2LAYER_ENTITY_CERT = ""
- + "-----BEGIN CERTIFICATE-----\n"
- + "MIIDjDCCAnSgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwgYQxCzAJBgNVBAYTAlVT\n"
- + "MRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw\n"
- + "FwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQD\n"
- + "DBVpbnRlcm1lZGlhdGUub25hcC5vcmcwHhcNMjAwMjEyMDk1MTI2WhcNMjIxMTA4\n"
- + "MDk1MTI2WjB7MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQG\n"
- + "A1UEBwwNU2FuLUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjEN\n"
- + "MAsGA1UECwwET05BUDEVMBMGA1UEAwwMdmlkLm9uYXAub3JnMIIBIjANBgkqhkiG\n"
- + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw+GIRzJzUOh0gtc+wzFJEdTnn+q5F10L0Yhr\n"
- + "G1xKdjPieHIFGsoiXwcuCU8arNSqlz7ocx62KQRkcA8y6edlOAsYtdOEJvqEI9vc\n"
- + "eyTB/HYsbzw3URPGch4AmibrQkKU9QvGwouHtHn4R2Ft2Y0tfEqv9hxj9v4njq4A\n"
- + "EiDLAFLl5FmVyCZu/MtKngSgu1smcaFKTYySPMxytgJZexoa/ALZyyE0gRhsvwHm\n"
- + "NLGCPt1bmE/PEGZybsCqliyTO0S56ncD55The7+D/UDS4kE1Wg0svlWon/YsE6QW\n"
- + "B3oeJDX7Kr8ebDTIAErevIAD7Sm4ee5se2zxYrsYlj0MzHZtvwIDAQABoxAwDjAM\n"
- + "BgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCvQ1pTvjON6vSlcJRKSY4r\n"
- + "8q7L4/9ZaVXWJAjzEYJtPIqsgGiPWz0vGfgklowU6tZxp9zRZFXfMil+mPQSe+yo\n"
- + "ULrZSQ/z48YHPueE/BNO/nT4aaVBEhPLR5aVwC7uQVX8H+m1V1UGT8lk9vdI9rej\n"
- + "CI9l524sLCpdE4dFXiWK2XHEZ0Vfylk221u3IYEogVVA+UMX7BFPSsOnI2vtYK/i\n"
- + "lwZtlri8LtTusNe4oiTkYyq+RSyDhtAswg8ANgvfHolhCHoLFj6w1IkG88UCmbwN\n"
- + "d7BoGMy06y5MJxyXEZG0vR7eNeLey0TIh+rAszAFPsIQvrOHW+HuA+WLQAj1mhnm\n"
- + "-----END CERTIFICATE-----";
-
- private static final String TEST_2LAYER_INTERMEDIATE_CERT = ""
- + "-----BEGIN CERTIFICATE-----\n"
- + "MIIDqTCCApGgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwgZcxCzAJBgNVBAYTAlVT\n"
- + "MRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw\n"
- + "FwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMREwDwYDVQQD\n"
- + "DAhvbmFwLm9yZzEeMBwGCSqGSIb3DQEJARYPdGVzdGVyQG9uYXAub3JnMB4XDTIw\n"
- + "MDIxMjA5NDAxMloXDTIyMTEwODA5NDAxMlowgYQxCzAJBgNVBAYTAlVTMRMwEQYD\n"
- + "VQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkwFwYDVQQK\n"
- + "DBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQDDBVpbnRl\n"
- + "cm1lZGlhdGUub25hcC5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n"
- + "AQC1oOYMZ6G+2DGDAizYnzdCNiogivlht1s4oqgem7fM1XFPxD2p31ATIibOdqr/\n"
- + "gv1qemO9Q4r1xn6w1Ufq7T1K7PjnMzdSeTqZefurE2JM/HHx2QvW4TjMlz2ILgaD\n"
- + "L1LN60kmMQSOi5VxKJpsrCQxbOsxhvefd212gny5AZMcjJe23kUd9OxUrtvpdLEv\n"
- + "wI3vFEvT7oRUnEUg/XNz7qeg33vf1C39yMR+6O4s6oevgsEebVKjb+yOoS6zzGtz\n"
- + "72wZjm07C54ZlO+4Uy+QAlMjRiU3mgWkKbkOy+4CvwehjhpTikdBs2DX39ZLGHhn\n"
- + "L/0a2NYtGulp9XEqmTvRoI+PAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZI\n"
- + "hvcNAQELBQADggEBADcitdJ6YswiV8jAD9GK0gf3+zqcGegt4kt+79JXlXYbb1sY\n"
- + "q3o6prcB7nSUoClgF2xUPCslFGpM0Er9FCSFElQM/ru0l/KVmJS6kSpwEHvsYIH3\n"
- + "q5anta+Pyk8JSQWAAw+qrind0uBQMnhR8Tn13tgV+Kjvg/xlH/nZIEdN5YtLB1cA\n"
- + "beVsZRyRfVL9DeZU8s/MZ5wC3kgcEp5A4m5lg7HyBxBdqhzFcDr6xiy6OGqW8Yep\n"
- + "xrwfc8Fw8a/lOv4U+tBeGNKPQDYaL9hh+oM+qMkNXsHXDqdJsuEGJtU4i3Wcwzoc\n"
- + "XGN5NWV//4bP+NFmwgcn7AYCdRvz04A8GU/0Cwg=\n"
- + "-----END CERTIFICATE-----";
-
- private static final String TEST_2LAYER_CA_CERT = ""
- + "-----BEGIN CERTIFICATE-----\n"
- + "MIIDtzCCAp8CFAwqQddh4/iyGfP8UZ3dpXlxfAN8MA0GCSqGSIb3DQEBCwUAMIGX\n"
- + "MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2Fu\n"
- + "LUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwE\n"
- + "T05BUDERMA8GA1UEAwwIb25hcC5vcmcxHjAcBgkqhkiG9w0BCQEWD3Rlc3RlckBv\n"
- + "bmFwLm9yZzAeFw0yMDAyMTIwOTM0MjdaFw0yMTAyMTEwOTM0MjdaMIGXMQswCQYD\n"
- + "VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuLUZyYW5j\n"
- + "aXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwET05BUDER\n"
- + "MA8GA1UEAwwIb25hcC5vcmcxHjAcBgkqhkiG9w0BCQEWD3Rlc3RlckBvbmFwLm9y\n"
- + "ZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMCFrnO7/eT6V+7XkPPd\n"
- + "eiL/6xXreuegvit/1/jTVjG+3AOVcmTn2WXwXXRcQLvkWQfJVPoltsY8E3FqFRti\n"
- + "797XjY6cdQJFVDyzNU0+Fb4vJL9FK5wSvnS6EFjBEn3JvXRlENorDCs/mfjkjJoa\n"
- + "Dl74gXQEJYcg4nsTeNIj7cm3Q7VK3mZt1t7LSJJ+czxv69UJDuNJpmQ/2WOKyLZA\n"
- + "gTtBJ+Hyol45/OLsrqwq1dAn9ZRWIFPvRt/XQYH9bI/6MtqSreRVUrdYCiTe/XpP\n"
- + "B/OM6NEi2+p5QLi3Yi70CEbqP3HqUVbkzF+r7bwIb6M5/HxfqzLmGwLvD+6rYnUn\n"
- + "Bm8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAhXoO65DXth2X/zFRNsCNpLwmDy7r\n"
- + "PxT9ZAIZAzSxx3/aCYiuTrKP1JnqjkO+F2IbikrI4n6sKO49SKnRf9SWTFhd+5dX\n"
- + "vxq5y7MaqxHAY9J7+Qzq33+COVFQnaF7ddel2NbyUVb2b9ZINNsaZkkPXui6DtQ7\n"
- + "/Fb/1tmAGWd3hMp75G2thBSzs816JMKKa9WD+4VGATEs6OSll4sv2fOZEn+0mAD3\n"
- + "9q9c+WtLGIudOwcHwzPb2njtNntQSCK/tVOqbY+vzhMY3JW+p9oSrLDSdGC+pAKK\n"
- + "m/wB+2VPIYcsPMtIhHC4tgoSaiCqjXYptaOh4b8ye8CPBUCpX/AYYkN0Ow==\n"
- + "-----END CERTIFICATE-----";
-
-
- @BeforeAll
- static void setUpSecurity() {
- Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
- }
-
-
- @Test
- void returnListOfCertificationWhenGivenCaCertInCaPubsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- PKIMessage respPkiMessage = mockExtraCerts(null);
-
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT);
- CMPCertificate[] cmpCertificates = {caCmpCertificate};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_1LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityCertificate(certs, TEST_1LAYER_ENTITY_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(certs, caCmpCertificate);
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertInExtraCertsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT);
- CMPCertificate[] extraCmpCertificates = {caCmpCertificate};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
-
- CertRepMessage certRepMessage = mockCaPubs(null);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_1LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityCertificate(certs, TEST_1LAYER_ENTITY_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(certs, caCmpCertificate);
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertInExtraCertsAndExtraTrustAnchorInCaPubsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT);
- CMPCertificate[] extraCmpCertificates = {caCmpCertificate};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
-
- CMPCertificate extraTrustAnchor = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate[] cmpCertificates = {extraTrustAnchor};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_1LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityCertificate(certs, TEST_1LAYER_ENTITY_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(
- certs,
- caCmpCertificate, extraTrustAnchor
- );
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertInExtraCertsAndExtraTrustAnchorInExtraCertsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate trustedCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT);
- CMPCertificate[] extraCmpCertificates = {caCmpCertificate, trustedCmpCertificate};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
-
- CertRepMessage certRepMessage = mockCaPubs(null);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_1LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityCertificate(certs, TEST_1LAYER_ENTITY_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(
- certs,
- caCmpCertificate, trustedCmpCertificate
- );
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertAndIntermediateCertInExtraCertsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate intermediateCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_INTERMEDIATE_CERT);
- CMPCertificate[] extraCmpCertificates = {caCmpCertificate, intermediateCmpCertificate};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
-
- CertRepMessage certRepMessage = mockCaPubs(null);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_2LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityAndIntermediateCertificate(certs, TEST_2LAYER_ENTITY_CERT, TEST_2LAYER_INTERMEDIATE_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(
- certs,
- caCmpCertificate
- );
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertAndIntermediateCertInCmpCertificatesAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- PKIMessage respPkiMessage = mockExtraCerts(null);
-
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate intermediateCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_INTERMEDIATE_CERT);
- CMPCertificate[] cmpCertificates = {caCmpCertificate, intermediateCmpCertificate};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_2LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityAndIntermediateCertificate(certs, TEST_2LAYER_ENTITY_CERT, TEST_2LAYER_INTERMEDIATE_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(
- certs,
- caCmpCertificate
- );
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertInCaPubsAndIntermediateCertInExtraCertsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate intermediateCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_INTERMEDIATE_CERT);
- CMPCertificate[] extraCmpCertificates = {intermediateCmpCertificate};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
-
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate[] cmpCertificates = {caCmpCertificate};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_2LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityAndIntermediateCertificate(certs, TEST_2LAYER_ENTITY_CERT, TEST_2LAYER_INTERMEDIATE_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(
- certs,
- caCmpCertificate
- );
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertInCaPubsAndExtraCertsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT);
- CMPCertificate[] extraCmpCertificates = {caCmpCertificate};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
- CMPCertificate[] cmpCertificates = {mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT)};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_1LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityCertificate(certs, TEST_1LAYER_ENTITY_CERT);
- assertThatRootCaAndTrustedCaAreInSecondList(certs, mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT));
-
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertAndIntermediateCertInExtraCertsAndIntermediateCertInCaPubsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate intermediateCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_INTERMEDIATE_CERT);
- CMPCertificate[] extraCmpCertificates = {caCmpCertificate, intermediateCmpCertificate};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
- CMPCertificate[] cmpCertificates = {intermediateCmpCertificate};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_2LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityAndIntermediateCertificate(certs, TEST_2LAYER_ENTITY_CERT, TEST_2LAYER_INTERMEDIATE_CERT);
- assertThatRootCaAndTrustedCaAreInSecondList(
- certs,
- caCmpCertificate
- );
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertAndExtraTrustAnchorInCaPubsAndIntermediateCertInExtraCertsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate intermediateCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_INTERMEDIATE_CERT);
- CMPCertificate[] extraCmpCertificates = {intermediateCmpCertificate};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
-
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate extraTrustAnchor = mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT);
- CMPCertificate[] cmpCertificates = {caCmpCertificate, extraTrustAnchor};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_2LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityAndIntermediateCertificate(certs, TEST_2LAYER_ENTITY_CERT, TEST_2LAYER_INTERMEDIATE_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(
- certs,
- caCmpCertificate, extraTrustAnchor
- );
- }
-
- @Test
- void returnListOfCertificationWhenGivenCaCertAndFirstExtraTrustAnchorInCaPubsAndIntermediateCertAndSecondExtraTrustAnchorInExtraCertsAndEntityCertInLeafCertificate()
- throws CertificateException, CmpClientException, IOException, NoSuchProviderException {
- // given
- CMPCertificate intermediateCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_INTERMEDIATE_CERT);
- CMPCertificate extraTrustAnchor01 = mockCmpCertificateFromPem(TEST_1LAYER_ENTITY_CERT);
- CMPCertificate[] extraCmpCertificates = {intermediateCmpCertificate, extraTrustAnchor01};
- PKIMessage respPkiMessage = mockExtraCerts(extraCmpCertificates);
-
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate extraTrustAnchor02 = mockCmpCertificateFromPem(TEST_1LAYER_CA_CERT);
- CMPCertificate[] cmpCertificates = {caCmpCertificate, extraTrustAnchor02};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_2LAYER_ENTITY_CERT);
-
- // when
- Cmpv2CertificationModel certs = CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate);
-
- // then
- assertThatChainContainsEntityAndIntermediateCertificate(certs, TEST_2LAYER_ENTITY_CERT, TEST_2LAYER_INTERMEDIATE_CERT);
-
- assertThatRootCaAndTrustedCaAreInSecondList(
- certs,
- caCmpCertificate, extraTrustAnchor01, extraTrustAnchor02
- );
- }
-
- @Test
- void throwsExceptionWhenNoCaCertForEntityCertIsGivenAndOnlyExtraTrustAnchorIsReturned()
- throws CertificateException, IOException, NoSuchProviderException {
- // given
-
- PKIMessage respPkiMessage = mockExtraCerts(null);
-
- CMPCertificate trustedCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate[] cmpCertificates = {trustedCmpCertificate};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_1LAYER_ENTITY_CERT);
-
- // when
- Exception exception = assertThrows(
- CmpClientException.class,
- () -> CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate
- )
- );
-
- String actualMessage = exception.getMessage();
-
- // then
- assertThat(actualMessage).isEqualTo(EXPECTED_ERROR_MESSAGE);
- }
-
- @Test
- void throwsExceptionWhenBothExtraCertsAndCaPubsAreEmpty()
- throws CertificateException, IOException, NoSuchProviderException {
- // given
-
- PKIMessage respPkiMessage = mockExtraCerts(null);
- CertRepMessage certRepMessage = mockCaPubs(null);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_1LAYER_ENTITY_CERT);
-
- // when
- Exception exception = assertThrows(
- CmpClientException.class,
- () -> CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate
- )
- );
-
- String actualMessage = exception.getMessage();
-
- // then
- assertThat(actualMessage).isEqualTo(EXPECTED_ERROR_MESSAGE);
- }
-
- @Test
- void throwsExceptionWhenNoIntermediateCertForEntityCertIsGiven()
- throws CertificateException, IOException, NoSuchProviderException {
- // given
-
- PKIMessage respPkiMessage = mockExtraCerts(null);
-
- CMPCertificate caCmpCertificate = mockCmpCertificateFromPem(TEST_2LAYER_CA_CERT);
- CMPCertificate[] cmpCertificates = {caCmpCertificate};
- CertRepMessage certRepMessage = mockCaPubs(cmpCertificates);
-
- X509Certificate leafCertificate = getX509CertificateFromPem(TEST_2LAYER_ENTITY_CERT);
-
- // when
- Exception exception = assertThrows(
- CmpClientException.class,
- () -> CmpResponseHelper.verifyAndReturnCertChainAndTrustSTore(
- respPkiMessage, certRepMessage, leafCertificate
- )
- );
-
- String actualMessage = exception.getMessage();
-
- // then
- assertThat(actualMessage).isEqualTo(EXPECTED_ERROR_MESSAGE);
- }
-
-
- private void assertThatRootCaAndTrustedCaAreInSecondList(
- Cmpv2CertificationModel certs, CMPCertificate... rootAndTrustedCerts
- ) throws IOException {
- assertThat(certs.getTrustedCertificates().size()).isEqualTo(rootAndTrustedCerts.length);
- for (CMPCertificate certificate : rootAndTrustedCerts) {
- assertThat(certs.getTrustedCertificates())
- .extracting(Certificate::getEncoded)
- .contains(certificate.getEncoded());
- }
- }
-
- private void assertThatChainContainsEntityCertificate(
- Cmpv2CertificationModel certs, String entityCertificate
- ) throws CertificateEncodingException, IOException {
- assertThat(certs.getCertificateChain().size()).isEqualTo(1);
- assertThat(certs.getCertificateChain().get(0).getEncoded()).isEqualTo(createPemObject(entityCertificate).getContent());
- }
-
- private void assertThatChainContainsEntityAndIntermediateCertificate(
- Cmpv2CertificationModel certs, String entityCertificate, String intermediateCertificate
- ) throws CertificateEncodingException, IOException {
- assertThat(certs.getCertificateChain().size()).isEqualTo(2);
- assertThat(certs.getCertificateChain().get(0).getEncoded()).isEqualTo(createPemObject(entityCertificate).getContent());
- assertThat(certs.getCertificateChain().get(1).getEncoded()).isEqualTo(createPemObject(intermediateCertificate).getContent());
- }
-
- private X509Certificate getX509CertificateFromPem(String pem) throws CertificateException, NoSuchProviderException, IOException {
- return (X509Certificate)
- CertificateFactory.getInstance("X.509", "BC").generateCertificate(
- new ByteArrayInputStream(createPemObject(pem).getContent())
- );
- }
-
- private PKIMessage mockExtraCerts(CMPCertificate[] cmpCertificates) {
- PKIMessage respPkiMessage = mock(PKIMessage.class);
- when(respPkiMessage.getExtraCerts()).thenReturn(cmpCertificates);
- return respPkiMessage;
- }
-
- private CertRepMessage mockCaPubs(CMPCertificate[] cmpCertificates) {
- CertRepMessage certRepMessage = mock(CertRepMessage.class);
- when(certRepMessage.getCaPubs()).thenReturn(cmpCertificates);
- return certRepMessage;
- }
-
- private CMPCertificate mockCmpCertificateFromPem(String pem) throws IOException {
- return mockCmpCertificate(createPemObject(pem).getContent());
- }
-
- private CMPCertificate mockCmpCertificate(byte[] encodedCertificate) throws IOException {
- CMPCertificate cmpCertificate01 = mock(CMPCertificate.class);
- when(cmpCertificate01.getEncoded()).thenReturn(encodedCertificate);
- return cmpCertificate01;
- }
-
- private PemObject createPemObject(String pem) throws IOException {
- try (StringReader stringReader = new StringReader(pem);
- PemReader pemReader = new PemReader(stringReader)) {
- return pemReader.readPemObject();
- }
- }
-}
diff --git a/certService/src/test/resources/ReturnedFailurePKIMessageBadPassword b/certService/src/test/resources/ReturnedFailurePKIMessageBadPassword
deleted file mode 100644
index 7d815814..00000000
--- a/certService/src/test/resources/ReturnedFailurePKIMessageBadPassword
+++ /dev/null
@@ -1,2 +0,0 @@
-0‚00ä010U ManagementCA¤T0R10U CN=CommonName1 0 *†H†÷  CommonName@cn.com10U
- CommonCompany 20191127135043Z¤ox eå×Öpî­1Â`ï¥ ›ˆ¢ŠSI\q–eè#«¦eþCÑÁrZÇÊ’ˆa®·h0f0d0[ YFailed to verify message using both Global Shared Secret and CMP RA Authentication Secret \ No newline at end of file
diff --git a/certService/src/test/resources/ReturnedSuccessPKIMessageWithCertificateFile b/certService/src/test/resources/ReturnedSuccessPKIMessageWithCertificateFile
deleted file mode 100644
index e4a1d7b9..00000000
--- a/certService/src/test/resources/ReturnedSuccessPKIMessageWithCertificateFile
+++ /dev/null
Binary files differ
diff --git a/certService/src/test/resources/application.properties b/certService/src/test/resources/application.properties
deleted file mode 100644
index b70ab3b4..00000000
--- a/certService/src/test/resources/application.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-# AAF CertService app specific configuration
-app.config.path=./src/test/resources
-
-# Mutual TLS configuration
-server.ssl.enabled=true
-server.ssl.client-auth=need
-server.port=${HTTPS_PORT:8443}
-
-server.ssl.key-store=${KEYSTORE_PATH:/etc/onap/aaf/certservice/certs/certServiceServer-keystore.jks}
-server.ssl.key-store-password=${KEYSTORE_PASSWORD:secret}
-
-server.ssl.trust-store=${TRUSTSTORE_PATH:/etc/onap/aaf/certservice/certs/truststore.jks}
-server.ssl.trust-store-password=${TRUSTSTORE_PASSWORD:secret} \ No newline at end of file
diff --git a/certService/src/test/resources/certificateChain.first b/certService/src/test/resources/certificateChain.first
deleted file mode 100644
index 3e0ae028..00000000
--- a/certService/src/test/resources/certificateChain.first
+++ /dev/null
Binary files differ
diff --git a/certService/src/test/resources/certificateModelChain.first b/certService/src/test/resources/certificateModelChain.first
deleted file mode 100644
index e6383860..00000000
--- a/certService/src/test/resources/certificateModelChain.first
+++ /dev/null
@@ -1 +0,0 @@
------BEGIN CERTIFICATE----- MIIEXTCCAsWgAwIBAgIUMI4X5/zCpkgY/NIx287DT/T1zEQwDQYJKoZIhvcNAQEL BQAwYTEjMCEGCgmSJomT8ixkAQEME2MtMDE5MmY0N2VkY2NjZjg5NzYxFTATBgNV BAMMDE1hbmFnZW1lbnRDQTEjMCEGA1UECgwaRUpCQ0EgQ29udGFpbmVyIFF1aWNr c3RhcnQwHhcNMTkxMjEyMTEwMDUxWhcNMjExMjExMTA1OTI1WjBSMSAwHgYJKoZI hvcNAQkBFhFDb21tb25OYW1lQGNuLmNvbTEWMBQGA1UEAwwNQ049Q29tbW9uTmFt ZTEWMBQGA1UECgwNQ29tbW9uQ29tcGFueTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAJtc1vAn9F166nHED5D2E/xoMMFkCJ0RhpXqn9A9RArB20U54TSf nEDuayAGpWIypAnGc1wXCj2ZTWFj48oIRGNy6b2uJ7qHlg7FGwdIGfTP151P0O6W zcb9kFj/KwRkyKu7Z9m7BR3G0MBhGaN4DFAVlAFNqmvIip4PW9cO4zCFGABGQcPx PhWtBt1Dp3wewp38yXN0evMjOTS7naogPCVme7ffqrqsd8ozlcjk5zd2giJPduUO 7puBkt6aynM1cc6kGpbQIHCf9f7L0ZGWDXSP/mr87h/WEDkhzBGa7aoME5gTLToT o0PPHtyfwOGi2KEBVQg0vde5BiKuisJTw2sCAwEAAaOBmzCBmDAMBgNVHRMBAf8E AjAAMB8GA1UdIwQYMBaAFKSoZvZ+ycvTR9MmLcG1sbVLZC19MBkGA1UdEQQSMBCC DkNvbW1vbk5hbWUuY29tMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDBDAd BgNVHQ4EFgQUKgFUjDFajTD1leb7Q2rvvSFvJZAwDgYDVR0PAQH/BAQDAgXgMA0G CSqGSIb3DQEBCwUAA4IBgQBs8knYiqq9GrHG8R0Lh46XTayAddcjN+dX4DHX/Tg9 sBkl1qUXKEUuOaK2JlW+BzLVuy5QtAAJuDc2BVq19hF2NALOiMi6cJUW/gWJi9ug eRqMELwxf44Am/CzQoUp52MVuCj4K9sJ6KLC5jm/GgTyFG+Qy7ZoU6df5Gd1E0iU Qf+tuF77LldMtNcYKbYbBVGDg4O/M221+D2Kq/gfTyWYiB6coiAuiXEjBfgsmCLp h8/JHK6zhq+wOUL0isaekPCK8LvzryHoZ5c1MdVXgDgwErWoZf+PnaUUHSH9DbTR LyWY++TXYLn0xUDZTqJboshDq3C4vqGsUJ4eSCfaAeiyX0RmXvE8DPiKQy7vTOGP 5CzpqnZbHSbKf/L3nbu4q7LZMtHzNhqgnqHVPJE42okHwBEbQX4POnghdujxCuFF gr+8LjQpc+0tlCXqTLeapBIHQDc0ECwWB2fPU1XRVHJB7MOew0OJ2yGgCSeJXO4W pujWO9CVPB49h5LyMPkNdr8= -----END CERTIFICATE----- \ No newline at end of file
diff --git a/certService/src/test/resources/cmpServers.json b/certService/src/test/resources/cmpServers.json
deleted file mode 100644
index ee9e72b9..00000000
--- a/certService/src/test/resources/cmpServers.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "cmpv2Servers": [
- {
- "caName": "TEST",
- "url": "http://127.0.0.1/ejbca/publicweb/cmp/cmp",
- "issuerDN": "CN=ManagementCA",
- "caMode": "CLIENT",
- "authentication": {
- "iak": "xxx",
- "rv": "yyy"
- }
- },
- {
- "caName": "TEST2",
- "url": "http://127.0.0.1/ejbca/publicweb/cmp/cmpRA",
- "issuerDN": "CN=ManagementCA2",
- "caMode": "RA",
- "authentication": {
- "iak": "xxx",
- "rv": "yyy"
- }
- }
- ]
-} \ No newline at end of file
diff --git a/certService/src/test/resources/invalidCmpServers.json b/certService/src/test/resources/invalidCmpServers.json
deleted file mode 100644
index ac4b34af..00000000
--- a/certService/src/test/resources/invalidCmpServers.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "cmpv2Servers": [
- {
- "caName": " ",
- "url": "http://127.0.0.1/ejbca/publicweb/cmp/cmp",
- "issuerDN": "CN=ManagementCA",
- "caMode": "CLIENT"
- },
- {
- "caName": "TEST2",
- "url": "http://127.0.0.1/ejbca/publicweb/cmp/cmpRA",
- "caMode": "RA",
- "authentication": {
- "iak": "xxx",
- "rv": "yyy"
- }
- }
- ]
-} \ No newline at end of file
diff --git a/certService/src/test/resources/privateKey b/certService/src/test/resources/privateKey
deleted file mode 100644
index 216714c9..00000000
--- a/certService/src/test/resources/privateKey
+++ /dev/null
Binary files differ
diff --git a/certService/src/test/resources/publicKey b/certService/src/test/resources/publicKey
deleted file mode 100644
index e5c63be8..00000000
--- a/certService/src/test/resources/publicKey
+++ /dev/null
Binary files differ
diff --git a/certService/src/test/resources/trustedCertificates.first b/certService/src/test/resources/trustedCertificates.first
deleted file mode 100644
index 6b44296d..00000000
--- a/certService/src/test/resources/trustedCertificates.first
+++ /dev/null
Binary files differ
diff --git a/certService/src/test/resources/trustedCertificatesModel.first b/certService/src/test/resources/trustedCertificatesModel.first
deleted file mode 100644
index 390f6e6b..00000000
--- a/certService/src/test/resources/trustedCertificatesModel.first
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEszCCAxugAwIBAgIUGMTLyt0bYrNGz4KPqapEq64XmIIwDQYJKoZIhvcNAQEL
-BQAwYTEjMCEGCgmSJomT8ixkAQEME2MtMDE5MmY0N2VkY2NjZjg5NzYxFTATBgNV
-BAMMDE1hbmFnZW1lbnRDQTEjMCEGA1UECgwaRUpCQ0EgQ29udGFpbmVyIFF1aWNr
-c3RhcnQwHhcNMTkxMjEyMTEwMDUxWhcNMjkxMjExMTEwMDUxWjBhMSMwIQYKCZIm
-iZPyLGQBAQwTYy0wMTkyZjQ3ZWRjY2NmODk3NjEVMBMGA1UEAwwMTWFuYWdlbWVu
-dENBMSMwIQYDVQQKDBpFSkJDQSBDb250YWluZXIgUXVpY2tzdGFydDCCAaIwDQYJ
-KoZIhvcNAQEBBQADggGPADCCAYoCggGBAK2yz/z273gG55p4NvDfg8EZIOFkQmAV
-Vi+gfvyl3zb8KYOBWGAOM8IKMInJP1Gulz2D2qYAL7PlJi87WaMI1mTNL0ca177T
-UOz3C1vuFp5QqcQZP8fbGlQCHawcPwacLm6G4WFHi5tjtuBQS+qn1RrHdnvSMwG7
-1bZll3wLOnU3TOAvDMEbAXCXIwc7wxAluO1e+bCM2VjL8iFvNtEqQ2KY3IKO7aaE
-nEGkTniYg6lBSd/3D04CLVEqinI4sbGV/DX3cULmIsGT5E4b6KMlXrFuzbfj5VtS
-n8awf+EMWm1AHlyM05GhMD8N60nZcoF5/rzrzxPr1Jv9DTl/MRRasqwtmEddbn0e
-OVgB7c5LEbNrnJWt/4sdEBQXX3z4y2HI40iuZmTMP0zPwxWA1v/bmd9EIE2/QKGo
-kMHvvjTRTtdBYGGeeL5TRU2o1YSw6bda57Dv2I3OGA6gNxbH1juG/2W8kg01YL7S
-C49OnY9l3EP0iPHhtNnikuULG+Us1AL+HwIDAQABo2MwYTAPBgNVHRMBAf8EBTAD
-AQH/MB8GA1UdIwQYMBaAFKSoZvZ+ycvTR9MmLcG1sbVLZC19MB0GA1UdDgQWBBSk
-qGb2fsnL00fTJi3BtbG1S2QtfTAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
-BQADggGBAD2z2NNVF1HKei+IGBiClyuSVOIXU86p+BLk4EoIlBvWB6jwB++jBHt5
-EfQhGr8dkRqkd9EG92PDgJklHz6qeogCGdkEQikaN03SwFxk5ig5HW8Fycpffbp/
-dY+QT8IVkx7jJfpe/+unf2FZbaIGcFiL+YFa2Ii6dHKIC5ntIUiKjRsQdbs6EjWU
-sxiozLuAxeD/otReNu2VZze43cZqygEB77cbHT8DSRsAtLUdbNluyTwZOZXKiTlG
-ClBXP4NkNTG+deP1B9k8CZolTn2fyj6KmQdBQ3S1MWIF9IsMbc2vjvbJlRkdX/nl
-lQC6bsvb0VVWnBHiLGpsgsye7eyE0PJ/tAvQNsrhOSxCxaTFBhRExG3Mr9uU7iDj
-PFxnuTACAOv9aAyoBbJnLkN/Mkq3ILTChGY8cLnM3tGnb8fpbXbtMSzGAoLPmsh4
-vvJEjIgi5NTIMqaADsXSAToW61AU2otAQxLvgI03szPxUF1l4Neo1RHJDNwp5yyo
-oYIM2lYI0w==
------END CERTIFICATE-----
diff --git a/certService/version.properties b/certService/version.properties
deleted file mode 100644
index 00ef5645..00000000
--- a/certService/version.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-major=1
-minor=2
-patch=0
-base_version=${major}.${minor}.${patch}
-release_version=${base_version}
-snapshot_version=${base_version}-SNAPSHOT
diff --git a/certServiceClient/Dockerfile b/certServiceClient/Dockerfile
deleted file mode 100644
index 9da47295..00000000
--- a/certServiceClient/Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM docker.io/openjdk:11-jre-slim
-
-ARG VERSION=${version}
-
-RUN groupadd certServiceClient && useradd -g certServiceClient certServiceClient
-
-RUN chown -R certServiceClient:certServiceClient /var/log
-
-USER certServiceClient:certServiceClient
-
-COPY target/aaf-certservice-client-${VERSION}.jar ./opt/onap/aaf/certservice/aaf-certservice-client.jar
-
-ENTRYPOINT ["java","-jar","./opt/onap/aaf/certservice/aaf-certservice-client.jar"]
diff --git a/certServiceClient/README.md b/certServiceClient/README.md
deleted file mode 100644
index b3005345..00000000
--- a/certServiceClient/README.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# Cert service client
-
-### Project building
-```
-mvn clean package
-```
-
-
-### Install the package into the local repository
-```
-mvn clean install
-```
-
-### Building Docker image and install the package into the local repository
-```
-mvn clean install -P docker
-```
-
-### Nexus container image
-```
-nexus3.onap.org:10001/onap/org.onap.aaf.certservice.aaf-certservice-client:latest
-```
-
-### Running local client application as standalone docker container
-CertService API and client must be running in same network.
-
-You need certificate and trust anchors (in JKS format) to connect to CertService API via HTTPS. Information how to generate truststore and keystore files you can find in CertService main README.
-
-Information how to run you can find in CertService main README and official documentation, see [Read The Docs](https://docs.onap.org/projects/onap-aaf-certservice/en/latest/sections/usage.html)
-
-
-### Logs locally
-
-path:
-```
-var/log/onap/aaf/certservice-client/certservice-client.log
-```
-### Logs in Docker container
-```
-docker logs aaf-certservice-client
-```
-###Exit codes
-```
-0 Success
-1 Invalid client configuration
-2 Invalid CSR configuration
-3 Fail in key pair generation
-4 Fail in CSR generation
-5 CertService HTTP unsuccessful response
-6 Internal HTTP Client connection problem
-7 Fail in PEM conversion
-8 Fail in Private Key to PEM Encoding
-9 Wrong TLS configuration
-10 File could not be created
diff --git a/certServiceClient/pom.xml b/certServiceClient/pom.xml
deleted file mode 100644
index e176b18e..00000000
--- a/certServiceClient/pom.xml
+++ /dev/null
@@ -1,185 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>aaf-certservice</artifactId>
- <groupId>org.onap.aaf.certservice</groupId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>aaf-certservice-client</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- <name>aaf-certservice-client</name>
- <description>AAF Certification Service Api Client</description>
- <packaging>jar</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>docker-staging</id>
- <properties>
- <docker.tag>${project.version}-STAGING-${maven.build.timestamp}</docker.tag>
- <docker.latest.tag>${project.version}-STAGING-latest</docker.latest.tag>
- </properties>
- </profile>
-
- <profile>
- <id>docker</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <properties>
- <os.detected.name>linux</os.detected.name>
- <os.detected.arch>x86_64</os.detected.arch>
- <os.detected.classifier>${os.detected.name}-${os.detected.arch}</os.detected.classifier>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>${maven-shade-plugin.version}</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <createDependencyReducedPom>false</createDependencyReducedPom>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- <transformers>
- <transformer
- implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.onap.aaf.certservice.client.MainApp</mainClass>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>${docker-maven-plugin.version}</version>
- <executions>
- <execution>
- <id>docker-build-image</id>
- <phase>package</phase>
- <goals>
- <goal>build</goal>
- </goals>
- </execution>
- <execution>
- <id>docker-push-image</id>
- <phase>deploy</phase>
- <goals>
- <goal>push</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <skipPush>${skipDockerPush}</skipPush>
- <verbose>true</verbose>
- <imagePullPolicy>IfNotPresent</imagePullPolicy>
- <images>
- <image>
- <alias>${project.artifactId}</alias>
- <name>${docker-image.namespace}/${docker-image.name}:${docker-image.tag.latest}
- </name>
- <registry>${docker-image.registry}</registry>
- <build>
- <dockerFileDir>${project.basedir}</dockerFileDir>
- <tags>
- <tag>${project.version}-${maven.build.timestamp}Z</tag>
- </tags>
- </build>
- </image>
- </images>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcpkix-jdk15on</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-junit-jupiter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-log4j2</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/AppExitHandler.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/AppExitHandler.java
deleted file mode 100644
index af30ff3e..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/AppExitHandler.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AppExitHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(AppExitHandler.class);
-
- public void exit(ExitStatus exitStatus) {
- LOGGER.info("Application exits with following exit code: {} and message: {}",
- exitStatus.getExitCodeValue(), exitStatus.getMessage());
- System.exit(exitStatus.getExitCodeValue());
- }
-}
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
deleted file mode 100644
index 56c355e4..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client;
-
-import org.onap.aaf.certservice.client.api.ExitableException;
-import org.onap.aaf.certservice.client.certification.ArtifactsCreatorProvider;
-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.common.Base64Encoder;
-import org.onap.aaf.certservice.client.configuration.EnvsForClient;
-import org.onap.aaf.certservice.client.configuration.EnvsForCsr;
-import org.onap.aaf.certservice.client.configuration.EnvsForTls;
-import org.onap.aaf.certservice.client.configuration.factory.ClientConfigurationFactory;
-import org.onap.aaf.certservice.client.configuration.factory.CsrConfigurationFactory;
-import org.onap.aaf.certservice.client.configuration.factory.SslContextFactory;
-import org.onap.aaf.certservice.client.configuration.model.ClientConfiguration;
-import org.onap.aaf.certservice.client.configuration.model.CsrConfiguration;
-import org.onap.aaf.certservice.client.httpclient.CloseableHttpsClientProvider;
-import org.onap.aaf.certservice.client.httpclient.HttpClient;
-import org.onap.aaf.certservice.client.httpclient.model.CertServiceResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.net.ssl.SSLContext;
-import java.security.KeyPair;
-
-import static org.onap.aaf.certservice.client.api.ExitStatus.SUCCESS;
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.KEY_SIZE;
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.RSA_ENCRYPTION_ALGORITHM;
-
-public class CertServiceClient {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CertServiceClient.class);
-
- private AppExitHandler appExitHandler;
-
- public CertServiceClient(AppExitHandler appExitHandler) {
- this.appExitHandler = appExitHandler;
- }
-
- public void run() {
- KeyPairFactory keyPairFactory = new KeyPairFactory(RSA_ENCRYPTION_ALGORITHM, KEY_SIZE);
- PrivateKeyToPemEncoder pkEncoder = new PrivateKeyToPemEncoder();
- Base64Encoder base64Encoder = new Base64Encoder();
- try {
- ClientConfiguration clientConfiguration = new ClientConfigurationFactory(new EnvsForClient()).create();
- CsrConfiguration csrConfiguration = new CsrConfigurationFactory(new EnvsForCsr()).create();
- KeyPair keyPair = keyPairFactory.create();
- CsrFactory csrFactory = new CsrFactory(csrConfiguration);
- SSLContext sslContext = new SslContextFactory(new EnvsForTls()).create();
-
- CloseableHttpsClientProvider provider = new CloseableHttpsClientProvider(
- sslContext, clientConfiguration.getRequestTimeout());
- HttpClient httpClient = new HttpClient(provider, clientConfiguration.getUrlToCertService());
-
- CertServiceResponse certServiceData =
- httpClient.retrieveCertServiceData(
- clientConfiguration.getCaName(),
- base64Encoder.encode(csrFactory.createCsrInPem(keyPair)),
- base64Encoder.encode(pkEncoder.encodePrivateKeyToPem(keyPair.getPrivate())));
-
- ArtifactsCreatorProvider
- .get(clientConfiguration.getOutputType(),
- clientConfiguration.getCertsOutputPath())
- .create(certServiceData.getCertificateChain(),
- certServiceData.getTrustedCertificates(),
- keyPair.getPrivate());
-
- } catch (ExitableException e) {
- LOGGER.error("Cert Service Client fails in execution: ", e);
- appExitHandler.exit(e.applicationExitStatus());
- }
- appExitHandler.exit(SUCCESS);
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/MainApp.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/MainApp.java
deleted file mode 100644
index 6a29241f..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/MainApp.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client;
-
-public class MainApp {
- public static void main(String[] args) {
- CertServiceClient certServiceClient = new CertServiceClient(new AppExitHandler());
- certServiceClient.run();
- }
-} \ No newline at end of file
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitStatus.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitStatus.java
deleted file mode 100644
index a84485eb..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitStatus.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.api;
-
-public enum ExitStatus {
-
- SUCCESS(0, "Success"),
- CLIENT_CONFIGURATION_EXCEPTION(1, "Invalid client configuration"),
- CSR_CONFIGURATION_EXCEPTION(2, "Invalid CSR configuration"),
- KEY_PAIR_GENERATION_EXCEPTION(3, "Fail in key pair generation"),
- CSR_GENERATION_EXCEPTION(4, "Fail in CSR generation"),
- CERT_SERVICE_API_CONNECTION_EXCEPTION(5, "CertService HTTP unsuccessful response"),
- HTTP_CLIENT_EXCEPTION(6, "Internal HTTP Client connection problem"),
- PEM_CONVERSION_EXCEPTION(7, "Fail in PEM conversion"),
- PK_TO_PEM_ENCODING_EXCEPTION(8, "Fail in Private Key to PEM Encoding"),
- TLS_CONFIGURATION_EXCEPTION(9, "Invalid TLS configuration"),
- FILE_CREATION_EXCEPTION(10, "File could not be created");
-
- private final int value;
- private final String message;
-
- ExitStatus(int value, String message) {
- this.value = value;
- this.message = message;
- }
-
- public int getExitCodeValue() {
- return value;
- }
-
- public String getMessage() {
- return message;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitableException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitableException.java
deleted file mode 100644
index 3a7a542b..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitableException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.api;
-
-public abstract class ExitableException extends Exception {
- public ExitableException(Throwable cause) {
- super(cause);
- }
-
- public ExitableException(String message) {
- super(message);
- }
-
- public abstract ExitStatus applicationExitStatus();
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java
deleted file mode 100644
index 954f3d30..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-import org.onap.aaf.certservice.client.certification.conversion.ArtifactsCreator;
-import org.onap.aaf.certservice.client.certification.conversion.ConvertedArtifactsCreatorFactory;
-import org.onap.aaf.certservice.client.certification.conversion.PemArtifactsCreator;
-import org.onap.aaf.certservice.client.certification.writer.CertFileWriter;
-
-public enum ArtifactsCreatorProvider {
- P12("PKCS12") {
- @Override
- ArtifactsCreator create(String destPath) {
- return ConvertedArtifactsCreatorFactory.createConverter(destPath, getExtension(), getKeyStoreType());
- }
- },
- JKS("JKS") {
- @Override
- ArtifactsCreator create(String destPath) {
- return ConvertedArtifactsCreatorFactory.createConverter(destPath, getExtension(), getKeyStoreType());
- }
- },
- PEM("PEM") {
- @Override
- ArtifactsCreator create(String destPath) {
- return new PemArtifactsCreator(CertFileWriter.createWithDir(destPath), new PrivateKeyToPemEncoder());
- }
- };
-
- private final String keyStoreType;
-
- ArtifactsCreatorProvider(String keyStoreType) {
- this.keyStoreType = keyStoreType;
- }
-
- public static ArtifactsCreator get(String outputType, String destPath) {
- return valueOf(outputType).create(destPath);
- }
-
- String getKeyStoreType() {
- return keyStoreType;
- }
-
- String getExtension() {
- return this.toString().toLowerCase();
- }
-
- abstract ArtifactsCreator create(String destPath);
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/CsrFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/CsrFactory.java
deleted file mode 100644
index 0faf5cab..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/CsrFactory.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.x509.Extension;
-import org.bouncycastle.asn1.x509.Extensions;
-import org.bouncycastle.asn1.x509.ExtensionsGenerator;
-import org.bouncycastle.asn1.x509.GeneralName;
-import org.bouncycastle.asn1.x509.GeneralNames;
-import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
-import org.bouncycastle.operator.ContentSigner;
-import org.bouncycastle.operator.OperatorCreationException;
-import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder;
-import org.onap.aaf.certservice.client.certification.exception.CsrGenerationException;
-import org.onap.aaf.certservice.client.configuration.model.CsrConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.security.auth.x500.X500Principal;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.security.KeyPair;
-import java.util.Optional;
-
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.COMMON_NAME;
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.COUNTRY;
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.LOCATION;
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.ORGANIZATION;
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.ORGANIZATION_UNIT;
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.SIGN_ALGORITHM;
-import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants.STATE;
-
-
-public class CsrFactory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CsrFactory.class);
- private static final String SANS_DELIMITER = ":";
- private final CsrConfiguration configuration;
-
-
- public CsrFactory(CsrConfiguration configuration) {
- this.configuration = configuration;
- }
-
-
- public String createCsrInPem(KeyPair keyPair) throws CsrGenerationException {
- LOGGER.info("Creation of CSR has been started with following parameters: {}", configuration.toString());
- String csrParameters = getMandatoryParameters().append(getOptionalParameters()).toString();
- X500Principal subject = new X500Principal(csrParameters);
- PKCS10CertificationRequest request = createPkcs10Csr(subject, keyPair);
-
- LOGGER.info("Creation of CSR has been completed successfully");
- return convertPkcs10CsrToPem(request);
- }
-
- private StringBuilder getMandatoryParameters() {
- return new StringBuilder(String.format("%s=%s, %s=%s, %s=%s, %s=%s",
- COMMON_NAME, configuration.getCommonName(),
- COUNTRY, configuration.getCountry(),
- STATE, configuration.getState(),
- ORGANIZATION, configuration.getOrganization()));
- }
-
- private String getOptionalParameters() {
- StringBuilder optionalParameters = new StringBuilder();
- Optional.ofNullable(configuration.getOrganizationUnit())
- .filter(CsrFactory::isParameterPresent)
- .map(unit -> optionalParameters.append(String.format(", %s=%s", ORGANIZATION_UNIT, unit)));
- Optional.ofNullable(configuration.getLocation())
- .filter(CsrFactory::isParameterPresent)
- .map(location -> optionalParameters.append(String.format(", %s=%s", LOCATION, location)));
- return optionalParameters.toString();
- }
-
- private PKCS10CertificationRequest createPkcs10Csr(X500Principal subject, KeyPair keyPair) throws CsrGenerationException {
- JcaPKCS10CertificationRequestBuilder builder = new JcaPKCS10CertificationRequestBuilder(subject, keyPair.getPublic());
-
- if (isParameterPresent(configuration.getSans())) {
- builder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, generateSansExtension());
- }
-
- return builder.build(getContentSigner(keyPair));
- }
-
- private ContentSigner getContentSigner(KeyPair keyPair) throws CsrGenerationException {
- ContentSigner contentSigner;
- try {
- contentSigner = new JcaContentSignerBuilder(SIGN_ALGORITHM).build(keyPair.getPrivate());
- } catch (OperatorCreationException e) {
- LOGGER.error("Creation of PKCS10Csr failed, exception message: {}", e.getMessage());
- throw new CsrGenerationException(e);
-
- }
- return contentSigner;
- }
-
- private String convertPkcs10CsrToPem(PKCS10CertificationRequest request) throws CsrGenerationException {
- final StringWriter stringWriter = new StringWriter();
- try (JcaPEMWriter pemWriter = new JcaPEMWriter(stringWriter)) {
- LOGGER.info("Conversion of CSR to PEM has been started");
- pemWriter.writeObject(request);
- } catch (IOException e) {
- LOGGER.error("Conversion to PEM failed, exception message: {}", e.getMessage());
- throw new CsrGenerationException(e);
- }
- return stringWriter.toString();
- }
-
- private Extensions generateSansExtension() throws CsrGenerationException {
- ExtensionsGenerator generator = new ExtensionsGenerator();
- try {
- generator.addExtension(Extension.subjectAlternativeName, false, createGeneralNames());
- } catch (IOException e) {
- LOGGER.error("Generation of SANs parameter failed, exception message: {}", e.getMessage());
- throw new CsrGenerationException(e);
- }
- return generator.generate();
- }
-
- private GeneralNames createGeneralNames() {
- String[] sansTable = this.configuration.getSans().split(SANS_DELIMITER);
- int length = sansTable.length;
- GeneralName[] generalNames = new GeneralName[length];
- for (int i = 0; i < length; i++) {
- generalNames[i] = new GeneralName(GeneralName.dNSName, sansTable[i]);
- }
- return new GeneralNames(generalNames);
- }
-
- private static Boolean isParameterPresent(String parameter) {
- return parameter != null && !"".equals(parameter);
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/EncryptionAlgorithmConstants.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/EncryptionAlgorithmConstants.java
deleted file mode 100644
index 63ede568..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/EncryptionAlgorithmConstants.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-public final class EncryptionAlgorithmConstants {
-
- private EncryptionAlgorithmConstants() {
- }
-
- public static final String RSA_ENCRYPTION_ALGORITHM = "RSA";
- public static final String SIGN_ALGORITHM = "SHA1withRSA";
- public static final int KEY_SIZE = 2048;
-
- public static final String COMMON_NAME = "CN";
- public static final String ORGANIZATION = "O";
- public static final String ORGANIZATION_UNIT = "OU";
- public static final String LOCATION = "L";
- public static final String STATE = "ST";
- public static final String COUNTRY = "C";
-
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/KeyPairFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/KeyPairFactory.java
deleted file mode 100644
index e997cd0d..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/KeyPairFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-import org.onap.aaf.certservice.client.certification.exception.KeyPairGenerationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.NoSuchAlgorithmException;
-
-public class KeyPairFactory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(KeyPairFactory.class);
- private final String encryptionAlgorithm;
- private final int keySize;
-
- public KeyPairFactory(String encryptionAlgorithm, int keySize) {
- this.encryptionAlgorithm = encryptionAlgorithm;
- this.keySize = keySize;
- }
-
- public KeyPair create() throws KeyPairGenerationException {
- try {
- LOGGER.info("KeyPair generation started with algorithm: {} and key size: {}", encryptionAlgorithm, keySize);
- return createKeyPairGenerator().generateKeyPair();
- } catch (NoSuchAlgorithmException e) {
- String errorMessage = String.format("Generation of KeyPair failed, exception message: %s", e.getMessage());
- throw new KeyPairGenerationException(errorMessage);
- }
- }
-
- private KeyPairGenerator createKeyPairGenerator() throws NoSuchAlgorithmException {
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(encryptionAlgorithm);
- keyPairGenerator.initialize(keySize);
- return keyPairGenerator;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoder.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoder.java
deleted file mode 100644
index fa6485e5..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoder.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-
-import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
-import org.bouncycastle.util.io.pem.PemObject;
-import org.onap.aaf.certservice.client.certification.exception.PkEncodingException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.security.PrivateKey;
-
-public class PrivateKeyToPemEncoder {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PrivateKeyToPemEncoder.class);
- private static final String PEM_OBJECT_TYPE = "RSA PRIVATE KEY";
-
- public String encodePrivateKeyToPem(PrivateKey pk) throws PkEncodingException {
- LOGGER.info("Attempt to encode private key to PEM");
- StringWriter stringWriter = new StringWriter();
- try (JcaPEMWriter pemWriter = new JcaPEMWriter(stringWriter)) {
- pemWriter.writeObject(new PemObject(PEM_OBJECT_TYPE, pk.getEncoded()));
- } catch (IOException e) {
- LOGGER.error("Encode of private key to PEM failed. Exception message: {}", e.getMessage());
- throw new PkEncodingException(e);
- }
- return stringWriter.toString();
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreator.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreator.java
deleted file mode 100644
index 428b85aa..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-import java.security.PrivateKey;
-import java.util.List;
-
-public interface ArtifactsCreator {
- void create(List<String> keystoreData, List<String> truststoreData, PrivateKey privateKey)
- throws ExitableException;
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreator.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreator.java
deleted file mode 100644
index 4826732c..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreator.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
-import org.onap.aaf.certservice.client.certification.exception.PemConversionException;
-import org.onap.aaf.certservice.client.certification.writer.CertFileWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.security.PrivateKey;
-import java.util.List;
-
-public class ConvertedArtifactsCreator implements ArtifactsCreator {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ConvertedArtifactsCreator.class);
- private static final String CERTIFICATE_ALIAS = "certificate";
- private static final String TRUSTED_CERTIFICATE_ALIAS = "trusted-certificate-";
- private static final int PASSWORD_LENGTH = 24;
- private static final String PASS_EXT = "pass";
- private static final String KEYSTORE = "keystore";
- private static final String TRUSTSTORE = "truststore";
-
- private final String fileExtension;
- private final RandomPasswordGenerator passwordGenerator;
- private final PemConverter converter;
- private final CertFileWriter fileWriter;
-
- ConvertedArtifactsCreator(CertFileWriter fileWriter, RandomPasswordGenerator passwordGenerator,
- PemConverter converter, String fileExtension) {
- this.passwordGenerator = passwordGenerator;
- this.converter = converter;
- this.fileWriter = fileWriter;
- this.fileExtension = fileExtension;
- }
-
- @Override
- public void create(List<String> keystoreData, List<String> truststoreData, PrivateKey privateKey)
- throws PemConversionException, CertFileWriterException {
- createKeystore(keystoreData, privateKey);
- createTruststore(truststoreData);
- }
-
- private void createKeystore(List<String> data, PrivateKey privateKey)
- throws PemConversionException, CertFileWriterException {
- Password password = passwordGenerator.generate(PASSWORD_LENGTH);
- String keystoreArtifactName = getFilenameWithExtension(KEYSTORE, fileExtension);
- String keystorePass = getFilenameWithExtension(KEYSTORE, PASS_EXT);
-
- LOGGER.debug("Attempt to create keystore files and saving data. File names: {}, {}", keystoreArtifactName, keystorePass);
-
- fileWriter.saveData(converter.convertKeystore(data, password, CERTIFICATE_ALIAS, privateKey), keystoreArtifactName);
- fileWriter.saveData(getPasswordAsBytes(password), keystorePass);
- }
-
- private void createTruststore(List<String> data)
- throws PemConversionException, CertFileWriterException {
- Password password = passwordGenerator.generate(PASSWORD_LENGTH);
- String truststoreArtifactName = getFilenameWithExtension(TRUSTSTORE, fileExtension);
- String truststorePass = getFilenameWithExtension(TRUSTSTORE, PASS_EXT);
-
- LOGGER.debug("Attempt to create truststore files and saving data. File names: {}, {}", truststoreArtifactName, truststorePass);
-
- fileWriter.saveData(converter.convertTruststore(data, password, TRUSTED_CERTIFICATE_ALIAS), truststoreArtifactName);
- fileWriter.saveData(getPasswordAsBytes(password), truststorePass);
- }
-
- private byte[] getPasswordAsBytes(Password password) {
- return password.getCurrentPassword().getBytes();
- }
-
- private String getFilenameWithExtension(String filename, String extension) {
- return String.format("%s.%s", filename, extension);
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java
deleted file mode 100644
index bda796eb..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.onap.aaf.certservice.client.certification.writer.CertFileWriter;
-
-public class ConvertedArtifactsCreatorFactory {
-
- private ConvertedArtifactsCreatorFactory() {
- }
-
- public static ConvertedArtifactsCreator createConverter(String destPath, String fileExtension, String keyStoreType) {
- return new ConvertedArtifactsCreator(
- CertFileWriter.createWithDir(destPath),
- new RandomPasswordGenerator(),
- new PemConverter(keyStoreType),
- fileExtension);
- }
-
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java
deleted file mode 100644
index 6ea1a219..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-class Password {
- // We are excluding this line in Sonar due to fact that
- // PASSWORD_PATTERN does not contain password. This solution
- // is safe.
- private static final String PASSWORD_PATTERN = "[\\w$#]{16,}"; // NOSONAR
- private final String currentPassword;
-
- Password(String currentPassword) {
- this.currentPassword = currentPassword;
- }
-
- String getCurrentPassword() {
- return currentPassword;
- }
-
- char[] toCharArray() {
- return currentPassword.toCharArray();
- }
-
- boolean isCorrectPasswordPattern() {
- return currentPassword.matches(PASSWORD_PATTERN);
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreator.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreator.java
deleted file mode 100644
index 4bec222f..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.onap.aaf.certservice.client.certification.PrivateKeyToPemEncoder;
-import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
-import org.onap.aaf.certservice.client.certification.exception.PkEncodingException;
-import org.onap.aaf.certservice.client.certification.writer.CertFileWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.security.PrivateKey;
-import java.util.List;
-
-public class PemArtifactsCreator implements ArtifactsCreator {
- private static final Logger LOGGER = LoggerFactory.getLogger(PemArtifactsCreator.class);
-
- private static final String KEY_PEM = "key.pem";
- private static final String KEYSTORE_PEM = "keystore.pem";
- private static final String TRUSTSTORE_PEM = "truststore.pem";
-
- private final CertFileWriter writer;
- private final PrivateKeyToPemEncoder pkEncoder;
-
- public PemArtifactsCreator(CertFileWriter writer, PrivateKeyToPemEncoder pkEncoder) {
- this.writer = writer;
- this.pkEncoder = pkEncoder;
- }
-
- @Override
- public void create(List<String> keystoreData, List<String> truststoreData, PrivateKey privateKey)
- throws PkEncodingException, CertFileWriterException {
- LOGGER.debug("Attempt to create PEM private key file and saving data. File name: {}", KEY_PEM);
- writer.saveData(pkEncoder.encodePrivateKeyToPem(privateKey).getBytes(), KEY_PEM);
-
- LOGGER.debug("Attempt to create PEM keystore file and saving data. File name: {}", KEYSTORE_PEM);
- writer.saveData(getDataAsBytes(keystoreData), KEYSTORE_PEM);
-
- LOGGER.debug("Attempt to create PEM truststore file and saving data. File name: {}", TRUSTSTORE_PEM);
- writer.saveData(getDataAsBytes(truststoreData), TRUSTSTORE_PEM);
- }
-
- private byte[] getDataAsBytes(List<String> data) {
- return String.join("\n", data).getBytes();
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemConverter.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemConverter.java
deleted file mode 100644
index 5e82c177..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemConverter.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.bouncycastle.cert.X509CertificateHolder;
-import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.PEMParser;
-import org.onap.aaf.certservice.client.certification.exception.PemConversionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.security.KeyStore;
-import java.security.KeyStore.LoadStoreParameter;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.List;
-import java.util.Optional;
-
-class PemConverter {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PemConverter.class);
- private static final String PASSWORD_ERROR_MSG = "Password should be min. 16 chars long and should contain only alphanumeric characters and special characters like Underscore (_), Dollar ($) and Pound (#)";
- private static final LoadStoreParameter EMPTY_KEYSTORE_CONFIGURATION = null;
- private final String keyStoreType;
-
- public PemConverter(String keyStoreType) {
- this.keyStoreType = keyStoreType;
- }
-
- byte[] convertKeystore(List<String> certificateChain, Password password, String alias, PrivateKey privateKey)
- throws PemConversionException {
- LOGGER.info("Conversion of PEM certificates to " + keyStoreType + " keystore");
- return convert(certificateChain, password, certs -> getKeyStore(alias, password, certs, privateKey));
- }
-
- byte[] convertTruststore(List<String> trustAnchors, Password password, String alias)
- throws PemConversionException {
- LOGGER.info("Conversion of PEM certificates to " + keyStoreType + " truststore");
- return convert(trustAnchors, password, certs -> getTrustStore(alias, certs));
- }
-
- private byte[] convert(List<String> certificates, Password password, StoreEntryOperation operation)
- throws PemConversionException {
- checkPassword(password);
- final Certificate[] X509Certificates = convertToCertificateArray(certificates);
- return getKeyStoreBytes(password, operation, X509Certificates);
- }
-
- private void checkPassword(Password password) throws PemConversionException {
- if (!password.isCorrectPasswordPattern()) {
- LOGGER.error(PASSWORD_ERROR_MSG);
- throw new PemConversionException(PASSWORD_ERROR_MSG);
- }
- }
-
- private byte[] getKeyStoreBytes(Password password, StoreEntryOperation op, Certificate[] x509Certificates)
- throws PemConversionException {
- try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
- KeyStore ks = op.getStore(x509Certificates);
- ks.store(bos, password.toCharArray());
- return bos.toByteArray();
- } catch (IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException e) {
- LOGGER.error("Pem to " + keyStoreType + " converter failed, exception message: {}", e.getMessage());
- throw new PemConversionException(e);
- }
- }
-
- private KeyStore getKeyStore(String alias, Password password, Certificate[] certificates, PrivateKey privateKey)
- throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
- KeyStore ks = getKeyStoreInstance();
- ks.setKeyEntry(alias, privateKey, password.toCharArray(), certificates);
- return ks;
- }
-
- private KeyStore getTrustStore(String alias, Certificate[] certificates)
- throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
- KeyStore ks = getKeyStoreInstance();
- long index = 1L;
- for (Certificate c : certificates) {
- ks.setCertificateEntry(alias + index++, c);
- }
- return ks;
- }
-
- private KeyStore getKeyStoreInstance()
- throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
- KeyStore ks = KeyStore.getInstance(keyStoreType);
- ks.load(EMPTY_KEYSTORE_CONFIGURATION);
- return ks;
- }
-
- private Certificate[] convertToCertificateArray(List<String> certificates)
- throws PemConversionException {
- Certificate[] parsedCertificates = new Certificate[certificates.size()];
- for (String certificate : certificates) {
- parsedCertificates[certificates.indexOf(certificate)] = parseCertificate(certificate);
- }
- return parsedCertificates;
- }
-
- private Certificate parseCertificate(String certificate) throws PemConversionException {
- try (PEMParser pem = new PEMParser(new StringReader(certificate))) {
- X509CertificateHolder certHolder = Optional.ofNullable((X509CertificateHolder) pem.readObject())
- .orElseThrow(
- () -> new PemConversionException("The certificate couldn't be parsed correctly. " + certificate));
- return new JcaX509CertificateConverter()
- .setProvider(new BouncyCastleProvider())
- .getCertificate(certHolder);
- } catch (IOException | CertificateException e) {
- LOGGER.error("Certificates conversion failed, exception message: {}", e.getMessage());
- throw new PemConversionException(e);
- }
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGenerator.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGenerator.java
deleted file mode 100644
index 8ad85d2c..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGenerator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.apache.commons.lang3.RandomStringUtils;
-
-import java.security.SecureRandom;
-
-class RandomPasswordGenerator {
-
- private static final String ALPHA = "abcdefghijklmnopqrstuvwxyz";
- private static final String NUMBERS = "0123456789";
- private static final String SPECIAL_CHARS = "_$#";
- private static final char[] SET_OF_CHARS = (ALPHA + ALPHA.toUpperCase() + NUMBERS + SPECIAL_CHARS).toCharArray();
- private static final char START_POSITION_IN_ASCII_CHARS = 0;
- private static final char END_POSITION_IN_ASCII_CHARS = 0;
- private static final boolean USE_LETTERS_ONLY = false;
- private static final boolean USE_NUMBERS_ONLY = false;
-
- // We are excluding this line in Sonar due to fact that
- //we are using new SecureRandom which provides
- //cryptographic security
- Password generate(int passwordLength) {
- return new Password(RandomStringUtils.random(//NOSONAR
- passwordLength,
- START_POSITION_IN_ASCII_CHARS,
- END_POSITION_IN_ASCII_CHARS,
- USE_LETTERS_ONLY,
- USE_NUMBERS_ONLY,
- SET_OF_CHARS,
- new SecureRandom())
- );
- }
-}
-
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/StoreEntryOperation.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/StoreEntryOperation.java
deleted file mode 100644
index 7a41d1fe..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/StoreEntryOperation.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-
-@FunctionalInterface
-public interface StoreEntryOperation {
-
- KeyStore getStore(Certificate[] certificates)
- throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException;
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/CertFileWriterException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/CertFileWriterException.java
deleted file mode 100644
index 7912f6d7..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/CertFileWriterException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class CertFileWriterException extends ExitableException {
-
- public CertFileWriterException(Throwable cause) {
- super(cause);
- }
-
- @Override
- public ExitStatus applicationExitStatus() {
- return ExitStatus.FILE_CREATION_EXCEPTION;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/CsrGenerationException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/CsrGenerationException.java
deleted file mode 100644
index ba501cd6..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/CsrGenerationException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class CsrGenerationException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.CSR_GENERATION_EXCEPTION;
-
- public CsrGenerationException(Throwable cause) {
- super(cause);
- }
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/KeyPairGenerationException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/KeyPairGenerationException.java
deleted file mode 100644
index 11030ff3..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/KeyPairGenerationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class KeyPairGenerationException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.KEY_PAIR_GENERATION_EXCEPTION;
-
- public KeyPairGenerationException(String errorMessage) {
- super(errorMessage);
- }
-
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PemConversionException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PemConversionException.java
deleted file mode 100644
index cad3388b..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PemConversionException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class PemConversionException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.PEM_CONVERSION_EXCEPTION;
-
- public PemConversionException(Throwable cause) {
- super(cause);
- }
-
- public PemConversionException(String message) {
- super(message);
- }
-
- @Override
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PkEncodingException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PkEncodingException.java
deleted file mode 100644
index 89976bf3..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PkEncodingException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class PkEncodingException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.PK_TO_PEM_ENCODING_EXCEPTION;
-
- public PkEncodingException(Throwable cause) {
- super(cause);
- }
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java
deleted file mode 100644
index fec3ebd3..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.writer;
-
-import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.file.Path;
-
-public class CertFileWriter {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CertFileWriter.class);
- private final String destPath;
-
- private CertFileWriter(String destPath) {
- this.destPath = destPath;
- }
-
- public static CertFileWriter createWithDir(String destPath) {
- createDirIfNotExists(destPath);
- return new CertFileWriter(destPath);
- }
-
- public void saveData(byte[] data, String filename) throws CertFileWriterException {
- LOGGER.debug("Attempt to save file {} in path {}", filename, destPath);
- try (FileOutputStream outputStream = new FileOutputStream(Path.of(destPath, filename).toString())) {
- outputStream.write(data);
- } catch (IOException e) {
- LOGGER.error("File creation failed, exception message: {}", e.getMessage());
- throw new CertFileWriterException(e);
- }
- }
-
- private static void createDirIfNotExists(String destPath) {
- File destFolderPath = new File(destPath);
- if (!destFolderPath.exists()) {
- LOGGER.debug("Destination path not exists, subdirectories are created");
- destFolderPath.mkdirs();
- }
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/common/Base64Encoder.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/common/Base64Encoder.java
deleted file mode 100644
index bfa43071..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/common/Base64Encoder.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.common;
-
-import org.bouncycastle.util.encoders.Base64;
-
-public class Base64Encoder {
- public String encode(String string) {
- return new String(Base64.encode(string.getBytes()));
- }
-} \ No newline at end of file
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
deleted file mode 100644
index f8a0e91a..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-public enum ClientConfigurationEnvs {
- REQUEST_URL,
- REQUEST_TIMEOUT,
- OUTPUT_PATH,
- CA_NAME,
- OUTPUT_TYPE
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/CsrConfigurationEnvs.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/CsrConfigurationEnvs.java
deleted file mode 100644
index d1cfcd5a..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/CsrConfigurationEnvs.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-public enum CsrConfigurationEnvs {
- COMMON_NAME,
- ORGANIZATION,
- ORGANIZATION_UNIT,
- LOCATION,
- STATE,
- COUNTRY,
- SANS
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java
deleted file mode 100644
index 15339bbd..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-import java.util.Optional;
-
-public class EnvProvider {
- public Optional<String> readEnvVariable(String envVariableName) {
- return Optional.ofNullable(getSystemEnv(envVariableName))
- .filter(EnvProvider::isEnvPresent);
- }
-
- String getSystemEnv(String envVariableName) {
- return System.getenv(envVariableName);
- }
-
- private static Boolean isEnvPresent(String envValue) {
- return !"".equals(envValue);
- }
-}
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
deleted file mode 100644
index 9321964c..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-import java.util.Optional;
-
-public class EnvsForClient {
- private final EnvProvider envProvider = new EnvProvider();
-
- public Optional<String> getUrlToCertService() {
- return readEnv(ClientConfigurationEnvs.REQUEST_URL);
- }
-
- public Optional<String> getRequestTimeOut() {
- return readEnv(ClientConfigurationEnvs.REQUEST_TIMEOUT);
- }
-
- public Optional<String> getOutputPath() {
- return readEnv(ClientConfigurationEnvs.OUTPUT_PATH);
- }
-
- public Optional<String> getCaName() {
- 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/EnvsForCsr.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForCsr.java
deleted file mode 100644
index 9a892b24..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForCsr.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-import java.util.Optional;
-
-public class EnvsForCsr {
- private final EnvProvider envProvider = new EnvProvider();
-
- public Optional<String> getCommonName() {
- return readEnv(CsrConfigurationEnvs.COMMON_NAME);
- }
-
- public Optional<String> getOrganization() {
- return readEnv(CsrConfigurationEnvs.ORGANIZATION);
- }
-
- public Optional<String> getOrganizationUnit() {
- return readEnv(CsrConfigurationEnvs.ORGANIZATION_UNIT);
- }
-
- public Optional<String> getLocation() {
- return readEnv(CsrConfigurationEnvs.LOCATION);
- }
-
- public Optional<String> getState() {
- return readEnv(CsrConfigurationEnvs.STATE);
- }
-
- public Optional<String> getCountry() {
- return readEnv(CsrConfigurationEnvs.COUNTRY);
- }
-
- public Optional<String> getSubjectAlternativesName() {
- return readEnv(CsrConfigurationEnvs.SANS);
- }
-
- Optional<String> readEnv(CsrConfigurationEnvs envName) {
- return envProvider.readEnvVariable(envName.toString());
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForTls.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForTls.java
deleted file mode 100644
index 55b536a7..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForTls.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-import java.util.Optional;
-
-public class EnvsForTls {
- private final EnvProvider envProvider = new EnvProvider();
-
- public Optional<String> getKeystorePath() {
- return readEnv(TlsConfigurationEnvs.KEYSTORE_PATH);
- }
-
- public Optional<String> getKeystorePassword() {
- return readEnv(TlsConfigurationEnvs.KEYSTORE_PASSWORD);
- }
-
- public Optional<String> getTruststorePath() {
- return readEnv(TlsConfigurationEnvs.TRUSTSTORE_PATH);
- }
-
- public Optional<String> getTruststorePassword() {
- return readEnv(TlsConfigurationEnvs.TRUSTSTORE_PASSWORD);
- }
-
- Optional<String> readEnv(TlsConfigurationEnvs envName) {
- return envProvider.readEnvVariable(envName.toString());
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/TlsConfigurationEnvs.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/TlsConfigurationEnvs.java
deleted file mode 100644
index 4009a088..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/TlsConfigurationEnvs.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-public enum TlsConfigurationEnvs {
- KEYSTORE_PATH,
- KEYSTORE_PASSWORD,
- TRUSTSTORE_PATH,
- TRUSTSTORE_PASSWORD
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java
deleted file mode 100644
index ea280736..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class ClientConfigurationException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.CLIENT_CONFIGURATION_EXCEPTION;
-
- public ClientConfigurationException(String message) {
- super(message);
- }
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java
deleted file mode 100644
index cf785a71..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class CsrConfigurationException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.CSR_CONFIGURATION_EXCEPTION;
-
- public CsrConfigurationException(String message) {
- super(message);
- }
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationException.java
deleted file mode 100644
index 91f164e3..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class TlsConfigurationException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.TLS_CONFIGURATION_EXCEPTION;
-
- public TlsConfigurationException(String message) {
- super(message);
- }
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
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
deleted file mode 100644
index 24ed8b0d..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.factory;
-
-
-import org.onap.aaf.certservice.client.certification.ArtifactsCreatorProvider;
-import org.onap.aaf.certservice.client.configuration.exception.ClientConfigurationException;
-import org.onap.aaf.certservice.client.configuration.exception.CsrConfigurationException;
-import org.onap.aaf.certservice.client.configuration.model.ConfigurationModel;
-
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.regex.Pattern;
-
-public abstract class AbstractConfigurationFactory<T extends ConfigurationModel> {
-
- abstract T create() throws ClientConfigurationException, CsrConfigurationException;
-
- public boolean isPathValid(String path) {
- return path.matches("^/|(/[a-zA-Z0-9_-]+)+/?$");
- }
-
- public boolean isAlphaNumeric(String caName) {
- return caName.matches("^[a-zA-Z0-9]*$");
- }
-
- public boolean isCommonNameValid(String commonName) {
- return !isSpecialCharsPresent(commonName)
- && !isHttpProtocolsPresent(commonName)
- && !isIpAddressPresent(commonName)
- && !isPortNumberPresent(commonName);
- }
-
- public boolean isSpecialCharsPresent(String stringToCheck) {
- return Pattern.compile("[~#@*$+%!()?/{}<>\\|_^]").matcher(stringToCheck).find();
- }
-
- public boolean isCountryValid(String country) {
- return Arrays.asList(Locale.getISOCountries()).contains(country);
- }
-
- public boolean isOutputTypeValid(String outputType) {
- return Arrays.stream(ArtifactsCreatorProvider.values())
- .map(ArtifactsCreatorProvider::toString)
- .anyMatch(name -> name.equals(outputType));
- }
-
- private boolean isPortNumberPresent(String stringToCheck) {
- return Pattern.compile(":[0-9]{1,5}").matcher(stringToCheck).find();
- }
-
- private boolean isIpAddressPresent(String stringToCheck) {
- return Pattern.compile("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}").matcher(stringToCheck).find();
- }
-
- private boolean isHttpProtocolsPresent(String stringToCheck) {
- return Pattern.compile("[h][t][t][p][:][/][/]|[h][t][t][p][s][:][/][/]").matcher(stringToCheck).find();
- }
-}
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
deleted file mode 100644
index d8498d84..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.factory;
-
-import org.onap.aaf.certservice.client.configuration.ClientConfigurationEnvs;
-import org.onap.aaf.certservice.client.configuration.EnvsForClient;
-import org.onap.aaf.certservice.client.configuration.exception.ClientConfigurationException;
-import org.onap.aaf.certservice.client.configuration.model.ClientConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Optional;
-
-public class ClientConfigurationFactory extends AbstractConfigurationFactory<ClientConfiguration> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ClientConfigurationFactory.class);
- private final EnvsForClient envsForClient;
-
- public ClientConfigurationFactory(EnvsForClient envsForClient) {
- this.envsForClient = envsForClient;
- }
-
- @Override
- public ClientConfiguration create() throws ClientConfigurationException {
-
- ClientConfiguration configuration = new ClientConfiguration();
-
-
- envsForClient.getUrlToCertService()
- .map(configuration::setUrlToCertService);
-
- envsForClient.getRequestTimeOut()
- .map(timeout -> configuration.setRequestTimeout(Integer.valueOf(timeout)));
-
- envsForClient.getOutputPath()
- .filter(this::isPathValid)
- .map(configuration::setCertsOutputPath)
- .orElseThrow(() -> new ClientConfigurationException(ClientConfigurationEnvs.OUTPUT_PATH + " is invalid."));
-
- envsForClient.getCaName()
- .filter(this::isAlphaNumeric)
- .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)
- .orElseThrow(() -> new ClientConfigurationException(ClientConfigurationEnvs.OUTPUT_TYPE + " is invalid."));
- }
-
- 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/factory/CsrConfigurationFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactory.java
deleted file mode 100644
index 1d4cf2b2..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.factory;
-
-import org.onap.aaf.certservice.client.configuration.CsrConfigurationEnvs;
-import org.onap.aaf.certservice.client.configuration.EnvsForCsr;
-import org.onap.aaf.certservice.client.configuration.exception.CsrConfigurationException;
-import org.onap.aaf.certservice.client.configuration.model.CsrConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class CsrConfigurationFactory extends AbstractConfigurationFactory<CsrConfiguration> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CsrConfigurationFactory.class);
- private final EnvsForCsr envsForCsr;
-
- public CsrConfigurationFactory(EnvsForCsr envsForCsr) {
- this.envsForCsr = envsForCsr;
- }
-
- @Override
- public CsrConfiguration create() throws CsrConfigurationException {
-
- CsrConfiguration configuration = new CsrConfiguration();
-
- envsForCsr.getCommonName()
- .filter(this::isCommonNameValid)
- .map(configuration::setCommonName)
- .orElseThrow(() -> new CsrConfigurationException(CsrConfigurationEnvs.COMMON_NAME + " is invalid."));
-
- envsForCsr.getOrganization()
- .filter(org -> !isSpecialCharsPresent(org))
- .map(configuration::setOrganization)
- .orElseThrow(() -> new CsrConfigurationException(CsrConfigurationEnvs.ORGANIZATION + " is invalid."));
-
- envsForCsr.getState()
- .map(configuration::setState)
- .orElseThrow(() -> new CsrConfigurationException(CsrConfigurationEnvs.STATE + " is invalid."));
-
- envsForCsr.getCountry()
- .filter(this::isCountryValid)
- .map(configuration::setCountry)
- .orElseThrow(() -> new CsrConfigurationException(CsrConfigurationEnvs.COUNTRY + " is invalid."));
-
- envsForCsr.getOrganizationUnit()
- .map(configuration::setOrganizationUnit);
-
- envsForCsr.getLocation()
- .map(configuration::setLocation);
-
- envsForCsr.getSubjectAlternativesName()
- .map(configuration::setSubjectAlternativeNames);
-
- LOGGER.info("Successful validation of CSR configuration. Configuration data: {}", configuration.toString());
-
- return configuration;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactory.java
deleted file mode 100644
index 7da8fa58..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactory.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.factory;
-
-import org.apache.http.ssl.SSLContexts;
-import org.onap.aaf.certservice.client.configuration.EnvsForTls;
-import org.onap.aaf.certservice.client.configuration.TlsConfigurationEnvs;
-import org.onap.aaf.certservice.client.configuration.exception.TlsConfigurationException;
-
-import javax.net.ssl.SSLContext;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-
-public class SslContextFactory {
-
- private static final String JKS = "jks";
-
- private EnvsForTls envsForTls;
-
- public SslContextFactory(EnvsForTls envsForTls) {
- this.envsForTls = envsForTls;
- }
-
- public SSLContext create() throws TlsConfigurationException {
- String keystorePath = envsForTls.getKeystorePath()
- .orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.KEYSTORE_PATH)));
- String keystorePassword = envsForTls.getKeystorePassword()
- .orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.KEYSTORE_PASSWORD)));
- String truststorePath = envsForTls.getTruststorePath()
- .orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.TRUSTSTORE_PATH)));
- String truststorePassword = envsForTls.getTruststorePassword()
- .orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.TRUSTSTORE_PASSWORD)));
-
- return createSslContext(keystorePath, keystorePassword, truststorePath, truststorePassword);
- }
-
- private String createEnvMissingMessage(TlsConfigurationEnvs keystorePath) {
- return String.format("%s env is missing.", keystorePath);
- }
-
- private KeyStore setupKeystore(String keystorePath, String certPassword)
- throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
- KeyStore keyStore = KeyStore.getInstance(JKS);
- FileInputStream identityKeyStoreFile = new FileInputStream(new File(
- keystorePath));
- keyStore.load(identityKeyStoreFile, certPassword.toCharArray());
- return keyStore;
- }
-
- private SSLContext createSslContext(String keystorePath, String keystorePassword, String truststorePath, String truststorePassword) throws TlsConfigurationException {
- try {
- KeyStore identityKeystore = setupKeystore(keystorePath, keystorePassword);
- KeyStore trustKeystore = setupKeystore(truststorePath, truststorePassword);
-
- return SSLContexts.custom()
- .loadKeyMaterial(identityKeystore, keystorePassword.toCharArray())
- .loadTrustMaterial(trustKeystore, null)
- .build();
- } catch (Exception e) {
- throw new TlsConfigurationException("TLS configuration exception: " + e);
- }
- }
-}
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
deleted file mode 100644
index 78fa1b4b..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.model;
-
-import org.onap.aaf.certservice.client.configuration.ClientConfigurationEnvs;
-
-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;
- }
-
-
- public String getUrlToCertService() {
- return urlToCertService;
- }
-
- public ClientConfiguration setUrlToCertService(String urlToCertService) {
- this.urlToCertService = urlToCertService;
- return this;
- }
-
- public Integer getRequestTimeout() {
- return requestTimeout;
- }
-
- public ClientConfiguration setRequestTimeout(Integer requestTimeout) {
- this.requestTimeout = requestTimeout;
- return this;
- }
-
- public String getCertsOutputPath() {
- return certsOutputPath;
- }
-
- public ClientConfiguration setCertsOutputPath(String certsOutputPath) {
- this.certsOutputPath = certsOutputPath;
- return this;
- }
-
- public String getCaName() {
- return caName;
- }
-
- public ClientConfiguration setCaName(String caName) {
- this.caName = caName;
- 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, %s: %s",
- ClientConfigurationEnvs.REQUEST_URL, urlToCertService,
- ClientConfigurationEnvs.REQUEST_TIMEOUT, requestTimeout,
- ClientConfigurationEnvs.OUTPUT_PATH, certsOutputPath,
- ClientConfigurationEnvs.CA_NAME, caName,
- ClientConfigurationEnvs.OUTPUT_TYPE, outputType);
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ConfigurationModel.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ConfigurationModel.java
deleted file mode 100644
index 15c22233..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ConfigurationModel.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.model;
-
-public interface ConfigurationModel {
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java
deleted file mode 100644
index 55f33c9f..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.model;
-
-
-import org.onap.aaf.certservice.client.configuration.CsrConfigurationEnvs;
-
-public class CsrConfiguration implements ConfigurationModel {
-
- private String commonName;
- private String organization;
- private String state;
- private String country;
- private String organizationUnit;
- private String location;
- private String sans;
-
-
- public String getCommonName() {
- return commonName;
- }
-
- public CsrConfiguration setCommonName(String commonName) {
- this.commonName = commonName;
- return this;
- }
-
- public String getOrganization() {
- return organization;
- }
-
- public CsrConfiguration setOrganization(String organization) {
- this.organization = organization;
- return this;
- }
-
- public String getState() {
- return state;
- }
-
- public CsrConfiguration setState(String state) {
- this.state = state;
- return this;
- }
-
- public String getCountry() {
- return country;
- }
-
- public CsrConfiguration setCountry(String country) {
- this.country = country;
- return this;
- }
-
- public String getOrganizationUnit() {
- return organizationUnit;
- }
-
- public CsrConfiguration setOrganizationUnit(String organizationUnit) {
- this.organizationUnit = organizationUnit;
- return this;
- }
-
- public String getLocation() {
- return location;
- }
-
- public CsrConfiguration setLocation(String location) {
- this.location = location;
- return this;
- }
-
- public String getSans() {
- return sans;
- }
-
- public CsrConfiguration setSubjectAlternativeNames(String subjectAlternativeNames) {
- this.sans = subjectAlternativeNames;
- return this;
- }
-
- @Override
- public String toString() {
- return String.format("%s: %s, %s: %s, %s: %s, %s: %s, %s: %s, %s: %s, %s: %s",
- CsrConfigurationEnvs.COMMON_NAME, commonName,
- CsrConfigurationEnvs.COUNTRY, country,
- CsrConfigurationEnvs.STATE, state,
- CsrConfigurationEnvs.ORGANIZATION, organization,
- CsrConfigurationEnvs.ORGANIZATION_UNIT, organizationUnit,
- CsrConfigurationEnvs.LOCATION, location,
- CsrConfigurationEnvs.SANS, sans);
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/CloseableHttpsClientProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/CloseableHttpsClientProvider.java
deleted file mode 100644
index 3b7a46ab..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/CloseableHttpsClientProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.httpclient;
-
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-
-import javax.net.ssl.SSLContext;
-
-public class CloseableHttpsClientProvider {
-
- private final int timeout;
- private final SSLContext sslContext;
-
- public CloseableHttpsClientProvider(SSLContext sslContext, int timeout) {
- this.sslContext = sslContext;
- this.timeout = timeout;
- }
-
- public CloseableHttpClient getClient() {
- RequestConfig config =
- RequestConfig.custom()
- .setConnectionRequestTimeout(timeout)
- .setConnectTimeout(timeout)
- .setSocketTimeout(timeout)
- .build();
-
- return HttpClientBuilder.create()
- .setSSLContext(sslContext)
- .setDefaultRequestConfig(config).build();
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java
deleted file mode 100644
index 0780afad..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.httpclient;
-
-import com.google.gson.Gson;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.util.EntityUtils;
-import org.onap.aaf.certservice.client.httpclient.exception.CertServiceApiResponseException;
-import org.onap.aaf.certservice.client.httpclient.exception.HttpClientException;
-import org.onap.aaf.certservice.client.httpclient.model.CertServiceResponse;
-import org.onap.aaf.certservice.client.httpclient.model.ErrorCertServiceResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-public class HttpClient {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HttpClient.class);
- private static final String CSR_HEADER_NAME = "CSR";
- private static final String PK_HEADER_NAME = "PK";
- private static final String CHARSET_UTF_8 = "UTF-8";
-
- private final Gson gson = new Gson();
- private final CloseableHttpsClientProvider httpClientProvider;
- private final String certServiceAddress;
-
- public HttpClient(CloseableHttpsClientProvider httpClientProvider, String certServiceAddress) {
- this.httpClientProvider = httpClientProvider;
- this.certServiceAddress = certServiceAddress;
- }
-
- public CertServiceResponse retrieveCertServiceData(String caName, String csr, String encodedPk)
- throws CertServiceApiResponseException, HttpClientException {
-
- try (CloseableHttpClient httpClient = httpClientProvider.getClient()) {
- LOGGER.info("Attempt to send request to API, on url: {}{} ", certServiceAddress, caName);
- HttpResponse httpResponse = httpClient.execute(createHttpRequest(caName, csr, encodedPk));
- LOGGER.info("Received response from API");
- return extractCertServiceResponse(httpResponse);
-
- } catch (IOException e) {
- LOGGER.error("Failed execute request to API for URL: {}{} , exception message: {}",
- certServiceAddress, caName, e.getMessage());
- throw new HttpClientException(e);
- }
- }
-
- private HttpGet createHttpRequest(String caName, String csr, String pk) {
- String url = certServiceAddress + caName;
- HttpGet httpGet = new HttpGet(url);
- httpGet.addHeader(CSR_HEADER_NAME, csr);
- httpGet.addHeader(PK_HEADER_NAME, pk);
- return httpGet;
- }
-
- private CertServiceResponse extractCertServiceResponse(HttpResponse httpResponse)
- throws CertServiceApiResponseException, HttpClientException {
- int httpResponseCode = getStatusCode(httpResponse);
- if (HttpStatus.SC_OK != httpResponseCode) {
- LOGGER.error("Error on API response. Response Code: {}", httpResponseCode);
- throw generateApiResponseException(httpResponse);
- }
- String jsonResponse = getStringResponse(httpResponse.getEntity());
- return gson.fromJson(jsonResponse, CertServiceResponse.class);
- }
-
- private CertServiceApiResponseException generateApiResponseException(HttpResponse httpResponse)
- throws HttpClientException {
- String stringResponse = getStringResponse(httpResponse.getEntity());
- ErrorCertServiceResponse errorCertServiceResponse =
- gson.fromJson(stringResponse, ErrorCertServiceResponse.class);
-
- return new CertServiceApiResponseException(getStatusCode(httpResponse), errorCertServiceResponse.getMessage());
- }
-
- private int getStatusCode(HttpResponse httpResponse) {
- return httpResponse.getStatusLine().getStatusCode();
- }
-
- private String getStringResponse(HttpEntity httpEntity) throws HttpClientException {
- try {
- return EntityUtils.toString(httpEntity, CHARSET_UTF_8);
- } catch (IOException e) {
- LOGGER.error("Cannot parse response to string, exception message: {}", e.getMessage());
- throw new HttpClientException(e);
- }
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java
deleted file mode 100644
index ad5a5f1c..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.httpclient.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class CertServiceApiResponseException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.CERT_SERVICE_API_CONNECTION_EXCEPTION;
-
- public CertServiceApiResponseException(int responseCode, String messageFromApi) {
-
- super(String.format("CertService HTTP unsuccessful response. Response code: %d . Message from Service: %s",
- responseCode,
- messageFromApi));
- }
-
- @Override
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java
deleted file mode 100644
index e9f0f0ad..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.httpclient.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class HttpClientException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.HTTP_CLIENT_EXCEPTION;
-
- public HttpClientException(Throwable cause) {
- super(cause);
- }
-
- @Override
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/CertServiceResponse.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/CertServiceResponse.java
deleted file mode 100644
index 4ca17999..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/CertServiceResponse.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.httpclient.model;
-
-import java.util.Collections;
-import java.util.List;
-
-public class CertServiceResponse {
-
- private final List<String> certificateChain;
- private final List<String> trustedCertificates;
-
- public CertServiceResponse(List<String> certificateChain, List<String> trustedCertificates) {
- this.certificateChain = certificateChain;
- this.trustedCertificates = trustedCertificates;
- }
-
- public List<String> getCertificateChain() {
- return Collections.unmodifiableList(certificateChain);
- }
-
- public List<String> getTrustedCertificates() {
- return Collections.unmodifiableList(trustedCertificates);
- }
-
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/ErrorCertServiceResponse.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/ErrorCertServiceResponse.java
deleted file mode 100644
index 4a9efcb4..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/ErrorCertServiceResponse.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.httpclient.model;
-
-public class ErrorCertServiceResponse {
-
- private final String errorMessage;
-
- public ErrorCertServiceResponse(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public String getMessage() {
- return errorMessage;
- }
-
-}
diff --git a/certServiceClient/src/main/resources/log4j2.xml b/certServiceClient/src/main/resources/log4j2.xml
deleted file mode 100644
index bf4b6239..00000000
--- a/certServiceClient/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<Configuration status="INFO">
-
- <Appenders>
- <Console name="CONSOLE" target="SYSTEM_OUT">
- <PatternLayout
- pattern="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} %highlight{${LOG_LEVEL_PATTERN:-%5p}}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=green, DEBUG=green bold, TRACE=blue} %style{%pid}{magenta} [%15.15t] %style{%-40.40C{1.}}{cyan} : %m%n%throwable"/>
- </Console>
-
- <RollingFile fileName="var/log/onap/aaf/certservice-client/certservice-client.log"
- filePattern="logs/certservice-client-%d{yyyy-MM-dd}-%i.log" name="ROLLING_FILE">
- <PatternLayout pattern="[%d{ISO8601}][%-5p][%-5c] %m%n"/>
- <Policies>
- <SizeBasedTriggeringPolicy size="64 MB"/>
- </Policies>
- <DefaultRolloverStrategy max="10"/>
- </RollingFile>
-
- </Appenders>
-
- <Loggers>
-
- <Logger name="reactor.netty" level="WARN"/>
- <Logger name="reactor.netty.tcp.TcpServer" level="OFF"/>
- <Logger name="io.netty" level="INFO"/>
- <Logger name="io.netty.util" level="WARN"/>
-
- <Root level="DEBUG">
- <AppenderRef ref="CONSOLE"/>
- <AppenderRef ref="ROLLING_FILE"/>
- </Root>
-
- </Loggers>
-</Configuration> \ No newline at end of file
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CerServiceRequestTestData.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CerServiceRequestTestData.java
deleted file mode 100644
index 8f252c31..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CerServiceRequestTestData.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-public final class CerServiceRequestTestData {
-
- private static final String RESOURCE_PATH = "src/test/resources/";
-
- // Request parameters
- public static final String CA_NAME = "TestCA";
- public static final String CSR = getCsrValue();
- public static final String PK = getPkValue();
-
- // Correct response data
- public static final String CORRECT_RESPONSE = getCorrectResponse();
- public static final String EXPECTED_FIRST_ELEMENT_OF_CERTIFICATE_CHAIN =
- getExpectedFirstElementOfCertificateChain();
- public static final String EXPECTED_FIRST_ELEMENT_OF_TRUSTED_CERTIFICATES =
- getExpectedFirstElementOfTrustedCertificates();
-
- // Error response data
- public static final String MISSING_PK_RESPONSE = getMissingPkResponse();
-
- private CerServiceRequestTestData() {
- }
-
- private static String getMissingPkResponse() {
- String fileName = "missingPkResponse";
- return readFromFile(RESOURCE_PATH + fileName);
- }
-
- private static String getExpectedFirstElementOfTrustedCertificates() {
-
- String fileName = "expectedFirstElementOfTrustedCertificates";
- return readFromFile(RESOURCE_PATH + fileName);
- }
-
- private static String getExpectedFirstElementOfCertificateChain() {
- String fileName = "expectedFirstElementOfCertificateChain";
- return readFromFile(RESOURCE_PATH + fileName);
- }
-
- private static String getCorrectResponse() {
- String fileName = "correctResponse";
- return readFromFile(RESOURCE_PATH + fileName);
- }
-
- private static String getPkValue() {
- String fileName = "testPk";
- return readFromFile(RESOURCE_PATH + fileName);
- }
-
- private static String getCsrValue() {
- String fileName = "testCsr";
- return readFromFile(RESOURCE_PATH + fileName);
- }
-
- private static String readFromFile(String path) {
- try {
- return Files.readString(Paths.get(path), StandardCharsets.UTF_8);
- } catch (IOException e) {
- e.printStackTrace();
- return "File not found";
- }
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java
deleted file mode 100644
index 9e256f98..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Spy;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.verify;
-import static org.onap.aaf.certservice.client.api.ExitStatus.CLIENT_CONFIGURATION_EXCEPTION;
-import static org.onap.aaf.certservice.client.api.ExitStatus.SUCCESS;
-
-@ExtendWith(MockitoExtension.class)
-class CertServiceClientTest {
- @Spy
- AppExitHandler appExitHandler = new AppExitHandler();
-
- @Test
- void shouldExitWithDefinedExitCode_onRunCallWhenNoEnvsPresent() {
- // given
- doNothing().when(appExitHandler).exit(CLIENT_CONFIGURATION_EXCEPTION);
- doNothing().when(appExitHandler).exit(SUCCESS);
- CertServiceClient certServiceClient = new CertServiceClient(appExitHandler);
- // when
- certServiceClient.run();
- // then
- verify(appExitHandler).exit(CLIENT_CONFIGURATION_EXCEPTION);
- verify(appExitHandler).exit(SUCCESS);
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProviderTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProviderTest.java
deleted file mode 100644
index 46bacef8..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProviderTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.onap.aaf.certservice.client.certification.conversion.ArtifactsCreator;
-import org.onap.aaf.certservice.client.certification.conversion.ConvertedArtifactsCreator;
-import org.onap.aaf.certservice.client.certification.conversion.PemArtifactsCreator;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-
-class ArtifactsCreatorProviderTest {
-
- private static final String P12 = "P12";
- private static final String JKS = "JKS";
- private static final String PEM = "PEM";
- private static final String TEST_PATH = "testPath";
-
- @ParameterizedTest
- @ValueSource(strings = {JKS, P12})
- void artifactsProviderShouldReturnConvertedCreator(String outputType) {
-
- // when
- ArtifactsCreator artifactsCreator =
- ArtifactsCreatorProvider.get(outputType, TEST_PATH);
- // then
- assertThat(artifactsCreator).isInstanceOf(ConvertedArtifactsCreator.class);
- }
-
- @Test
- void artifactsProviderShouldReturnPemCreator() {
-
- // when
- ArtifactsCreator artifactsCreator =
- ArtifactsCreatorProvider.get(PEM, TEST_PATH);
- // then
- assertThat(artifactsCreator).isInstanceOf(PemArtifactsCreator.class);
- }
-
- @ParameterizedTest
- @CsvSource({
- "JKS, jks",
- "P12, p12"})
- void getExtensionShouldProvideExtensionBasedOnArtifactType(String artifactType, String expectedExtension) {
-
- //when
- String actualExtension = ArtifactsCreatorProvider.valueOf(artifactType).getExtension();
- //then
- assertThat(actualExtension).isEqualTo(expectedExtension);
- }
-
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java
deleted file mode 100644
index ae18e6fb..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.certification.exception.CsrGenerationException;
-import org.onap.aaf.certservice.client.certification.exception.KeyPairGenerationException;
-import org.onap.aaf.certservice.client.configuration.model.CsrConfiguration;
-
-import java.security.KeyPair;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-class CsrFactoryTest {
-
- CsrConfiguration config = mock(CsrConfiguration.class);
-
-
- @Test
- void createEncodedCsr_shouldSucceedWhenAllFieldsAreSetCorrectly() throws KeyPairGenerationException, CsrGenerationException {
-
- KeyPair keyPair =
- new KeyPairFactory(EncryptionAlgorithmConstants.RSA_ENCRYPTION_ALGORITHM, EncryptionAlgorithmConstants.KEY_SIZE).create();
-
- when(config.getCommonName()).thenReturn("onap.org");
- when(config.getSans()).thenReturn("onapexample.com:onapexample.com.pl:onapexample.pl");
- when(config.getCountry()).thenReturn("US");
- when(config.getLocation()).thenReturn("San-Francisco");
- when(config.getOrganization()).thenReturn("Linux-Foundation");
- when(config.getOrganizationUnit()).thenReturn("ONAP");
- when(config.getState()).thenReturn("California");
-
- assertThat(new CsrFactory(config).createCsrInPem(keyPair)).isNotEmpty();
- }
-}
-
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/KeyPairFactoryTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/KeyPairFactoryTest.java
deleted file mode 100644
index 3d3d3c17..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/KeyPairFactoryTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.certification.exception.KeyPairGenerationException;
-
-import java.security.KeyPair;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-class KeyPairFactoryTest {
- private static final String NOT_EXISTING_ENCRYPTION_ALGORITHM = "FAKE_ALGORITHM";
-
- @Test
- public void shouldProvideKeyPair_whenCreateKeyPairCalledWithCorrectArguments() throws KeyPairGenerationException {
- // given
- KeyPairFactory keyPairFactory = new KeyPairFactory(EncryptionAlgorithmConstants.RSA_ENCRYPTION_ALGORITHM,
- EncryptionAlgorithmConstants.KEY_SIZE);
- // when
- KeyPair keyPair = keyPairFactory.create();
- // then
- assertThat(keyPair).isInstanceOf(KeyPair.class);
- }
-
- @Test
- public void shouldThrowKeyPairGenerationException_whenCreateTryCalledOnNotExistingAlgorithm() {
- // given
- KeyPairFactory keyPairFactory = new KeyPairFactory(NOT_EXISTING_ENCRYPTION_ALGORITHM,
- EncryptionAlgorithmConstants.KEY_SIZE);
- // when, then
- assertThatThrownBy(keyPairFactory::create).isInstanceOf(KeyPairGenerationException.class);
- }
-
-} \ No newline at end of file
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java
deleted file mode 100644
index 41f15bb7..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification;
-
-
-import org.bouncycastle.util.io.pem.PemObject;
-import org.bouncycastle.util.io.pem.PemReader;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.certification.exception.PkEncodingException;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.PKCS8EncodedKeySpec;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class PrivateKeyToPemEncoderTest {
-
- private static final String ENCRYPTION_ALGORITHM = "RSA";
- private static final String RESOURCES_DIR = "src/test/resources/";
- private static final String PRIVATE_KEY_PEM_PATH = RESOURCES_DIR + "rsaPrivateKeyPem";
-
- @Test
- void shouldReturnProperlyEncodedPrivateKey() throws InvalidKeySpecException, NoSuchAlgorithmException, PkEncodingException, IOException {
- //given
- String expectedPem = Files.readString(Paths.get(PRIVATE_KEY_PEM_PATH));
- PrivateKeyToPemEncoder testedPkEncoder = new PrivateKeyToPemEncoder();
- //when
- PrivateKey privateKey = extractPrivateKeyFromPem(expectedPem);
- String resultPkInPem = testedPkEncoder.encodePrivateKeyToPem(privateKey);
- //then
- assertThat(resultPkInPem).isEqualTo(expectedPem);
- }
-
- private PrivateKey extractPrivateKeyFromPem(String pem) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException {
- PemReader pemReader = new PemReader(new StringReader(pem));
- PemObject pemObject = pemReader.readPemObject();
- pemReader.close();
- PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(pemObject.getContent());
- KeyFactory kf = KeyFactory.getInstance(ENCRYPTION_ALGORITHM);
- return kf.generatePrivate(spec);
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorTest.java
deleted file mode 100644
index e13f8be8..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
-import org.onap.aaf.certservice.client.certification.exception.PemConversionException;
-import org.onap.aaf.certservice.client.certification.writer.CertFileWriter;
-
-import java.security.PrivateKey;
-import java.util.List;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-class ConvertedArtifactsCreatorTest {
-
- private static final int PASSWORD_LENGTH = 24;
- private static final String CERTIFICATE_ALIAS = "certificate";
- private static final String TRUSTED_CERTIFICATE_ALIAS = "trusted-certificate-";
-
- private static final Password SAMPLE_PASSWORD = new Password("d9D_u8LooYaXH4G48DtN#vw0");
- private static final List<String> SAMPLE_KEYSTORE_CERTIFICATE_CHAIN = List.of("a", "b");
- private static final List<String> SAMPLE_TRUSTED_CERTIFICATE_CHAIN = List.of("c", "d");
- private static final byte[] SAMPLE_KEYSTORE_BYTES = "this is a keystore test".getBytes();
- private static final byte[] SAMPLE_TRUSTSTORE_BYTES = "this is a truststore test".getBytes();
- private static final String P12_EXTENSION = "p12";
-
- private CertFileWriter certFileWriter;
- private RandomPasswordGenerator passwordGenerator;
- private PemConverter converter;
- private PrivateKey privateKey;
- private ConvertedArtifactsCreator artifactsCreator;
-
-
- @BeforeEach
- void setUp() {
- certFileWriter = mock(CertFileWriter.class);
- passwordGenerator = mock(RandomPasswordGenerator.class);
- converter = mock(PemConverter.class);
- privateKey = mock(PrivateKey.class);
- artifactsCreator = new ConvertedArtifactsCreator(certFileWriter, passwordGenerator, converter, P12_EXTENSION);
- }
-
- @Test
- void convertedArtifactCreatorShouldTryCreateFileWithGivenExtension()
- throws CertFileWriterException, PemConversionException {
- //given
- mockPasswordGeneratorAndPemConverter();
- final String keystore = "keystore";
- final String testExtension = "testExt";
- final String keystoreFileName = String.format("%s.%s", keystore, testExtension);
- artifactsCreator = new ConvertedArtifactsCreator(certFileWriter, passwordGenerator, converter, testExtension);
-
- //when
- artifactsCreator.create(SAMPLE_KEYSTORE_CERTIFICATE_CHAIN, SAMPLE_TRUSTED_CERTIFICATE_CHAIN, privateKey);
-
- //then
- verify(certFileWriter, times(1))
- .saveData(SAMPLE_KEYSTORE_BYTES, keystoreFileName);
- }
-
- @Test
- void convertedArtifactsCreatorShouldCallConverterAndFilesCreatorMethods()
- throws PemConversionException, CertFileWriterException {
- // given
- mockPasswordGeneratorAndPemConverter();
- final String keystoreP12 = "keystore.p12";
- final String keystorePass = "keystore.pass";
-
- //when
- artifactsCreator.create(SAMPLE_KEYSTORE_CERTIFICATE_CHAIN, SAMPLE_TRUSTED_CERTIFICATE_CHAIN, privateKey);
-
- // then
- verify(converter, times(1))
- .convertKeystore(SAMPLE_KEYSTORE_CERTIFICATE_CHAIN, SAMPLE_PASSWORD, CERTIFICATE_ALIAS, privateKey);
- verify(certFileWriter, times(1))
- .saveData(SAMPLE_KEYSTORE_BYTES, keystoreP12);
- verify(certFileWriter, times(1))
- .saveData(SAMPLE_PASSWORD.getCurrentPassword().getBytes(), keystorePass);
- verify(converter, times(1))
- .convertTruststore(SAMPLE_TRUSTED_CERTIFICATE_CHAIN, SAMPLE_PASSWORD, TRUSTED_CERTIFICATE_ALIAS);
- }
-
- @Test
- void convertedArtifactsCreatorShouldCallPasswordGeneratorTwice()
- throws PemConversionException, CertFileWriterException {
- // given
- mockPasswordGeneratorAndPemConverter();
-
- //when
- artifactsCreator.create(SAMPLE_KEYSTORE_CERTIFICATE_CHAIN, SAMPLE_TRUSTED_CERTIFICATE_CHAIN, privateKey);
-
- // then
- verify(passwordGenerator, times(2)).generate(PASSWORD_LENGTH);
- }
-
- private void mockPasswordGeneratorAndPemConverter() throws PemConversionException {
- when(passwordGenerator.generate(PASSWORD_LENGTH)).thenReturn(SAMPLE_PASSWORD);
- when(converter.convertKeystore(SAMPLE_KEYSTORE_CERTIFICATE_CHAIN, SAMPLE_PASSWORD, CERTIFICATE_ALIAS, privateKey))
- .thenReturn(SAMPLE_KEYSTORE_BYTES);
- when(converter.convertTruststore(SAMPLE_TRUSTED_CERTIFICATE_CHAIN, SAMPLE_PASSWORD, TRUSTED_CERTIFICATE_ALIAS))
- .thenReturn(SAMPLE_TRUSTSTORE_BYTES);
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreatorTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreatorTest.java
deleted file mode 100644
index 5e79b96f..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreatorTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.api.ExitableException;
-import org.onap.aaf.certservice.client.certification.PrivateKeyToPemEncoder;
-import org.onap.aaf.certservice.client.certification.writer.CertFileWriter;
-
-import java.security.PrivateKey;
-import java.util.List;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-class PemArtifactsCreatorTest {
- private static final String KEYSTORE_PEM = "keystore.pem";
- private static final String TRUSTSTORE_PEM = "truststore.pem";
- private static final String KEY_PEM = "key.pem";
- private static final String KEY = "my private key";
- private CertFileWriter certFileWriter = mock(CertFileWriter.class);
- private PrivateKey privateKey = mock(PrivateKey.class);
- private PrivateKeyToPemEncoder pkEncoder = mock(PrivateKeyToPemEncoder.class);
-
- @Test
- void pemArtifactsCreatorShouldCallRequiredMethods() throws ExitableException {
- // given
- final PemArtifactsCreator creator = new PemArtifactsCreator(certFileWriter, pkEncoder);
-
- // when
- when(pkEncoder.encodePrivateKeyToPem(privateKey)).thenReturn(KEY);
- creator.create(List.of("one", "two"), List.of("three", "four"), privateKey);
-
- // then
- verify(certFileWriter, times(1)).saveData("one\ntwo".getBytes(), KEYSTORE_PEM);
- verify(certFileWriter, times(1)).saveData("three\nfour".getBytes(), TRUSTSTORE_PEM);
- verify(certFileWriter, times(1)).saveData(KEY.getBytes(), KEY_PEM);
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemConverterTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemConverterTest.java
deleted file mode 100644
index e3a58c3f..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemConverterTest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.onap.aaf.certservice.client.certification.EncryptionAlgorithmConstants;
-import org.onap.aaf.certservice.client.certification.exception.PemConversionException;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-class PemConverterTest {
-
- private static final String RESOURCES_PATH = "src/test/resources";
- private static final String CERT1_PATH = RESOURCES_PATH + "/cert1.pem";
- private static final String CERT2_PATH = RESOURCES_PATH + "/cert2.pem";
- private static final String KEY_PATH = RESOURCES_PATH + "/privateKey";
- private static final String EXPECTED_KEYSTORE_PATH = RESOURCES_PATH + "/expectedKeystore.jks";
- private static final String EXPECTED_TRUSTSTORE_PATH = RESOURCES_PATH + "/expectedTruststore.jks";
- private static final String PKCS12 = "PKCS12";
- private static final String PKCS8 = "PKCS#8";
- private static final String JKS = "JKS";
- private static final String KEY_ERROR_MSG = "java.security.KeyStoreException: Key protection algorithm not found: java.lang.NullPointerException";
- private static final String CERTIFICATES_ERROR_MSG = "The certificate couldn't be parsed correctly. certificate1";
- private static final String PASSWORD_ERROR_MSG = "Password should be min. 16 chars long and should contain only alphanumeric characters and special characters like Underscore (_), Dollar ($) and Pound (#)";
- private static byte[] key;
- private PrivateKey privateKey = mock(PrivateKey.class);
-
- @BeforeAll
- static void setUpForAll() throws IOException {
- key = Files.readAllBytes(Path.of(KEY_PATH));
- }
-
- @ParameterizedTest
- @ValueSource(strings = {PKCS12, JKS})
- void convertKeystoreShouldReturnKeystoreWithGivenPrivateKeyAndCertificateChain(String conversionTarget)
- throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, PemConversionException {
- // given
- final String alias = "keystore-entry";
- final Password password = new Password("d9D_u8LooYaXH4G48DtN#vw0");
- final List<String> certificateChain = getCertificates();
- final PemConverter converter = new PemConverter(conversionTarget);
- final KeyStore expectedKeyStore = KeyStore.getInstance(conversionTarget);
- expectedKeyStore.load(new ByteArrayInputStream(Files.readAllBytes(Path.of(EXPECTED_KEYSTORE_PATH))),
- password.toCharArray());
- final Certificate[] expectedChain = expectedKeyStore.getCertificateChain(alias);
- privateKeyMockSetup();
-
- // when
- final byte[] result = converter.convertKeystore(certificateChain, password, alias, privateKey);
-
- // then
- final KeyStore actualKeyStore = KeyStore.getInstance(conversionTarget);
- actualKeyStore.load(new ByteArrayInputStream(result), password.toCharArray());
- final Certificate[] actualChain = actualKeyStore.getCertificateChain(alias);
-
- assertArrayEquals(key, actualKeyStore.getKey(alias, password.toCharArray()).getEncoded());
- assertEquals(2, expectedChain.length);
- assertArrayEquals(expectedChain, actualChain);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {PKCS12, JKS})
- void convertKeystoreShouldThrowPemConverterExceptionBecauseOfWrongPassword(String conversionTarget) throws IOException {
- // given
- final String alias = "keystore-entry";
- final Password password = new Password("apple");
- final List<String> certificateChain = getCertificates();
- final PemConverter converter = new PemConverter(conversionTarget);
- privateKeyMockSetup();
-
- // when
- Exception exception = assertThrows(PemConversionException.class, () ->
- converter.convertKeystore(certificateChain, password, alias, privateKey)
- );
-
- // then
- assertEquals(PASSWORD_ERROR_MSG, exception.getMessage());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {PKCS12, JKS})
- void convertTruststoreShouldReturnTruststoreWithGivenCertificatesArray(String conversionTarget)
- throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException, PemConversionException {
-
- // given
- final PemConverter converter = new PemConverter(conversionTarget);
- final String alias = "trusted-certificate-";
- final String alias1 = alias + 1;
- final String alias2 = alias + 2;
- final Password password = new Password("9z6oFx1epRSCuBWU4Er8i_0y");
- final List<String> trustedCertificates = getCertificates();
- final KeyStore expectedTrustStore = KeyStore.getInstance(conversionTarget);
- expectedTrustStore.load(new ByteArrayInputStream(Files.readAllBytes(Path.of(EXPECTED_TRUSTSTORE_PATH))),
- password.toCharArray());
-
- // when
- final byte[] result = converter.convertTruststore(trustedCertificates, password, alias);
-
- // then
- final KeyStore actualKeyStore = KeyStore.getInstance(conversionTarget);
- actualKeyStore.load(new ByteArrayInputStream(result), password.toCharArray());
-
- assertTrue(actualKeyStore.containsAlias(alias1));
- assertTrue(actualKeyStore.containsAlias(alias2));
- assertEquals(expectedTrustStore.getCertificate(alias1), actualKeyStore.getCertificate(alias1));
- assertEquals(expectedTrustStore.getCertificate(alias2), actualKeyStore.getCertificate(alias2));
- }
-
- @ParameterizedTest
- @ValueSource(strings = {PKCS12, JKS})
- void convertTruststoreShouldThrowPemConverterExceptionBecauseOfWrongPassword(String conversionTarget) throws IOException {
- // given
- final String alias = "trusted-certificate-";
- final Password password = new Password("nokia");
- final List<String> trustedCertificates = getCertificates();
- final PemConverter converter = new PemConverter(conversionTarget);
-
- // when then
- assertThatThrownBy(() ->
- converter.convertTruststore(trustedCertificates, password, alias))
- .isInstanceOf(PemConversionException.class).hasMessage(PASSWORD_ERROR_MSG);
- }
-
- @Test
- void convertKeystoreShouldThrowPemConverterExceptionBecauseOfWrongPrivateKey() throws IOException {
- // given
- final String alias = "keystore-entry";
- final Password password = new Password("d9D_u8LooYaXH4G48DtN#vw0");
- final List<String> certificateChain = getCertificates();
- final PemConverter converter = new PemConverter(PKCS12);
-
- // when then
- assertThatThrownBy(() -> converter.convertKeystore(certificateChain, password, alias, privateKey))
- .isInstanceOf(PemConversionException.class).hasMessage(KEY_ERROR_MSG);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {PKCS12, JKS})
- void convertKeystoreShouldThrowPemConverterExceptionBecauseOfWrongCertificates(String conversionTarget) {
- // given
- final String alias = "keystore-entry";
- final Password password = new Password("d9D_u8LooYaXH4G48DtN#vw0");
- final List<String> certificateChain = List.of("certificate1", "certificate2");
- final PemConverter converter = new PemConverter(conversionTarget);
- privateKeyMockSetup();
-
- // when then
- assertThatThrownBy(() -> converter.convertKeystore(certificateChain, password, alias, privateKey))
- .isInstanceOf(PemConversionException.class).hasMessage(CERTIFICATES_ERROR_MSG);
- }
-
- private void privateKeyMockSetup() {
- when(privateKey.getEncoded()).thenReturn(key);
- when(privateKey.getAlgorithm()).thenReturn(EncryptionAlgorithmConstants.RSA_ENCRYPTION_ALGORITHM);
- when(privateKey.getFormat()).thenReturn(PKCS8);
- }
-
- private List<String> getCertificates() throws IOException {
- return List.of(
- Files.readString(
- Path.of(CERT1_PATH), StandardCharsets.UTF_8),
- Files.readString(
- Path.of(CERT2_PATH), StandardCharsets.UTF_8)
- );
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGeneratorTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGeneratorTest.java
deleted file mode 100644
index 483e35e0..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGeneratorTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.conversion;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class RandomPasswordGeneratorTest {
-
- @Test
- void shouldGenerateRandomPasswordOfGivenLengthMatchingThePattern() {
- Password password = new RandomPasswordGenerator().generate(24);
- assertTrue(password.isCorrectPasswordPattern());
- }
-} \ No newline at end of file
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java
deleted file mode 100644
index c45876ec..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.certification.writer;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-class CertFileWriterTest {
-
- private static final String RESOURCES_PATH = "src/test/resources/";
- private static final String OUTPUT_PATH = RESOURCES_PATH + "generatedFiles/";
- private static final String NOT_EXISTING_OUTPUT_PATH = OUTPUT_PATH + "directoryDoesNotExist/";
- private static final String TRUSTSTORE_P12 = "truststore.p12";
- private File outputDirectory = new File(OUTPUT_PATH);
-
- @AfterEach
- void cleanUpFiles() {
- deleteDirectoryRecursive(outputDirectory);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {OUTPUT_PATH, NOT_EXISTING_OUTPUT_PATH})
- void certFileWriterShouldCreateFilesWithDataInGivenLocation(String outputPath)
- throws IOException, CertFileWriterException {
- // given
- File truststore = new File(outputPath + TRUSTSTORE_P12);
- CertFileWriter certFileWriter = CertFileWriter.createWithDir(outputPath);
- final byte[] data = new byte[]{-128, 1, 2, 3, 127};
-
- // when
- certFileWriter.saveData(data, TRUSTSTORE_P12);
-
- // then
- assertThat(truststore.exists()).isTrue();
- assertThat(Files.readAllBytes(Path.of(outputPath + TRUSTSTORE_P12))).isEqualTo(data);
- }
-
- private void deleteDirectoryRecursive(File dirForDeletion) {
- List.of(dirForDeletion.listFiles()).forEach(file -> {
- if (file.isDirectory()) {
- deleteDirectoryRecursive(file);
- }
- file.delete();
- });
- dirForDeletion.delete();
- }
-
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java
deleted file mode 100644
index 74c8c2a1..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import java.util.Optional;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.when;
-
-class EnvProviderTest {
- private static final String TEST_ENV = "testEnv";
- private static final String TEST_ENV_VALUE = "prod";
-
- private EnvProvider envProvider;
-
- @BeforeEach
- void setUp() {
- envProvider = Mockito.spy(EnvProvider.class);
- }
-
- @Test
- void shouldReturnSystemEnvVariableWhenItWasDefined() {
- // given
- when(envProvider.getSystemEnv(TEST_ENV)).thenReturn(TEST_ENV_VALUE);
-
- // when
- final Optional<String> testEnv = envProvider.readEnvVariable(TEST_ENV);
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV_VALUE);
- }
-
- @Test
- void shouldReportThatSystemEnvVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envProvider.readEnvVariable(TEST_ENV);
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java
deleted file mode 100644
index d6af20c6..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import java.util.Optional;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.when;
-
-class EnvsForCsrTest {
- private static final String TEST_ENV = "testEnv";
- private EnvsForCsr envsForCsr;
-
- @BeforeEach
- public void setUp() {
- envsForCsr = Mockito.spy(EnvsForCsr.class);
- }
-
- @Test
- void shouldReturnSystemEnvCommonNameVariableWhenItWasDefined() {
- // given
- when(envsForCsr.readEnv(CsrConfigurationEnvs.COMMON_NAME)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForCsr.getCommonName();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvCommonNameVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForCsr.getCommonName();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvOrganizationVariableWhenItWasDefined() {
- // given
- when(envsForCsr.readEnv(CsrConfigurationEnvs.ORGANIZATION)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForCsr.getOrganization();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvOrganizationVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForCsr.getOrganization();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvOuVariableWhenItWasDefined() {
- // given
- when(envsForCsr.readEnv(CsrConfigurationEnvs.ORGANIZATION_UNIT)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForCsr.getOrganizationUnit();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- public void shouldReportThatSystemEnvOuVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForCsr.getOrganizationUnit();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvLocationVariableWhenItWasDefined() {
- // given
- when(envsForCsr.readEnv(CsrConfigurationEnvs.LOCATION)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForCsr.getLocation();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvLocationVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForCsr.getLocation();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvStateVariableWhenItWasDefined() {
- // given
- when(envsForCsr.readEnv(CsrConfigurationEnvs.STATE)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForCsr.getState();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvStateVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForCsr.getState();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvCountryVariableWhenItWasDefined() {
- // given
- when(envsForCsr.readEnv(CsrConfigurationEnvs.COUNTRY)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForCsr.getCountry();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvCountryVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForCsr.getCountry();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvSansVariableWhenItWasDefined() {
- // given
- when(envsForCsr.readEnv(CsrConfigurationEnvs.SANS)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForCsr.getSubjectAlternativesName();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- public void shouldReportThatSystemEnvSansVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForCsr.getSubjectAlternativesName();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java
deleted file mode 100644
index 7f599aa5..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import java.util.Optional;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.when;
-
-class EnvsForTlsTest {
-
- private static final String TEST_ENV = "testEnv";
- private EnvsForTls envsForTls;
-
- @BeforeEach
- public void setUp() {
- envsForTls = Mockito.spy(EnvsForTls.class);
- }
-
- @Test
- void shouldReturnSystemEnvKeyStorePathVariableWhenItWasDefined() {
- // given
- when(envsForTls.readEnv(TlsConfigurationEnvs.KEYSTORE_PATH)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForTls.getKeystorePath();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvKeyStorePathVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForTls.getKeystorePath();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvKeyStorePasswordVariableWhenItWasDefined() {
- // given
- when(envsForTls.readEnv(TlsConfigurationEnvs.KEYSTORE_PASSWORD)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForTls.getKeystorePassword();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvKeyStorePasswordVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForTls.getKeystorePassword();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvTrustStorePathVariableWhenItWasDefined() {
- // given
- when(envsForTls.readEnv(TlsConfigurationEnvs.TRUSTSTORE_PATH)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForTls.getTruststorePath();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvTrustStorePathVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForTls.getTruststorePath();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-
- @Test
- void shouldReturnSystemEnvTrustStorePasswordVariableWhenItWasDefined() {
- // given
- when(envsForTls.readEnv(TlsConfigurationEnvs.TRUSTSTORE_PASSWORD)).thenReturn(Optional.of(TEST_ENV));
-
- // when
- final Optional<String> testEnv = envsForTls.getTruststorePassword();
-
- // then
- assertThat(testEnv)
- .isPresent()
- .contains(TEST_ENV);
- }
-
- @Test
- void shouldReportThatSystemEnvTrustStorePasswordVariableIsNotPresentWhenItWasNotDefined() {
- // when
- final Optional<String> testEnv = envsForTls.getTruststorePassword();
-
- // then
- assertThat(testEnv).isNotPresent();
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java
deleted file mode 100644
index e9e5c3bf..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.exception;
-
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.api.ExitStatus;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-
-class TlsConfigurationExceptionTest {
-
- @Test
- void containsProperExitStatus() {
- // Given
- ExitStatus exitStatus = null;
-
- // When
- try {
- throw new TlsConfigurationException("Test message");
- } catch (TlsConfigurationException e) {
- exitStatus = e.applicationExitStatus();
- }
-
- // Then
- assertThat(exitStatus)
- .isNotNull()
- .isEqualTo(ExitStatus.TLS_CONFIGURATION_EXCEPTION);
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java
deleted file mode 100644
index e4d71b31..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.factory;
-
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.mockito.Mockito;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
-class AbstractConfigurationFactoryTest {
-
- private final AbstractConfigurationFactory cut = mock(AbstractConfigurationFactory.class, Mockito.CALLS_REAL_METHODS);
-
- @ParameterizedTest
- @ValueSource(strings = {"/var/log", "/", "/var/log/", "/second_var", "/second-var"})
- void shouldAcceptValidPath(String path) {
- assertThat(cut.isPathValid(path)).isTrue();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/var/log?", "", "var_", "var", "//", "/var//log"})
- void shouldRejectInvalidPath(String path) {
- assertThat(cut.isPathValid(path)).isFalse();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"PL", "DE", "PN", "US", "IO", "CA", "KH", "CO", "DK", "EC", "CZ", "CN", "BR", "BD", "BE"})
- void shouldAcceptValidCountryCode(String countryCode) {
- assertThat(cut.isCountryValid(countryCode)).isTrue();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"", "QQ", "AFG", "D", "&*", "!", "ONAP", "p", "pl", "us", "afg"})
- void shouldRejectInvalidCountryCode(String countryCode) {
- assertThat(cut.isCountryValid(countryCode)).isFalse();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"caname", "caname1", "123caName", "ca1name"})
- void shouldAcceptValidAlphanumeric(String caName) {
- assertThat(cut.isAlphaNumeric(caName)).isTrue();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"44caname$", "#caname1", "1c_aname", "ca1-name"})
- void shouldRejectInvalidAlphanumeric(String caName) {
- assertThat(cut.isAlphaNumeric(caName)).isFalse();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"example.com", "www.example.com"})
- void shouldAcceptValidCommonName(String commonName) {
- assertThat(cut.isCommonNameValid(commonName)).isTrue();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"https://example.com", "http://example.com", "example.com:8080", "0.0.0.0", "@#$%.com"})
- void shouldRejectInvalidCommonName(String commonName) {
- assertThat(cut.isCommonNameValid(commonName)).isFalse();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"JKS", "P12", "PEM"})
- void shouldAcceptValidOutputType(String outputType) {
- assertThat(cut.isOutputTypeValid(outputType)).isTrue();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"jks", "p12", "pem", "", "pass", "!@$#pp"})
- void shouldRejectInvalidOutputType(String outputType) {
- assertThat(cut.isOutputTypeValid(outputType)).isFalse();
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactoryTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactoryTest.java
deleted file mode 100644
index 20a6c7ef..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactoryTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.factory;
-
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.configuration.ClientConfigurationEnvs;
-import org.onap.aaf.certservice.client.configuration.EnvsForClient;
-import org.onap.aaf.certservice.client.configuration.exception.ClientConfigurationException;
-import org.onap.aaf.certservice.client.configuration.model.ClientConfiguration;
-
-import java.util.Optional;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ClientConfigurationFactoryTest {
-
- private static final String CA_NAME_VALID = "caaaftest2";
- private static final String TIME_OUT_VALID = "30000";
- private static final String OUTPUT_PATH_VALID = "/opt/app/osaaf";
- private static final String URL_TO_CERT_SERVICE_VALID = "https://cert-service:8443/v1/certificate/";
- private static final String URL_TO_CERT_SERVICE_DEFAULT = "https://aaf-cert-service:8443/v1/certificate/";
- private static final String CA_NAME_INVALID = "caaaftest2#$";
- private static final String OUTPUT_PATH_INVALID = "/opt//app/osaaf";
- private static final String OUTPUT_TYPE_VALID = "JKS";
- private static final String OUTPUT_TYPE_INVALID = "JKSS";
- private static final String OUTPUT_TYPE_DEFAULT = "P12";
-
- private EnvsForClient envsForClient = mock(EnvsForClient.class);
-
-
- @Test
- void create_shouldReturnSuccessWhenAllVariablesAreSetAndValid() throws ClientConfigurationException {
- // given
- when(envsForClient.getCaName()).thenReturn(Optional.of(CA_NAME_VALID));
- when(envsForClient.getOutputPath()).thenReturn(Optional.of(OUTPUT_PATH_VALID));
- when(envsForClient.getRequestTimeOut()).thenReturn(Optional.of(TIME_OUT_VALID));
- when(envsForClient.getUrlToCertService()).thenReturn(Optional.of(URL_TO_CERT_SERVICE_VALID));
- when(envsForClient.getOutputType()).thenReturn(Optional.of(OUTPUT_TYPE_VALID));
-
- // when
- ClientConfiguration configuration = new ClientConfigurationFactory(envsForClient).create();
- System.out.println(configuration.toString());
-
- // then
- assertThat(configuration.getCaName()).isEqualTo(CA_NAME_VALID);
- assertThat(configuration.getRequestTimeout()).isEqualTo(Integer.valueOf(TIME_OUT_VALID));
- assertThat(configuration.getCertsOutputPath()).isEqualTo(OUTPUT_PATH_VALID);
- assertThat(configuration.getUrlToCertService()).isEqualTo(URL_TO_CERT_SERVICE_VALID);
- assertThat(configuration.getOutputType()).isEqualTo(OUTPUT_TYPE_VALID);
- }
-
- @Test
- void create_shouldReturnSuccessWhenDefaultVariablesAreNotSet() throws ClientConfigurationException {
- // given
- when(envsForClient.getCaName()).thenReturn(Optional.of(CA_NAME_VALID));
- when(envsForClient.getOutputPath()).thenReturn(Optional.of(OUTPUT_PATH_VALID));
-
- // when
- ClientConfiguration configuration = new ClientConfigurationFactory(envsForClient).create();
-
- // then
- assertThat(configuration.getCaName()).isEqualTo(CA_NAME_VALID);
- assertThat(configuration.getRequestTimeout()).isEqualTo(Integer.valueOf(TIME_OUT_VALID));
- assertThat(configuration.getCertsOutputPath()).isEqualTo(OUTPUT_PATH_VALID);
- assertThat(configuration.getUrlToCertService()).isEqualTo(URL_TO_CERT_SERVICE_DEFAULT);
- assertThat(configuration.getOutputType()).isEqualTo(OUTPUT_TYPE_DEFAULT);
- }
-
- @Test
- void create_shouldReturnClientExceptionWhenRequiredVariableIsNotSet() {
- // given
- when(envsForClient.getOutputPath()).thenReturn(Optional.of(OUTPUT_PATH_VALID));
-
- // when
- ClientConfigurationFactory configurationFactory = new ClientConfigurationFactory(envsForClient);
-
- // then
- assertThatExceptionOfType(ClientConfigurationException.class)
- .isThrownBy(configurationFactory::create)
- .withMessageContaining(ClientConfigurationEnvs.CA_NAME + " is invalid.");
- }
-
- @Test
- void create_shouldReturnClientExceptionWhenCaNameContainsSpecialCharacters() {
- // given
- when(envsForClient.getCaName()).thenReturn(Optional.of(CA_NAME_INVALID));
- when(envsForClient.getOutputPath()).thenReturn(Optional.of(OUTPUT_PATH_VALID));
- when(envsForClient.getRequestTimeOut()).thenReturn(Optional.of(TIME_OUT_VALID));
- when(envsForClient.getUrlToCertService()).thenReturn(Optional.of(URL_TO_CERT_SERVICE_VALID));
-
- // when
- ClientConfigurationFactory configurationFactory = new ClientConfigurationFactory(envsForClient);
-
- // when/then
- assertThatExceptionOfType(ClientConfigurationException.class)
- .isThrownBy(configurationFactory::create)
- .withMessageContaining(ClientConfigurationEnvs.CA_NAME + " is invalid.");
- }
-
- @Test
- void create_shouldReturnClientExceptionWhenOutputPathContainsSpecialCharacters() {
- // given
- when(envsForClient.getCaName()).thenReturn(Optional.of(CA_NAME_VALID));
- when(envsForClient.getOutputPath()).thenReturn(Optional.of(OUTPUT_PATH_INVALID));
- when(envsForClient.getRequestTimeOut()).thenReturn(Optional.of(TIME_OUT_VALID));
- when(envsForClient.getUrlToCertService()).thenReturn(Optional.of(URL_TO_CERT_SERVICE_VALID));
-
- // when
- ClientConfigurationFactory configurationFactory = new ClientConfigurationFactory(envsForClient);
-
- //then
- assertThatExceptionOfType(ClientConfigurationException.class)
- .isThrownBy(configurationFactory::create)
- .withMessageContaining(ClientConfigurationEnvs.OUTPUT_PATH + " is invalid.");
- }
-
- @Test
- void create_shouldReturnClientExceptionWhenOutputTypeIsInvalid() {
- // given
- when(envsForClient.getCaName()).thenReturn(Optional.of(CA_NAME_VALID));
- when(envsForClient.getOutputPath()).thenReturn(Optional.of(OUTPUT_PATH_VALID));
- when(envsForClient.getRequestTimeOut()).thenReturn(Optional.of(TIME_OUT_VALID));
- when(envsForClient.getUrlToCertService()).thenReturn(Optional.of(URL_TO_CERT_SERVICE_VALID));
- when(envsForClient.getOutputType()).thenReturn(Optional.of(OUTPUT_TYPE_INVALID));
-
- // when
- ClientConfigurationFactory configurationFactory = new ClientConfigurationFactory(envsForClient);
-
- //then
- assertThatExceptionOfType(ClientConfigurationException.class)
- .isThrownBy(configurationFactory::create)
- .withMessageContaining(ClientConfigurationEnvs.OUTPUT_TYPE + " is invalid.");
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactoryTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactoryTest.java
deleted file mode 100644
index b9b9b078..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactoryTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.factory;
-
-import org.assertj.core.api.Condition;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.configuration.CsrConfigurationEnvs;
-import org.onap.aaf.certservice.client.configuration.EnvsForCsr;
-import org.onap.aaf.certservice.client.configuration.exception.CsrConfigurationException;
-import org.onap.aaf.certservice.client.configuration.model.CsrConfiguration;
-
-import java.util.Optional;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.onap.aaf.certservice.client.api.ExitStatus.CSR_CONFIGURATION_EXCEPTION;
-
-public class CsrConfigurationFactoryTest {
-
- private static final String COMMON_NAME_VALID = "onap.org";
- private static final String SANS_VALID = "test-name";
- private static final String COUNTRY_VALID = "US";
- private static final String LOCATION_VALID = "San-Francisco";
- private static final String ORGANIZATION_VALID = "Linux-Foundation";
- private static final String ORGANIZATION_UNIT_VALID = "ONAP";
- private static final String STATE_VALID = "California";
- private static final String COMMON_NAME_INVALID = "onap.org*&";
- private static final String COUNTRY_INVALID = "PLA";
- private static final String ORGANIZATION_INVALID = "Linux?Foundation";
-
- private EnvsForCsr envsForCsr = mock(EnvsForCsr.class);
- private CsrConfigurationFactory testedFactory;
- private Condition<CsrConfigurationException> expectedExitCodeCondition = new Condition<>("Correct exit code") {
- @Override
- public boolean matches(CsrConfigurationException exception) {
- return exception.applicationExitStatus() == CSR_CONFIGURATION_EXCEPTION;
- }
- };
-
- @BeforeEach
- void setUp() {
- testedFactory = new CsrConfigurationFactory(envsForCsr);
- }
-
- @Test
- void shouldReturnCorrectConfiguration_WhenAllVariablesAreSetAndValid() throws CsrConfigurationException {
- // given
- mockEnvsWithAllValidParameters();
-
- // when
- CsrConfiguration configuration = testedFactory.create();
-
- // then
- assertThat(configuration.getCommonName()).isEqualTo(COMMON_NAME_VALID);
- assertThat(configuration.getSans()).isEqualTo(SANS_VALID);
- assertThat(configuration.getCountry()).isEqualTo(COUNTRY_VALID);
- assertThat(configuration.getLocation()).isEqualTo(LOCATION_VALID);
- assertThat(configuration.getOrganization()).isEqualTo(ORGANIZATION_VALID);
- assertThat(configuration.getOrganizationUnit()).isEqualTo(ORGANIZATION_UNIT_VALID);
- assertThat(configuration.getState()).isEqualTo(STATE_VALID);
- }
-
- @Test
- void shouldReturnCorrectConfiguration_WhenNotRequiredVariablesAreNotSet() throws CsrConfigurationException {
- // given
- mockEnvsWithValidRequiredParameters();
-
- // when
- CsrConfiguration configuration = testedFactory.create();
-
- // then
- assertThat(configuration.getCommonName()).isEqualTo(COMMON_NAME_VALID);
- assertThat(configuration.getCountry()).isEqualTo(COUNTRY_VALID);
- assertThat(configuration.getOrganization()).isEqualTo(ORGANIZATION_VALID);
- assertThat(configuration.getState()).isEqualTo(STATE_VALID);
- }
-
-
- @Test
- void shouldThrowCsrConfigurationException_WhenCommonNameInvalid() {
- // given
- mockEnvsWithInvalidCommonName();
-
- // when/then
- assertThatExceptionOfType(CsrConfigurationException.class)
- .isThrownBy(testedFactory::create)
- .withMessageContaining(CsrConfigurationEnvs.COMMON_NAME + " is invalid.")
- .has(expectedExitCodeCondition);
- }
-
- @Test
- void shouldThrowCsrConfigurationException_WhenOrganizationInvalid() {
- // given
- mockEnvsWithInvalidOrganization();
-
- // when/then
- assertThatExceptionOfType(CsrConfigurationException.class)
- .isThrownBy(testedFactory::create)
- .withMessageContaining(CsrConfigurationEnvs.ORGANIZATION + " is invalid.")
- .has(expectedExitCodeCondition);
-
- }
-
- @Test
- void shouldThrowCsrConfigurationException_WhenCountryInvalid() {
- // given
- mockEnvsWithInvalidCountry();
-
- // when/then
- assertThatExceptionOfType(CsrConfigurationException.class)
- .isThrownBy(testedFactory::create)
- .withMessageContaining(CsrConfigurationEnvs.COUNTRY + " is invalid.")
- .has(expectedExitCodeCondition);
-
- }
-
- @Test
- void shouldThrowCsrConfigurationExceptionWhenStateInvalid() {
- // given
- mockEnvsWithInvalidState();
- // when/then
- assertThatExceptionOfType(CsrConfigurationException.class)
- .isThrownBy(testedFactory::create)
- .withMessageContaining(CsrConfigurationEnvs.STATE + " is invalid.")
- .has(expectedExitCodeCondition);
- }
-
- private void mockEnvsWithAllValidParameters() {
- mockEnvsWithValidRequiredParameters();
- mockEnvsWithValidOptionalParameters();
- }
-
- private void mockEnvsWithValidOptionalParameters() {
- when(envsForCsr.getOrganizationUnit()).thenReturn(Optional.of(ORGANIZATION_UNIT_VALID));
- when(envsForCsr.getLocation()).thenReturn(Optional.of(LOCATION_VALID));
- when(envsForCsr.getSubjectAlternativesName()).thenReturn(Optional.of(SANS_VALID));
- }
-
- private void mockEnvsWithValidRequiredParameters() {
- when(envsForCsr.getCommonName()).thenReturn(Optional.of(COMMON_NAME_VALID));
- when(envsForCsr.getCountry()).thenReturn(Optional.of(COUNTRY_VALID));
- when(envsForCsr.getOrganization()).thenReturn(Optional.of(ORGANIZATION_VALID));
- when(envsForCsr.getState()).thenReturn(Optional.of(STATE_VALID));
- }
-
- private void mockEnvsWithInvalidCommonName() {
- mockEnvsWithAllValidParameters();
- when(envsForCsr.getCommonName()).thenReturn(Optional.of(COMMON_NAME_INVALID));
- }
-
- private void mockEnvsWithInvalidCountry() {
- mockEnvsWithAllValidParameters();
- when(envsForCsr.getCountry()).thenReturn(Optional.of(COUNTRY_INVALID));
- }
-
- private void mockEnvsWithInvalidOrganization() {
- mockEnvsWithAllValidParameters();
- when(envsForCsr.getOrganization()).thenReturn(Optional.of(ORGANIZATION_INVALID));
- }
-
- private void mockEnvsWithInvalidState() {
- mockEnvsWithAllValidParameters();
- when(envsForCsr.getState()).thenReturn(Optional.empty());
- }
-}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactoryTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactoryTest.java
deleted file mode 100644
index 8e6e8369..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactoryTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.configuration.factory;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.aaf.certservice.client.configuration.EnvsForTls;
-import org.onap.aaf.certservice.client.configuration.exception.TlsConfigurationException;
-
-import javax.net.ssl.SSLContext;
-import java.util.Optional;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.when;
-
-
-@ExtendWith(MockitoExtension.class)
-public class SslContextFactoryTest {
-
- public static final String INVALID_KEYSTORE_PATH = "nonexistent/keystore";
- public static final String VALID_KEYSTORE_NAME = "keystore.jks";
- public static final String VALID_KEYSTORE_PASSWORD = "secret";
- public static final String INVALID_KEYSTORE_PASSWORD = "wrong_secret";
- public static final String INVALID_TRUSTSTORE_PATH = "nonexistent/truststore";
- public static final String VALID_TRUSTSTORE_PASSWORD = "secret";
- public static final String INVALID_TRUSTSTORE_PASSWORD = "wrong_secret";
- public static final String VALID_TRUSTSTORE_NAME = "truststore.jks";
- @Mock
- private EnvsForTls envsForTls;
-
- @Test
- public void shouldThrowExceptionWhenKeystorePathEnvIsMissing() {
- // Given
- when(envsForTls.getKeystorePath()).thenReturn(Optional.empty());
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When, Then
- Exception exception = assertThrows(
- TlsConfigurationException.class, sslContextFactory::create
- );
- assertThat(exception.getMessage()).contains("KEYSTORE_PATH");
- }
-
- @Test
- public void shouldThrowExceptionWhenKeystorePasswordEnvIsMissing() {
- // Given
- when(envsForTls.getKeystorePath()).thenReturn(Optional.of("keystore"));
- when(envsForTls.getKeystorePassword()).thenReturn(Optional.empty());
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When, Then
- Exception exception = assertThrows(
- TlsConfigurationException.class, sslContextFactory::create
- );
- assertThat(exception.getMessage()).contains("KEYSTORE_PASSWORD");
- }
-
- @Test
- public void shouldThrowExceptionWhenTruststorePathEnvIsMissing() {
- // Given
- when(envsForTls.getKeystorePath()).thenReturn(Optional.of("keystore"));
- when(envsForTls.getKeystorePassword()).thenReturn(Optional.of("password"));
- when(envsForTls.getTruststorePath()).thenReturn(Optional.empty());
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When, Then
- Exception exception = assertThrows(
- TlsConfigurationException.class, sslContextFactory::create
- );
- assertThat(exception.getMessage()).contains("TRUSTSTORE_PATH");
- }
-
- @Test
- public void shouldThrowExceptionWhenTruststorePasswordEnvIsMissing() {
- // Given
- when(envsForTls.getKeystorePath()).thenReturn(Optional.of("keystore"));
- when(envsForTls.getKeystorePassword()).thenReturn(Optional.of("password"));
- when(envsForTls.getTruststorePath()).thenReturn(Optional.of("truststore"));
- when(envsForTls.getTruststorePassword()).thenReturn(Optional.empty());
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When, Then
- Exception exception = assertThrows(
- TlsConfigurationException.class, sslContextFactory::create
- );
- assertThat(exception.getMessage()).contains("TRUSTSTORE_PASSWORD");
- }
-
- @Test
- public void shouldThrowExceptionWhenKeystoreIsMissing() {
- // Given
- when(envsForTls.getKeystorePath()).thenReturn(Optional.of(INVALID_KEYSTORE_PATH));
- when(envsForTls.getKeystorePassword()).thenReturn(Optional.of("secret"));
- when(envsForTls.getTruststorePath()).thenReturn(Optional.of("truststore.jks"));
- when(envsForTls.getTruststorePassword()).thenReturn(Optional.of("secret"));
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When, Then
- assertThrows(
- TlsConfigurationException.class, sslContextFactory::create
- );
- }
-
- @Test
- public void shouldThrowExceptionWhenKeystorePasswordIsWrong() {
- // Given
- String keystorePath = getResourcePath(VALID_KEYSTORE_NAME);
- when(envsForTls.getKeystorePath()).thenReturn(Optional.of(keystorePath));
- when(envsForTls.getKeystorePassword()).thenReturn(Optional.of(INVALID_KEYSTORE_PASSWORD));
- when(envsForTls.getTruststorePath()).thenReturn(Optional.of(VALID_TRUSTSTORE_NAME));
- when(envsForTls.getTruststorePassword()).thenReturn(Optional.of(VALID_TRUSTSTORE_PASSWORD));
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When, Then
- assertThrows(
- TlsConfigurationException.class, sslContextFactory::create
- );
- }
-
- @Test
- public void shouldThrowExceptionWhenTruststoreIsMissing() {
- // Given
- String keystorePath = getResourcePath(VALID_KEYSTORE_NAME);
- when(envsForTls.getKeystorePath()).thenReturn(Optional.of(keystorePath));
- when(envsForTls.getKeystorePassword()).thenReturn(Optional.of(VALID_KEYSTORE_PASSWORD));
- when(envsForTls.getTruststorePath()).thenReturn(Optional.of(INVALID_TRUSTSTORE_PATH));
- when(envsForTls.getTruststorePassword()).thenReturn(Optional.of(VALID_TRUSTSTORE_PASSWORD));
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When, Then
- assertThrows(
- TlsConfigurationException.class, sslContextFactory::create
- );
- }
-
- @Test
- public void shouldThrowExceptionWhenTruststorePasswordIsWrong() {
- // Given
- String keystorePath = getResourcePath(VALID_KEYSTORE_NAME);
- String truststorePath = getResourcePath(VALID_TRUSTSTORE_NAME);
- when(envsForTls.getKeystorePath()).thenReturn(Optional.of(keystorePath));
- when(envsForTls.getKeystorePassword()).thenReturn(Optional.of(VALID_KEYSTORE_PASSWORD));
- when(envsForTls.getTruststorePath()).thenReturn(Optional.of(truststorePath));
- when(envsForTls.getTruststorePassword()).thenReturn(Optional.of(INVALID_TRUSTSTORE_PASSWORD));
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When, Then
- assertThrows(
- TlsConfigurationException.class, sslContextFactory::create
- );
- }
-
- @Test
- public void shouldReturnSslContext() throws TlsConfigurationException {
- // Given
- String keystorePath = getResourcePath(VALID_KEYSTORE_NAME);
- String truststorePath = getResourcePath(VALID_TRUSTSTORE_NAME);
- when(envsForTls.getKeystorePath()).thenReturn(Optional.of(keystorePath));
- when(envsForTls.getKeystorePassword()).thenReturn(Optional.of(VALID_KEYSTORE_PASSWORD));
- when(envsForTls.getTruststorePath()).thenReturn(Optional.of(truststorePath));
- when(envsForTls.getTruststorePassword()).thenReturn(Optional.of(VALID_TRUSTSTORE_PASSWORD));
- SslContextFactory sslContextFactory = new SslContextFactory(envsForTls);
-
- // When
- SSLContext sslContext = sslContextFactory.create();
-
- // Then
- assertNotNull(sslContext);
- }
-
- private String getResourcePath(String resource) {
- return getClass().getClassLoader().getResource(resource).getFile();
- }
-}
-
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/httpclient/HttpClientTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/httpclient/HttpClientTest.java
deleted file mode 100644
index a109749b..00000000
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/httpclient/HttpClientTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aaf.certservice.client.httpclient;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.StatusLine;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.httpclient.exception.CertServiceApiResponseException;
-import org.onap.aaf.certservice.client.httpclient.exception.HttpClientException;
-import org.onap.aaf.certservice.client.httpclient.model.CertServiceResponse;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.List;
-
-import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
-import static java.net.HttpURLConnection.HTTP_OK;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.onap.aaf.certservice.client.CerServiceRequestTestData.CA_NAME;
-import static org.onap.aaf.certservice.client.CerServiceRequestTestData.CORRECT_RESPONSE;
-import static org.onap.aaf.certservice.client.CerServiceRequestTestData.CSR;
-import static org.onap.aaf.certservice.client.CerServiceRequestTestData.EXPECTED_FIRST_ELEMENT_OF_CERTIFICATE_CHAIN;
-import static org.onap.aaf.certservice.client.CerServiceRequestTestData.EXPECTED_FIRST_ELEMENT_OF_TRUSTED_CERTIFICATES;
-import static org.onap.aaf.certservice.client.CerServiceRequestTestData.MISSING_PK_RESPONSE;
-import static org.onap.aaf.certservice.client.CerServiceRequestTestData.PK;
-
-class HttpClientTest {
-
- private HttpClient httpClient;
- private CloseableHttpClient closeableHttpClient;
- private HttpEntity httpEntity;
- private StatusLine statusLine;
- private CloseableHttpResponse httpResponse;
-
- @BeforeEach
- void setUp() {
-
- closeableHttpClient = mock(CloseableHttpClient.class);
- httpEntity = mock(HttpEntity.class);
- statusLine = mock(StatusLine.class);
- httpResponse = mock(CloseableHttpResponse.class);
-
- CloseableHttpsClientProvider httpClientProvider = mock(CloseableHttpsClientProvider.class);
-
- when(httpClientProvider.getClient()).thenReturn(closeableHttpClient);
- String testCertServiceAddress = "";
- httpClient = new HttpClient(httpClientProvider, testCertServiceAddress);
- }
-
- @Test
- void shouldReturnCorrectListsOfCertificatedChainsAndTrustedCertificates_WhenRequestDataIsCorrect()
- throws Exception {
-
- // given
- mockServerResponse(HTTP_OK, CORRECT_RESPONSE);
-
- // when
- CertServiceResponse certServiceResponse =
- httpClient.retrieveCertServiceData(CA_NAME, CSR, PK);
- List<String> certificateChain = certServiceResponse.getCertificateChain();
- List<String> trustedCertificate = certServiceResponse.getTrustedCertificates();
-
- // then
- assertThat(certServiceResponse).isNotNull();
-
- final int expectedTwoElements = 2;
-
- assertThat(certificateChain).hasSize(expectedTwoElements);
- assertThat(trustedCertificate).hasSize(expectedTwoElements);
-
- assertThat(certificateChain.get(0)).isEqualTo(EXPECTED_FIRST_ELEMENT_OF_CERTIFICATE_CHAIN);
- assertThat(trustedCertificate.get(0)).isEqualTo(EXPECTED_FIRST_ELEMENT_OF_TRUSTED_CERTIFICATES);
- }
-
- @Test
- void shouldThrowCertServiceApiResponseException_WhenPkHeaderIsMissing() throws Exception {
-
- //given
- mockServerResponse(HTTP_BAD_REQUEST, MISSING_PK_RESPONSE);
-
- //when //then
- assertThatExceptionOfType(CertServiceApiResponseException.class)
- .isThrownBy(() -> httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
- }
-
- @Test
- void shouldThrowHttpClientException_WhenCannotExecuteRequestToApi() throws Exception {
-
- //given
- when(closeableHttpClient.execute(any(HttpGet.class))).thenThrow(IOException.class);
-
- //when //then
- assertThatExceptionOfType(HttpClientException.class)
- .isThrownBy(() -> httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
- }
-
- @Test
- void shouldThrowHttpClientException_WhenCannotParseResponseToString() throws Exception {
-
- //given
- mockServerResponse(HTTP_OK, CORRECT_RESPONSE);
- when(httpEntity.getContent()).thenThrow(IOException.class);
-
- //when //then
- assertThatExceptionOfType(HttpClientException.class)
- .isThrownBy(() -> httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
- }
-
- private void mockServerResponse(int serverCodeResponse, String stringResponse)
- throws IOException {
- when(statusLine.getStatusCode()).thenReturn(serverCodeResponse);
- when(httpResponse.getStatusLine()).thenReturn(statusLine);
- when(httpResponse.getEntity()).thenReturn(httpEntity);
- when(closeableHttpClient.execute(any(HttpGet.class))).thenReturn(httpResponse);
-
- when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(stringResponse.getBytes()));
- }
-}
diff --git a/certServiceClient/src/test/resources/cert1.pem b/certServiceClient/src/test/resources/cert1.pem
deleted file mode 100644
index cd5f3841..00000000
--- a/certServiceClient/src/test/resources/cert1.pem
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDjDCCAnSgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwgYQxCzAJBgNVBAYTAlVT
-MRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw
-FwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQD
-DBVpbnRlcm1lZGlhdGUub25hcC5vcmcwHhcNMjAwMjEyMDk1MTI2WhcNMjIxMTA4
-MDk1MTI2WjB7MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQG
-A1UEBwwNU2FuLUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjEN
-MAsGA1UECwwET05BUDEVMBMGA1UEAwwMdmlkLm9uYXAub3JnMIIBIjANBgkqhkiG
-9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw+GIRzJzUOh0gtc+wzFJEdTnn+q5F10L0Yhr
-G1xKdjPieHIFGsoiXwcuCU8arNSqlz7ocx62KQRkcA8y6edlOAsYtdOEJvqEI9vc
-eyTB/HYsbzw3URPGch4AmibrQkKU9QvGwouHtHn4R2Ft2Y0tfEqv9hxj9v4njq4A
-EiDLAFLl5FmVyCZu/MtKngSgu1smcaFKTYySPMxytgJZexoa/ALZyyE0gRhsvwHm
-NLGCPt1bmE/PEGZybsCqliyTO0S56ncD55The7+D/UDS4kE1Wg0svlWon/YsE6QW
-B3oeJDX7Kr8ebDTIAErevIAD7Sm4ee5se2zxYrsYlj0MzHZtvwIDAQABoxAwDjAM
-BgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCvQ1pTvjON6vSlcJRKSY4r
-8q7L4/9ZaVXWJAjzEYJtPIqsgGiPWz0vGfgklowU6tZxp9zRZFXfMil+mPQSe+yo
-ULrZSQ/z48YHPueE/BNO/nT4aaVBEhPLR5aVwC7uQVX8H+m1V1UGT8lk9vdI9rej
-CI9l524sLCpdE4dFXiWK2XHEZ0Vfylk221u3IYEogVVA+UMX7BFPSsOnI2vtYK/i
-lwZtlri8LtTusNe4oiTkYyq+RSyDhtAswg8ANgvfHolhCHoLFj6w1IkG88UCmbwN
-d7BoGMy06y5MJxyXEZG0vR7eNeLey0TIh+rAszAFPsIQvrOHW+HuA+WLQAj1mhnm
------END CERTIFICATE-----
diff --git a/certServiceClient/src/test/resources/cert2.pem b/certServiceClient/src/test/resources/cert2.pem
deleted file mode 100644
index 92ebc821..00000000
--- a/certServiceClient/src/test/resources/cert2.pem
+++ /dev/null
@@ -1,22 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDqTCCApGgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwgZcxCzAJBgNVBAYTAlVT
-MRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw
-FwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMREwDwYDVQQD
-DAhvbmFwLm9yZzEeMBwGCSqGSIb3DQEJARYPdGVzdGVyQG9uYXAub3JnMB4XDTIw
-MDIxMjA5NDAxMloXDTIyMTEwODA5NDAxMlowgYQxCzAJBgNVBAYTAlVTMRMwEQYD
-VQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkwFwYDVQQK
-DBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQDDBVpbnRl
-cm1lZGlhdGUub25hcC5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
-AQC1oOYMZ6G+2DGDAizYnzdCNiogivlht1s4oqgem7fM1XFPxD2p31ATIibOdqr/
-gv1qemO9Q4r1xn6w1Ufq7T1K7PjnMzdSeTqZefurE2JM/HHx2QvW4TjMlz2ILgaD
-L1LN60kmMQSOi5VxKJpsrCQxbOsxhvefd212gny5AZMcjJe23kUd9OxUrtvpdLEv
-wI3vFEvT7oRUnEUg/XNz7qeg33vf1C39yMR+6O4s6oevgsEebVKjb+yOoS6zzGtz
-72wZjm07C54ZlO+4Uy+QAlMjRiU3mgWkKbkOy+4CvwehjhpTikdBs2DX39ZLGHhn
-L/0a2NYtGulp9XEqmTvRoI+PAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZI
-hvcNAQELBQADggEBADcitdJ6YswiV8jAD9GK0gf3+zqcGegt4kt+79JXlXYbb1sY
-q3o6prcB7nSUoClgF2xUPCslFGpM0Er9FCSFElQM/ru0l/KVmJS6kSpwEHvsYIH3
-q5anta+Pyk8JSQWAAw+qrind0uBQMnhR8Tn13tgV+Kjvg/xlH/nZIEdN5YtLB1cA
-beVsZRyRfVL9DeZU8s/MZ5wC3kgcEp5A4m5lg7HyBxBdqhzFcDr6xiy6OGqW8Yep
-xrwfc8Fw8a/lOv4U+tBeGNKPQDYaL9hh+oM+qMkNXsHXDqdJsuEGJtU4i3Wcwzoc
-XGN5NWV//4bP+NFmwgcn7AYCdRvz04A8GU/0Cwg=
------END CERTIFICATE-----
diff --git a/certServiceClient/src/test/resources/correctResponse b/certServiceClient/src/test/resources/correctResponse
deleted file mode 100644
index c7bf349e..00000000
--- a/certServiceClient/src/test/resources/correctResponse
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "certificateChain": [
- "-----BEGIN CERTIFICATE-----\nMIIDjDCCAnSgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwgYQxCzAJBgNVBAYTAlVT\nMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw\nFwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQD\nDBVpbnRlcm1lZGlhdGUub25hcC5vcmcwHhcNMjAwMjEyMDk1MTI2WhcNMjIxMTA4\nMDk1MTI2WjB7MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQG\nA1UEBwwNU2FuLUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjEN\nMAsGA1UECwwET05BUDEVMBMGA1UEAwwMdmlkLm9uYXAub3JnMIIBIjANBgkqhkiG\n9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw+GIRzJzUOh0gtc+wzFJEdTnn+q5F10L0Yhr\nG1xKdjPieHIFGsoiXwcuCU8arNSqlz7ocx62KQRkcA8y6edlOAsYtdOEJvqEI9vc\neyTB/HYsbzw3URPGch4AmibrQkKU9QvGwouHtHn4R2Ft2Y0tfEqv9hxj9v4njq4A\nEiDLAFLl5FmVyCZu/MtKngSgu1smcaFKTYySPMxytgJZexoa/ALZyyE0gRhsvwHm\nNLGCPt1bmE/PEGZybsCqliyTO0S56ncD55The7+D/UDS4kE1Wg0svlWon/YsE6QW\nB3oeJDX7Kr8ebDTIAErevIAD7Sm4ee5se2zxYrsYlj0MzHZtvwIDAQABoxAwDjAM\nBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCvQ1pTvjON6vSlcJRKSY4r\n8q7L4/9ZaVXWJAjzEYJtPIqsgGiPWz0vGfgklowU6tZxp9zRZFXfMil+mPQSe+yo\nULrZSQ/z48YHPueE/BNO/nT4aaVBEhPLR5aVwC7uQVX8H+m1V1UGT8lk9vdI9rej\nCI9l524sLCpdE4dFXiWK2XHEZ0Vfylk221u3IYEogVVA+UMX7BFPSsOnI2vtYK/i\nlwZtlri8LtTusNe4oiTkYyq+RSyDhtAswg8ANgvfHolhCHoLFj6w1IkG88UCmbwN\nd7BoGMy06y5MJxyXEZG0vR7eNeLey0TIh+rAszAFPsIQvrOHW+HuA+WLQAj1mhnm\n-----END CERTIFICATE-----",
- "-----BEGIN CERTIFICATE-----\nMIIDqTCCApGgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwgZcxCzAJBgNVBAYTAlVT\nMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw\nFwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMREwDwYDVQQD\nDAhvbmFwLm9yZzEeMBwGCSqGSIb3DQEJARYPdGVzdGVyQG9uYXAub3JnMB4XDTIw\nMDIxMjA5NDAxMloXDTIyMTEwODA5NDAxMlowgYQxCzAJBgNVBAYTAlVTMRMwEQYD\nVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkwFwYDVQQK\nDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQDDBVpbnRl\ncm1lZGlhdGUub25hcC5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\nAQC1oOYMZ6G+2DGDAizYnzdCNiogivlht1s4oqgem7fM1XFPxD2p31ATIibOdqr/\ngv1qemO9Q4r1xn6w1Ufq7T1K7PjnMzdSeTqZefurE2JM/HHx2QvW4TjMlz2ILgaD\nL1LN60kmMQSOi5VxKJpsrCQxbOsxhvefd212gny5AZMcjJe23kUd9OxUrtvpdLEv\nwI3vFEvT7oRUnEUg/XNz7qeg33vf1C39yMR+6O4s6oevgsEebVKjb+yOoS6zzGtz\n72wZjm07C54ZlO+4Uy+QAlMjRiU3mgWkKbkOy+4CvwehjhpTikdBs2DX39ZLGHhn\nL/0a2NYtGulp9XEqmTvRoI+PAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADggEBADcitdJ6YswiV8jAD9GK0gf3+zqcGegt4kt+79JXlXYbb1sY\nq3o6prcB7nSUoClgF2xUPCslFGpM0Er9FCSFElQM/ru0l/KVmJS6kSpwEHvsYIH3\nq5anta+Pyk8JSQWAAw+qrind0uBQMnhR8Tn13tgV+Kjvg/xlH/nZIEdN5YtLB1cA\nbeVsZRyRfVL9DeZU8s/MZ5wC3kgcEp5A4m5lg7HyBxBdqhzFcDr6xiy6OGqW8Yep\nxrwfc8Fw8a/lOv4U+tBeGNKPQDYaL9hh+oM+qMkNXsHXDqdJsuEGJtU4i3Wcwzoc\nXGN5NWV//4bP+NFmwgcn7AYCdRvz04A8GU/0Cwg=\n-----END CERTIFICATE-----"
- ],
- "trustedCertificates": [
- "-----BEGIN CERTIFICATE-----\nMIIDtzCCAp8CFAwqQddh4/iyGfP8UZ3dpXlxfAN8MA0GCSqGSIb3DQEBCwUAMIGX\nMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2Fu\nLUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwE\nT05BUDERMA8GA1UEAwwIb25hcC5vcmcxHjAcBgkqhkiG9w0BCQEWD3Rlc3RlckBv\nbmFwLm9yZzAeFw0yMDAyMTIwOTM0MjdaFw0yMTAyMTEwOTM0MjdaMIGXMQswCQYD\nVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuLUZyYW5j\naXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwET05BUDER\nMA8GA1UEAwwIb25hcC5vcmcxHjAcBgkqhkiG9w0BCQEWD3Rlc3RlckBvbmFwLm9y\nZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMCFrnO7/eT6V+7XkPPd\neiL/6xXreuegvit/1/jTVjG+3AOVcmTn2WXwXXRcQLvkWQfJVPoltsY8E3FqFRti\n797XjY6cdQJFVDyzNU0+Fb4vJL9FK5wSvnS6EFjBEn3JvXRlENorDCs/mfjkjJoa\nDl74gXQEJYcg4nsTeNIj7cm3Q7VK3mZt1t7LSJJ+czxv69UJDuNJpmQ/2WOKyLZA\ngTtBJ+Hyol45/OLsrqwq1dAn9ZRWIFPvRt/XQYH9bI/6MtqSreRVUrdYCiTe/XpP\nB/OM6NEi2+p5QLi3Yi70CEbqP3HqUVbkzF+r7bwIb6M5/HxfqzLmGwLvD+6rYnUn\nBm8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAhXoO65DXth2X/zFRNsCNpLwmDy7r\nPxT9ZAIZAzSxx3/aCYiuTrKP1JnqjkO+F2IbikrI4n6sKO49SKnRf9SWTFhd+5dX\nvxq5y7MaqxHAY9J7+Qzq33+COVFQnaF7ddel2NbyUVb2b9ZINNsaZkkPXui6DtQ7\n/Fb/1tmAGWd3hMp75G2thBSzs816JMKKa9WD+4VGATEs6OSll4sv2fOZEn+0mAD3\n9q9c+WtLGIudOwcHwzPb2njtNntQSCK/tVOqbY+vzhMY3JW+p9oSrLDSdGC+pAKK\nm/wB+2VPIYcsPMtIhHC4tgoSaiCqjXYptaOh4b8ye8CPBUCpX/AYYkN0Ow==\n-----END CERTIFICATE-----",
- "-----BEGIN CERTIFICATE-----\nMIIDvzCCAqcCFF5DejiyfoNfPiiMmBXulniBewBGMA0GCSqGSIb3DQEBCwUAMIGb\nMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2Fu\nLUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwE\nT05BUDEVMBMGA1UEAwwMbmV3Lm9uYXAub3JnMR4wHAYJKoZIhvcNAQkBFg90ZXN0\nZXJAb25hcC5vcmcwHhcNMjAwMjEyMDk1OTM3WhcNMjEwMjExMDk1OTM3WjCBmzEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbi1G\ncmFuY2lzY28xGTAXBgNVBAoMEExpbnV4LUZvdW5kYXRpb24xDTALBgNVBAsMBE9O\nQVAxFTATBgNVBAMMDG5ldy5vbmFwLm9yZzEeMBwGCSqGSIb3DQEJARYPdGVzdGVy\nQG9uYXAub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtF4FXeDV\nng/inC/bTACmZnLC9IiC7PyG/vVbMxxN1bvQLRAwC/Hbl3i9zD68Vs/jPPr/SDr9\n2rgItdDdUY1V30Y3PT06F11XdEaRb+t++1NX0rDf1AqPaBZgnBmB86s1wbqHdJTr\nwEImDZ5xMPfP3fiWy/9Yw/U7iRMIi1/oI0lWuHJV0bn908shuJ6dvInpRCoDnoTX\nYP/FiDSZCFVewQcq4TigB7kRqZrDcPZWbSlqHklDMXRwbCxAiFSziuX6TBwru9Rn\nHhIeXVSgMU1ZSSopVbJGtQ4zSsU1nvTK5Bhc2UHGcAOZy1xTN5D9EEbTqh7l+Wtx\ny8ojkEXvFG8lVwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAE+bUphwHit78LK8sb\nOMjt4DiEu32KeSJOpYgPLeBeAIynaNsa7sQrpuxerGNTmQWIcw6olXI0J+OOwkik\nII7elrYtd5G1uALxXWdamNsaY0Du34moVL1YjexJ7qQ4oBUxg2tuY8NAQGDK+23I\nnCA+ZwzdTJo73TYS6sx64d/YLWkX4nHGUoMlF+xUH34csDyhpuTSzQhC2quB5N8z\ntSFdpe4z2jqx07qo2EBFxi03EQ8Q0ex6l421QM2gbs7cZQ66K0DkpPcF2+iHZnyx\nxq1lnlsWHklElF2bhyXTn3fPp5wtan00P8IolKx7CAWb92QjkW6M0RvTW/xuwIzh\n0rTO\n-----END CERTIFICATE-----"
- ]
-} \ No newline at end of file
diff --git a/certServiceClient/src/test/resources/expectedFirstElementOfCertificateChain b/certServiceClient/src/test/resources/expectedFirstElementOfCertificateChain
deleted file mode 100644
index 1cbbc8d3..00000000
--- a/certServiceClient/src/test/resources/expectedFirstElementOfCertificateChain
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDjDCCAnSgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwgYQxCzAJBgNVBAYTAlVT
-MRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4tRnJhbmNpc2NvMRkw
-FwYDVQQKDBBMaW51eC1Gb3VuZGF0aW9uMQ0wCwYDVQQLDARPTkFQMR4wHAYDVQQD
-DBVpbnRlcm1lZGlhdGUub25hcC5vcmcwHhcNMjAwMjEyMDk1MTI2WhcNMjIxMTA4
-MDk1MTI2WjB7MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQG
-A1UEBwwNU2FuLUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjEN
-MAsGA1UECwwET05BUDEVMBMGA1UEAwwMdmlkLm9uYXAub3JnMIIBIjANBgkqhkiG
-9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw+GIRzJzUOh0gtc+wzFJEdTnn+q5F10L0Yhr
-G1xKdjPieHIFGsoiXwcuCU8arNSqlz7ocx62KQRkcA8y6edlOAsYtdOEJvqEI9vc
-eyTB/HYsbzw3URPGch4AmibrQkKU9QvGwouHtHn4R2Ft2Y0tfEqv9hxj9v4njq4A
-EiDLAFLl5FmVyCZu/MtKngSgu1smcaFKTYySPMxytgJZexoa/ALZyyE0gRhsvwHm
-NLGCPt1bmE/PEGZybsCqliyTO0S56ncD55The7+D/UDS4kE1Wg0svlWon/YsE6QW
-B3oeJDX7Kr8ebDTIAErevIAD7Sm4ee5se2zxYrsYlj0MzHZtvwIDAQABoxAwDjAM
-BgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCvQ1pTvjON6vSlcJRKSY4r
-8q7L4/9ZaVXWJAjzEYJtPIqsgGiPWz0vGfgklowU6tZxp9zRZFXfMil+mPQSe+yo
-ULrZSQ/z48YHPueE/BNO/nT4aaVBEhPLR5aVwC7uQVX8H+m1V1UGT8lk9vdI9rej
-CI9l524sLCpdE4dFXiWK2XHEZ0Vfylk221u3IYEogVVA+UMX7BFPSsOnI2vtYK/i
-lwZtlri8LtTusNe4oiTkYyq+RSyDhtAswg8ANgvfHolhCHoLFj6w1IkG88UCmbwN
-d7BoGMy06y5MJxyXEZG0vR7eNeLey0TIh+rAszAFPsIQvrOHW+HuA+WLQAj1mhnm
------END CERTIFICATE----- \ No newline at end of file
diff --git a/certServiceClient/src/test/resources/expectedFirstElementOfTrustedCertificates b/certServiceClient/src/test/resources/expectedFirstElementOfTrustedCertificates
deleted file mode 100644
index 2d36a220..00000000
--- a/certServiceClient/src/test/resources/expectedFirstElementOfTrustedCertificates
+++ /dev/null
@@ -1,22 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDtzCCAp8CFAwqQddh4/iyGfP8UZ3dpXlxfAN8MA0GCSqGSIb3DQEBCwUAMIGX
-MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2Fu
-LUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwE
-T05BUDERMA8GA1UEAwwIb25hcC5vcmcxHjAcBgkqhkiG9w0BCQEWD3Rlc3RlckBv
-bmFwLm9yZzAeFw0yMDAyMTIwOTM0MjdaFw0yMTAyMTEwOTM0MjdaMIGXMQswCQYD
-VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuLUZyYW5j
-aXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwET05BUDER
-MA8GA1UEAwwIb25hcC5vcmcxHjAcBgkqhkiG9w0BCQEWD3Rlc3RlckBvbmFwLm9y
-ZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMCFrnO7/eT6V+7XkPPd
-eiL/6xXreuegvit/1/jTVjG+3AOVcmTn2WXwXXRcQLvkWQfJVPoltsY8E3FqFRti
-797XjY6cdQJFVDyzNU0+Fb4vJL9FK5wSvnS6EFjBEn3JvXRlENorDCs/mfjkjJoa
-Dl74gXQEJYcg4nsTeNIj7cm3Q7VK3mZt1t7LSJJ+czxv69UJDuNJpmQ/2WOKyLZA
-gTtBJ+Hyol45/OLsrqwq1dAn9ZRWIFPvRt/XQYH9bI/6MtqSreRVUrdYCiTe/XpP
-B/OM6NEi2+p5QLi3Yi70CEbqP3HqUVbkzF+r7bwIb6M5/HxfqzLmGwLvD+6rYnUn
-Bm8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAhXoO65DXth2X/zFRNsCNpLwmDy7r
-PxT9ZAIZAzSxx3/aCYiuTrKP1JnqjkO+F2IbikrI4n6sKO49SKnRf9SWTFhd+5dX
-vxq5y7MaqxHAY9J7+Qzq33+COVFQnaF7ddel2NbyUVb2b9ZINNsaZkkPXui6DtQ7
-/Fb/1tmAGWd3hMp75G2thBSzs816JMKKa9WD+4VGATEs6OSll4sv2fOZEn+0mAD3
-9q9c+WtLGIudOwcHwzPb2njtNntQSCK/tVOqbY+vzhMY3JW+p9oSrLDSdGC+pAKK
-m/wB+2VPIYcsPMtIhHC4tgoSaiCqjXYptaOh4b8ye8CPBUCpX/AYYkN0Ow==
------END CERTIFICATE----- \ No newline at end of file
diff --git a/certServiceClient/src/test/resources/expectedKeystore.jks b/certServiceClient/src/test/resources/expectedKeystore.jks
deleted file mode 100644
index 95359b0e..00000000
--- a/certServiceClient/src/test/resources/expectedKeystore.jks
+++ /dev/null
Binary files differ
diff --git a/certServiceClient/src/test/resources/expectedTruststore.jks b/certServiceClient/src/test/resources/expectedTruststore.jks
deleted file mode 100644
index ab7d93d9..00000000
--- a/certServiceClient/src/test/resources/expectedTruststore.jks
+++ /dev/null
Binary files differ
diff --git a/certServiceClient/src/test/resources/keystore.jks b/certServiceClient/src/test/resources/keystore.jks
deleted file mode 100644
index 0de9a18d..00000000
--- a/certServiceClient/src/test/resources/keystore.jks
+++ /dev/null
Binary files differ
diff --git a/certServiceClient/src/test/resources/missingPkResponse b/certServiceClient/src/test/resources/missingPkResponse
deleted file mode 100644
index c53358e0..00000000
--- a/certServiceClient/src/test/resources/missingPkResponse
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "timestamp": "2020-02-25T06:36:23.651+0000",
- "status": 400,
- "error": "Bad Request",
- "message": "Missing request header 'PK' for method parameter of type String",
- "path": "//v1/certificate/TestCA"
-} \ No newline at end of file
diff --git a/certServiceClient/src/test/resources/privateKey b/certServiceClient/src/test/resources/privateKey
deleted file mode 100644
index 463a27d3..00000000
--- a/certServiceClient/src/test/resources/privateKey
+++ /dev/null
Binary files differ
diff --git a/certServiceClient/src/test/resources/rsaPrivateKeyPem b/certServiceClient/src/test/resources/rsaPrivateKeyPem
deleted file mode 100644
index a99cc3c8..00000000
--- a/certServiceClient/src/test/resources/rsaPrivateKeyPem
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCwooLW/yfXHIGs
-djOW6zCM6mzGq4ZkFr0LMVBE+Y9dckGsYJzCrfC4pQtFjcvTlwalu6/YOgieR/zY
-bgVF7Ic0IYV+BssO+t6Zx2xYli4NIGc5kJgDrKtR6lWvH8AMnQEr+QiDElLBWobU
-+QGn5v8A528Ow5yD1fmxKTqqvWS4v1rOShGCIdse5ViraGjnMFxOV6u6pGqa17v7
-dTh0XIUyF/o3aSbmBHXkmvQ4pu/K1ncsF2zHIqUWAc7j8y1u5uE5o8b+dUzkcS4t
-QKfjFKP81I7XQNmpGZ8REzWyaYVk3RrMCju6iVgdKrs198Wif0b7wGswFv4BFhOp
-2jceFUwfAgMBAAECggEABjDb9x8gTVjRbrMB4eNCY14ADAKNBksJuy+ySYiZrsPH
-a3xDYktoaYBXYcuzfioH8J0gb6qxDKMnSIqqoqXEo14daKpiSZcfYDJuKLiyyoD9
-PTZFLbPKmWdmM2ogeBC0rs7eroFg5yf+G87ScQkWnPh/mvveK3y/cKcqSDu1IQh8
-3b8KQshC5g4iBqCfOMW3ASF03M4zmM3brKMWsdsAWEbFHQ34H10FXTHrAINpWIZK
-s2NL3z9tK6hXrwlZdKH6R/JWczSO7O5MBjLfeXZK7q3Tw4qtFWWjcNwfPlUZKMAS
-3fZFamFwY//qW+0yuCO59o70d9Pjm6p0DWsfOs9t8QKBgQD1iRdGV4xZXZT9Q4Wh
-LQMnChjuNHcmhdBYbmC03j3AffQwkQ1dKt++9uWYdy9dO9v1w7aygAMQI36jkDvR
-UJ1Rnmt9gQpeOL/wHP3R0uHbTtxLeGnX3Oo1Yx7Wfl98rq4mmBxjO5Lgft/6kTgz
-XgeiNDWi53KwDEOoFaZhWihZ6QKBgQC4Ka5Hc9wXD/5utpvNs5ut+9zjY0kx6kr8
-SyDZExbVR1ohtvSQ2sd2JvZPyFS0VbvYfFPhyCYcWW9LDEX168CZT5aHgcNop1Iu
-Szq8nYrljFa5Ibdlpf0qxC6JgObC2XytUR0O7BaXHBWpl0/wLpLTcfU2wTDLRoH8
-JLu7P3MoxwKBgQCI9DWqQ60CL8Op3J7NvviyLtynCVaogx0qJi8E062oD9lDubS1
-kfOJZde8ykX+ACR5mffu6p5KwzGg9BOZdhi57N5R+8cXtRnCSbl97t2R4RPZeMm4
-4P02WBpcU9LZDeoPlurGovUTCVHPRm8Nn9YsMGj2e5ip/71BJQpP5OT6+QKBgQCP
-NYJb+AG3QW22hHQmArxWEFxVyrh5g1sqU/XIOCryUVkKjK4kEq02+NdjdUJBNcYs
-c4n7MlxIgVelQXcJ5HlR/uzslQDy2eJzM3cKg2wmUvqBXnGyLuDvJ72UmdNYxC1K
-zZ/OIdLzURibV5oHCQCOQrjQCm06NasQ+zOtSYrwswKBgQCUHhgxynFNyidxPFzX
-V0X5xCbJ3jvJNjZFRsItQ97vEAkfJqxCnOZKMti0JWSlLBEViaKnqaA+ZE/SeJ/k
-Jut5h9gu4QIdeF4mf9v3tjuEQP7RaMCD6xnFZnebkQf6wlZz5VaXME4ICpi1Cnk7
-DySS9CMoRnwdwY7hAbfPtupKDA==
------END RSA PRIVATE KEY-----
diff --git a/certServiceClient/src/test/resources/testCsr b/certServiceClient/src/test/resources/testCsr
deleted file mode 100644
index aa9387bf..00000000
--- a/certServiceClient/src/test/resources/testCsr
+++ /dev/null
@@ -1 +0,0 @@
-LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KTUlJRExEQ0NBaFFDQVFBd2daQXhDekFKQmdOVkJBWVRBbEJNTVJZd0ZBWURWUVFJREExTWIzZGxjaTFUYVd4bGMybGhNUkF3RGdZRFZRUUhEQWRYY205amJHRjNNUTR3REFZRFZRUUtEQVZPYjJ0cFlURU5NQXNHQTFVRUN3d0VUMDVCVURFWE1CVUdBMVVFQXd3T2RHVnpkQzV1YjJ0cFlTNWpiMjB4SHpBZEJna3Foa2lHOXcwQkNRRVdFSFJsYzNSbGNrQnViMnRwWVM1amIyMHdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCRHdBd2dnRUtBb0lCQVFERzMwWUZKMDk3bS83dDJQV1pFbExBNmJ5bFc5Z1k0cDNod3NidC9paENqKzFqRG9YRFdpQk0wMXVGd1BqWmNiaXhwR3BQdXdVU3ZWREUzOUtwUDFHS3NCYVcrMHdLZG02Sit4YmN6ZTBEc0N6QUhCTnNYVXJEK3VzZC9jVUxOVm5UeXRZYzZubkF1VSswQzg0U1l6OGVkVHJ4UWVkSmF4MDBaS3YrdHluVnZvWUtyVVFsMlFrTDI4bFhhaWsxdWIzd1FGeFNQdndEM2xuMU81N2k0Wk9hOHlNcWx2NlpsTkxZYng2UFhsc1RqanBWTldPUllPKzdzeWdieEZ0bHYvbEgyN1BISHZJT3BUUmtGd0lVLzRHWXU2blQ0bDBqYkl0VEE0b2dhUFR6b3hodG5jaStLT1VVeVZ4OWk4eWd3cVBUb3d5UFkyNGpSb2xTd3RBQWpDYkJBZ01CQUFHZ1ZqQlVCZ2txaGtpRzl3MEJDUTR4UnpCRk1FTUdBMVVkRVFROE1EcUNEM1JsYzNReUxtNXZhMmxoTG1OdmJZSVBkR1Z6ZEM1dWIyc3VhWFF1WTI5dGdoWjBaWE4wTG1sdWRDNXVaWFF1Ym05cmFXRXVZMjl0TUEwR0NTcUdTSWIzRFFFQkN3VUFBNElCQVFBUmRlNnpiT2R2TXdKSkFETGV0TmlXT0p3TU9Ec0RJeFduUDBjbXkwTVovb21KK21JZFJSb1NZV0t2VDl5OXd3a3A1Sllzb2htMUN4c0RvS1pBZHFWWTloeENMSUJWRktEL2FveUlRUzRhM3prZFBVa0lnWW00UzJxMkI3bTFjT2YxTHpYNzVSQ3BKN3N2SDZ3RFlqV2dEOTBsVW5uamphNUF2VnJTWnRCVUhEQWZsUG5DTmhXU3hMREhTSkZhWHhERkpGbjhpT1FhdDkvUmNERHc2M0lrbWVaLzBWWDhVRjRsaWp2VWcxSGc4WUFrdXVOQnNwTmRDY2FFVFZFUHJwS3BjaFQxdDg1YnA2RnppSHczc3ZCVTM2cmhzUGNQVU5IM1NYT2tVcmZlOXp0RmJzUFB4dmJtZWx1MWEwS2FudmhDbEU0Z1dMT2tWb1k2Q0hlUktYeU0KLS0tLS1FTkQgQ0VSVElGSUNBVEUgUkVRVUVTVC0tLS0t \ No newline at end of file
diff --git a/certServiceClient/src/test/resources/testPk b/certServiceClient/src/test/resources/testPk
deleted file mode 100644
index 36bc9834..00000000
--- a/certServiceClient/src/test/resources/testPk
+++ /dev/null
@@ -1 +0,0 @@
-LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2UUlCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktjd2dnU2pBZ0VBQW9JQkFRREczMFlGSjA5N20vN3QyUFdaRWxMQTZieWxXOWdZNHAzaHdzYnQvaWhDaisxakRvWERXaUJNMDF1RndQalpjYml4cEdwUHV3VVN2VkRFMzlLcFAxR0tzQmFXKzB3S2RtNkoreGJjemUwRHNDekFIQk5zWFVyRCt1c2QvY1VMTlZuVHl0WWM2bm5BdVUrMEM4NFNZejhlZFRyeFFlZEpheDAwWkt2K3R5blZ2b1lLclVRbDJRa0wyOGxYYWlrMXViM3dRRnhTUHZ3RDNsbjFPNTdpNFpPYTh5TXFsdjZabE5MWWJ4NlBYbHNUampwVk5XT1JZTys3c3lnYnhGdGx2L2xIMjdQSEh2SU9wVFJrRndJVS80R1l1Nm5UNGwwamJJdFRBNG9nYVBUem94aHRuY2krS09VVXlWeDlpOHlnd3FQVG93eVBZMjRqUm9sU3d0QUFqQ2JCQWdNQkFBRUNnZ0VBTHdIcHFDQXhubk15SUFCdmxSNEtwNFRZVFhIWE01S2xaUTdJUE1zZHN4WVlNNWprTDFmbldLR0ErYTJ5Wkp1SDM1MlFiNFl5WGNxWUErRXdCMGRyTzlBQmx2Q1JlY3VpdDBTOWs3V3ROM2oyS3ZhMzlKNWNwTlJ6ck9RbUprOFhDNFBmZG5oS0RTOEFVdnVUV3k5UVpSK3FyZ280NUZiSVVYRVdZcC9pNkoyMGR3WW44Sm9HamV5WkFBdVhKQktOYzRJNDRndmNQUHJ4ZHBzMUh6dG5WU2RXbE1wL2lDZnc2YnNlRG94aCtkcXYrTXBrbUhROEV6WVZyVUNmbnhsTWNoMmtwenJpOXdTS3ZrZmMzckFieUpTWnhPQ3hYd2ZvTit3M05JQlpOQzh3WStIZC9nVzJPdFNkY2JOaHJ5UWdjMUVWVGtBdVdzTG1jNXZiTjRZQUVRS0JnUUR1WUdCUmVGZ3FUT1BhNHJJVEZhY1BSZm1qdGNmRnpqSEJLNDA5emhSL0VEWERDNGdxVmpxYWZGSkNIWFp4USt2Q1N3UXBvYVpQcTgraWFmc0pVTUdlcjhLNGdQR0xJTmVueFF2ZEF2c2M4NnA2MzZlakYxbFVLdzA4Rmhzam5zL3pyeGxhZnB3eWpGb0RIcFBoWGg2R25sNGx1NmEycGF2bm8wK3dzWGNRZFFLQmdRRFZremhzY1h1SG0wMnZTTE9KN1RZOHEzQSthbUZrb2hBOVY0YmpJYVpBZ2ZoVHZjMS9aSWM4THNRQmZBL2RKZ0R1eldOYjVqckJ5S0NQMWZDU1FZZ2VybmpSYXFRRlB6ZC82bmswSWZzNjUreUJ6bHlBVDVQNjB0Qjk2NEhsSjBYODRnc1owZlMweFlBRTNxWW83UG1QRUNDRXJPQ05FZTlLRXZabjBVanpuUUtCZ1FEYVAyMFFTbkhXVU0yeFl5c05KQjd2Y2U3TlA2cW5aVkRTZnJCemJOSUJQL01wSDg3TWpHUmRld1BKT3JadG4zVWtUNUNCR1ZwdXlXeHlWRHdlWEV6Wm9DeFV4dUhmc3ZNZnpONCt2UEx5bi9sdlJJUjBZdlZMaFpzNWJ6ZnIxZ1NwSktDKzVQclhvUDdzcWp0VTlOcFlBSGxNYk5HSG1vbVlyRUpURVRoazNRS0JnR1FCRm5kNHY4M2tnNENpK3lhSFExRXZPVlNRZldBZ25wZ0todWVObHdvM2tXNnN2aTk3Zy9ORE5wWTNZRG8rRkV1OU1sd1N0c3FNUmRwejQ3eW9JTE8xSUc5MmpxekNTQnVHVUJDQUpPSVZQT0lmSGFNYklBQmZmQzZwK3QyeEFRMkRUbzFkaVVhbi8rVEgyR2ZyWm9OOW1xeGxRcFBycE84N1o5Tis1TGpsQW9HQVhFQXI5Vmo5WmF3bE5yV0VZYjgyN1J6NVNFZkFjSmFFeTVhVzFUVWNzZVc0bWgwYmNuTzVCSHQvYTFmN3VoQmJoY2xQVFlPOTBSNGpLcUtGK2lVa2VDRHV0TmcrM09ncTdKaS9PWk5vajRSaUM1WWV4TWs5d1kxc3NVV0pqbDVoUURpd1BRQU5Zc09TSWxOT3Z2SWpydG81RnhNWVN5UndHamYrYnRSTzIyYz0KLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQ \ No newline at end of file
diff --git a/certServiceClient/src/test/resources/truststore.jks b/certServiceClient/src/test/resources/truststore.jks
deleted file mode 100644
index 2686690e..00000000
--- a/certServiceClient/src/test/resources/truststore.jks
+++ /dev/null
Binary files differ
diff --git a/certServiceClient/version.properties b/certServiceClient/version.properties
deleted file mode 100644
index 00ef5645..00000000
--- a/certServiceClient/version.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-major=1
-minor=2
-patch=0
-base_version=${major}.${minor}.${patch}
-release_version=${base_version}
-snapshot_version=${base_version}-SNAPSHOT
diff --git a/certs/Makefile b/certs/Makefile
deleted file mode 100644
index de797a53..00000000
--- a/certs/Makefile
+++ /dev/null
@@ -1,111 +0,0 @@
-all: step_1 step_2 step_3 step_4 step_5 step_6 step_7 step_8 step_9 step_10 step_11 step_12 step_13 step_14 step_15
-.PHONY: all
-#Clear certificates
-clear:
- @echo "Clear certificates"
- rm certServiceClient-keystore.jks certServiceServer-keystore.jks root.crt truststore.jks certServiceServer-keystore.p12
- @echo "#####done#####"
-
-#Generate root private and public keys
-step_1:
- @echo "Generate root private and public keys"
- keytool -genkeypair -v -alias root -keyalg RSA -keysize 4096 -validity 3650 -keystore root-keystore.jks \
- -dname "CN=onap.org, OU=ONAP, O=Linux-Foundation, L=San-Francisco, ST=California, C=US" -keypass secret \
- -storepass secret -ext BasicConstraints:critical="ca:true"
- @echo "#####done#####"
-
-#Export public key as certificate
-step_2:
- @echo "(Export public key as certificate)"
- keytool -exportcert -alias root -keystore root-keystore.jks -storepass secret -file root.crt -rfc
- @echo "#####done#####"
-
-#Self-signed root (import root certificate into truststore)
-step_3:
- @echo "(Self-signed root (import root certificate into truststore))"
- keytool -importcert -alias root -keystore truststore.jks -file root.crt -storepass secret -noprompt
- @echo "#####done#####"
-
-#Generate certService's client private and public keys
-step_4:
- @echo "Generate certService's client private and public keys"
- keytool -genkeypair -v -alias certServiceClient -keyalg RSA -keysize 2048 -validity 365 \
- -keystore certServiceClient-keystore.jks -storetype JKS \
- -dname "CN=onap.org,OU=ONAP,O=Linux-Foundation,L=San-Francisco,ST=California,C=US" \
- -keypass secret -storepass secret
- @echo "####done####"
-
-#Generate certificate signing request for certService's client
-step_5:
- @echo "Generate certificate signing request for certService's client"
- keytool -certreq -keystore certServiceClient-keystore.jks -alias certServiceClient -storepass secret -file certServiceClient.csr
- @echo "####done####"
-
-#Sign certService's client certificate by root CA
-step_6:
- @echo "Sign certService's client certificate by root CA"
- keytool -gencert -v -validity 365 -keystore root-keystore.jks -storepass secret -alias root \
- -infile certServiceClient.csr -outfile certServiceClientByRoot.crt -rfc -ext bc=0 \
- -ext ExtendedkeyUsage="serverAuth,clientAuth"
- @echo "####done####"
-
-#Import root certificate into client
-step_7:
- @echo "Import root certificate into intermediate"
- cat root.crt >> certServiceClientByRoot.crt
- @echo "####done####"
-
-#Import signed certificate into certService's client
-step_8:
- @echo "Import signed certificate into certService's client"
- keytool -importcert -file certServiceClientByRoot.crt -destkeystore certServiceClient-keystore.jks -alias certServiceClient -storepass secret -noprompt
- @echo "####done####"
-
-#Generate certService private and public keys
-step_9:
- @echo "Generate certService private and public keys"
- keytool -genkeypair -v -alias aaf-cert-service -keyalg RSA -keysize 2048 -validity 365 \
- -keystore certServiceServer-keystore.jks -storetype JKS \
- -dname "CN=onap.org,OU=ONAP,O=Linux-Foundation,L=San-Francisco,ST=California,C=US" \
- -keypass secret -storepass secret -ext BasicConstraints:critical="ca:false"
- @echo "####done####"
-
-#Generate certificate signing request for certService
-step_10:
- @echo "Generate certificate signing request for certService"
- keytool -certreq -keystore certServiceServer-keystore.jks -alias aaf-cert-service -storepass secret -file certServiceServer.csr
- @echo "####done####"
-
-#Sign certService certificate by root CA
-step_11:
- @echo "Sign certService certificate by root CA"
- keytool -gencert -v -validity 365 -keystore root-keystore.jks -storepass secret -alias root \
- -infile certServiceServer.csr -outfile certServiceServerByRoot.crt -rfc -ext bc=0 \
- -ext ExtendedkeyUsage="serverAuth,clientAuth" -ext SubjectAlternativeName:="DNS:aaf-cert-service,DNS:localhost"
- @echo "####done####"
-
-#Import root certificate into server
-step_12:
- @echo "Import root certificate into intermediate(server)"
- cat root.crt >> certServiceServerByRoot.crt
- @echo "####done####"
-
-#Import signed certificate into certService
-step_13:
- @echo "Import signed certificate into certService"
- keytool -importcert -file certServiceServerByRoot.crt -destkeystore certServiceServer-keystore.jks -alias aaf-cert-service \
- -storepass secret -noprompt
- @echo "####done####"
-
-#Convert certServiceServer-keystore(.jks) to PCKS12 format(.p12)
-step_14:
- @echo "Convert certServiceServer-keystore(.jks) to PCKS12 format(.p12)"
- keytool -importkeystore -srckeystore certServiceServer-keystore.jks -srcstorepass secret \
- -destkeystore certServiceServer-keystore.p12 -deststoretype PKCS12 -deststorepass secret
- @echo "#####done#####"
-
-#Clear unused certificates
-step_15:
- @echo "Clear unused certificates"
- rm certServiceClientByRoot.crt certServiceClient.csr root-keystore.jks certServiceServerByRoot.crt certServiceServer.csr
- @echo "#####done#####"
diff --git a/certs/certServiceClient-keystore.jks b/certs/certServiceClient-keystore.jks
deleted file mode 100644
index e7da9a7d..00000000
--- a/certs/certServiceClient-keystore.jks
+++ /dev/null
Binary files differ
diff --git a/certs/certServiceServer-keystore.jks b/certs/certServiceServer-keystore.jks
deleted file mode 100644
index f47adb61..00000000
--- a/certs/certServiceServer-keystore.jks
+++ /dev/null
Binary files differ
diff --git a/certs/certServiceServer-keystore.p12 b/certs/certServiceServer-keystore.p12
deleted file mode 100644
index 9b90af64..00000000
--- a/certs/certServiceServer-keystore.p12
+++ /dev/null
Binary files differ
diff --git a/certs/root.crt b/certs/root.crt
deleted file mode 100644
index b5e75dad..00000000
--- a/certs/root.crt
+++ /dev/null
@@ -1,33 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIFnjCCA4agAwIBAgIEDQtWKTANBgkqhkiG9w0BAQwFADB3MQswCQYDVQQGEwJV
-UzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuLUZyYW5jaXNjbzEZ
-MBcGA1UEChMQTGludXgtRm91bmRhdGlvbjENMAsGA1UECxMET05BUDERMA8GA1UE
-AxMIb25hcC5vcmcwHhcNMjAwNzA5MDgwNDE1WhcNMzAwNzA3MDgwNDE1WjB3MQsw
-CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuLUZy
-YW5jaXNjbzEZMBcGA1UEChMQTGludXgtRm91bmRhdGlvbjENMAsGA1UECxMET05B
-UDERMA8GA1UEAxMIb25hcC5vcmcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK
-AoICAQCkxel9G29Hgy9j7cEQ0BGlPrP9s1SF3ADe7f56jTjQd/jFUsN67Da+l9Dt
-vy1yUwPnTr3krpXOHwQKplsuBDMoa0ayRhqUpp6fuSuu/zgGJOQIe7NlJh9FbYfq
-ax0nHO8qtwd+eTUCqkwVfOFZpDFwR7Ss73Z++14Em8TgFiIsTlBV1sa/xRWLT9JL
-Sqnr0tQiUJewO6sCUsis+U7kEf+QCueJAktMxR70rQcAJ2gd/zlnIaoaL4rF+MU8
-xlbEfMK/rxC6jeVm3oJu4ihjDKj1V6PDyEtzjsWQFtM+y6wgd98Kxt+0mHW3mZZ0
-+Ul0fHSE0fRNp8qEMOUKYFbCffWBrMBZaOaUy6FSnnGi8frv7WqJXNiO2lClhsN1
-2yA1HgiorhK9sXjVdwsjTmJhOdvn5sla22+QXrobNflHZHo8JhWHpZ9RbBWAZdaa
-FrEizBoDnkpdaNb2PykYjqPo8D1Y/lOSDOg32wOW50F6bZg3yyQzFe0+PsAPK/u+
-b8THRJhkbXYvcAoDQv785aXoaa0mVg+yAvz6dorchJkViaOvUlNl+DNNKGJb1hWc
-KWLU1SpH7I9QWQYGExFEzsg4Wv2ErGponSoecAm+IM23mn/fhGrwv1r/bl5WR++5
-5nUIAbPysz3yQoMllSsBBOpuSsCLo1KQqQeQxnTwFxLS0Ag2SwIDAQABozIwMDAd
-BgNVHQ4EFgQUff+Pkp90yZtYsNvFGhq6SBdL+f0wDwYDVR0TAQH/BAUwAwEB/zAN
-BgkqhkiG9w0BAQwFAAOCAgEAAWzAQxiJb+3WiXnVC0AeQ2GBnj3JNWI13WE1VJ1a
-+hsKAGHk6ACzsGfN0BiGp81Bt/4y+AinWTPI0xnuYqfJHS8/7sEvC7aSzmR0TsuM
-u7xOYCiczoEwlM2YoFt1dRWt+ve6EZgTXzBSm75to7F3HS0dZzRaEKxyOA3ONFHT
-tGgT+u7851qJQvNVwTOt54C7/PZ9Me5y98sosiGbp0USKroJbiMXHzIligp8s1uT
-+Pm581C8YTVHKciR/4fhChu+tx39ZR2p4AoJFjEvgcWqYy+sOyn+Z8sWWLoj3dFk
-xjdpSRLPI771ihGdV2JXwgzN1ei8OvUzrW1a1gLZkZ1ZWtK4rwpJteFh4YW/wuDb
-dKElfqXJITmOEO+uT4cJ5+hGa3rl6asxbEJ6vhy7SZPOzgM1uAjRT1MpBtG/ZPY5
-mOkjzNbjlNsgwJNkuXCi4+3DWNC3QNrIqm825Wdr79TM3kYGfkK/ngargA0z0KYc
-7sF6P0tGo6gLACbx+dO9KFpjBIqVaw9AUwb/IOGm1Yv+QutEISqgDQTKzT0iv2Pt
-eSkR2IzaEvH0VmBnTHoHQwrV7x10cMxhwoA1mRvdt8L+gKC91CbVirIiRGCrJabO
-GiKKZ+pD5kVi9gy7omrjw2kH6Vu4aQGySGBhzpIZ977oO9u+jaTdMHBtladqVvWd
-sIM=
------END CERTIFICATE-----
diff --git a/certs/truststore.jks b/certs/truststore.jks
deleted file mode 100644
index 90dfcb93..00000000
--- a/certs/truststore.jks
+++ /dev/null
Binary files differ
diff --git a/compose-resources/client-configuration.env b/compose-resources/client-configuration.env
deleted file mode 100644
index 90eb5ea8..00000000
--- a/compose-resources/client-configuration.env
+++ /dev/null
@@ -1,19 +0,0 @@
-#Client envs
-REQUEST_URL=https://aaf-cert-service:8443/v1/certificate/
-REQUEST_TIMEOUT=10000
-OUTPUT_PATH=/var/certs
-CA_NAME=RA
-OUTPUT_TYPE=P12
-#Csr config envs
-COMMON_NAME=onap.org
-ORGANIZATION=Linux-Foundation
-ORGANIZATION_UNIT=ONAP
-LOCATION=San-Francisco
-STATE=California
-COUNTRY=US
-SANS=example.org
-#Tls config envs
-KEYSTORE_PATH=/etc/onap/aaf/certservice/certs/certServiceClient-keystore.jks
-KEYSTORE_PASSWORD=secret
-TRUSTSTORE_PATH=/etc/onap/aaf/certservice/certs/truststore.jks
-TRUSTSTORE_PASSWORD=secret
diff --git a/compose-resources/cmpServers.json b/compose-resources/cmpServers.json
deleted file mode 100644
index d6557c52..00000000
--- a/compose-resources/cmpServers.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "cmpv2Servers": [
- {
- "caName": "Client",
- "url": "http://aafcert-ejbca:8080/ejbca/publicweb/cmp/cmp",
- "issuerDN": "CN=ManagementCA",
- "caMode": "CLIENT",
- "authentication": {
- "iak": "mypassword",
- "rv": "mypassword"
- }
- },
- {
- "caName": "RA",
- "url": "http://aafcert-ejbca:8080/ejbca/publicweb/cmp/cmpRA",
- "issuerDN": "CN=ManagementCA",
- "caMode": "RA",
- "authentication": {
- "iak": "mypassword",
- "rv": "mypassword"
- }
- }
- ]
-}
diff --git a/compose-resources/ejbca-configuration.sh b/compose-resources/ejbca-configuration.sh
deleted file mode 100755
index 77f5c555..00000000
--- a/compose-resources/ejbca-configuration.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-configureEjbca() {
- ejbca.sh config cmp addalias --alias cmpRA
- ejbca.sh config cmp updatealias --alias cmpRA --key operationmode --value ra
- ejbca.sh ca editca --caname ManagementCA --field cmpRaAuthSecret --value mypassword
- ejbca.sh config cmp updatealias --alias cmpRA --key responseprotection --value pbe
- ejbca.sh config cmp dumpalias --alias cmpRA
- ejbca.sh config cmp addalias --alias cmp
- ejbca.sh config cmp updatealias --alias cmp --key allowautomatickeyupdate --value true
- ejbca.sh config cmp updatealias --alias cmp --key responseprotection --value pbe
- ejbca.sh ra addendentity --username Node123 --dn "CN=Node123" --caname ManagementCA --password mypassword --type 1 --token USERGENERATED
- ejbca.sh ra setclearpwd --username Node123 --password mypassword
- ejbca.sh config cmp updatealias --alias cmp --key extractusernamecomponent --value CN
- ejbca.sh config cmp dumpalias --alias cmp
- ejbca.sh ca getcacert --caname ManagementCA -f /dev/stdout > cacert.pem
-}
-
-configureEjbca
diff --git a/docker-compose.yml b/docker-compose.yml
deleted file mode 100644
index 8aa72a55..00000000
--- a/docker-compose.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-version: "2.1"
-
-services:
- ejbca:
- image: primekey/ejbca-ce:6.15.2.5
- hostname: cahostname
- container_name: aafcert-ejbca
- ports:
- - "80:8080"
- - "443:8443"
- volumes:
- - ./compose-resources/ejbca-configuration.sh:/opt/primekey/scripts/ejbca-configuration.sh
- healthcheck:
- test: ["CMD-SHELL", "curl -kI https://localhost:8443/ejbca/publicweb/healthcheck/ejbcahealth"]
- interval: 10s
- timeout: 3s
- retries: 15
- networks:
- - certservice
-
- aaf-cert-service:
- image: onap/org.onap.aaf.certservice.aaf-certservice-api:latest
- volumes:
- - ./compose-resources/cmpServers.json:/etc/onap/aaf/certservice/cmpServers.json
- - ./certs/truststore.jks:/etc/onap/aaf/certservice/certs/truststore.jks
- - ./certs/root.crt:/etc/onap/aaf/certservice/certs/root.crt
- - ./certs/certServiceServer-keystore.jks:/etc/onap/aaf/certservice/certs/certServiceServer-keystore.jks
- - ./certs/certServiceServer-keystore.p12:/etc/onap/aaf/certservice/certs/certServiceServer-keystore.p12
- container_name: aafcert-service
- ports:
- - "8443:8443"
- depends_on:
- ejbca:
- condition: service_healthy
- healthcheck:
- test: ["CMD-SHELL", "curl https://localhost:8443/actuator/health --cacert /etc/onap/aaf/certservice/certs/root.crt --cert-type p12 --cert /etc/onap/aaf/certservice/certs/certServiceServer-keystore.p12 --pass secret"]
- interval: 10s
- timeout: 3s
- retries: 15
- networks:
- - certservice
-
-
-networks:
- certservice:
- driver: bridge
diff --git a/docs/index.rst b/docs/index.rst
index fb2c3a62..8d839bb4 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -7,9 +7,12 @@ AAF Certification Service
==========================================
21-08-2020
-THIS PROJECT WAS ABANDON IN RELEASE Guilin!
-New version of CertService is developed begin release Guilin in https://gerrit.onap.org/r/admin/repos/oom/platform/cert-service
-repository.
+----------
+
+ THIS PROJECT WAS ABANDONED IN Guilin RELEASE!
+
+ The new version of CertService project is developed in oom/platform/cert-service repository since Guilin release.
+ An official documentation is available at https://docs.onap.org/projects/onap-oom-platform-cert-service/en/latest/index.html#master-index
Indices and tables
==================
diff --git a/pom.xml b/pom.xml
index 8126ee99..9564be0e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,244 +37,6 @@
<java.version>11</java.version>
<springdoc-openapi-maven-plugin.apiDocsUrl>http://localhost:8080/v3/api-docs.yaml</springdoc-openapi-maven-plugin.apiDocsUrl>
- <!-- Dependencies -->
- <assertj-core.version>3.15.0</assertj-core.version>
- <mockito-core.version>3.2.4</mockito-core.version>
- <spring-core.version>5.2.3.RELEASE</spring-core.version>
- <spring-boot-starter.version>2.2.4.RELEASE</spring-boot-starter.version>
- <maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
- <maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
- <spring-boot-starter-actuator.version>2.2.4.RELEASE</spring-boot-starter-actuator.version>
- <spring-boot-starter-log4j2.version>2.1.5.RELEASE</spring-boot-starter-log4j2.version>
- <spring-cloud-starter-config.version>2.2.1.RELEASE</spring-cloud-starter-config.version>
- <springdoc-openapi-ui.version>1.2.30</springdoc-openapi-ui.version>
- <bouncycastle.version>1.60</bouncycastle.version>
- <docker-maven-plugin.version>0.33.0</docker-maven-plugin.version>
- <springdoc-openapi-maven-plugin.version>0.2</springdoc-openapi-maven-plugin.version>
- <gson.version>2.8.6</gson.version>
- <httpcomponents.version>4.5.6</httpcomponents.version>
- <commons-lang3.version>3.9</commons-lang3.version>
- <commons-io.version>2.6</commons-io.version>
- <junit.version>5.5.2</junit.version>
- <mockito-junit-jupiter.version>2.17.0</mockito-junit-jupiter.version>
-
- <!-- Docker -->
- <skipDockerPush>true</skipDockerPush>
- <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
- <maven-shade-plugin.version>3.2.2</maven-shade-plugin.version>
- <docker-image.registry>${onap.nexus.dockerregistry.daily}</docker-image.registry>
- <docker-image.namespace>onap</docker-image.namespace>
- <docker-image.name>${project.groupId}.${project.artifactId}</docker-image.name>
- <docker-image.latest>${project.version}</docker-image.latest>
- <docker-image.tag.latest>latest</docker-image.tag.latest>
- <version>${project.version}</version>
- <docker.http_proxy/>
-
</properties>
- <modules>
- <module>certService</module>
- <module>certServiceClient</module>
- </modules>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-maven-plugin</artifactId>
- <version>${springdoc-openapi-maven-plugin.version}</version>
- <executions>
- <execution>
- <phase>integration-test</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <apiDocsUrl>${springdoc-openapi-maven-plugin.apiDocsUrl}</apiDocsUrl>
- <outputFileName>api-docs.yaml</outputFileName>
- <outputDir>${project.build.directory}</outputDir>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot-starter.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin.version}</version>
- <configuration>
- <quiet>true</quiet>
- <verbose>false</verbose>
- <useStandardDocletOptions>false</useStandardDocletOptions>
- <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
- </configuration>
- <executions>
- <execution>
- <id>aggregate</id>
- <phase>site</phase>
- <goals>
- <goal>aggregate</goal>
- </goals>
- </execution>
- <execution>
- <id>attach-javadoc</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>${maven-surefire-plugin.version}</version>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
- <dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <version>${spring-boot-starter.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-log4j2</artifactId>
- <version>${spring-boot-starter-log4j2.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <version>${spring-boot-starter.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- <version>${spring-boot-starter-actuator.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-ui</artifactId>
- <version>${springdoc-openapi-ui.version}</version>
- </dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcpkix-jdk15on</artifactId>
- <version>${bouncycastle.version}</version>
- </dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk15on</artifactId>
- <version>${bouncycastle.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>${gson.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>${httpcomponents.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>${commons-lang3.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>${commons-io.version}</version>
- </dependency>
- <dependency>
- <!-- Import dependency management from Spring Boot -->
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>${spring-boot-starter.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
-
- <!-- Test dependecies -->
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>${assertj-core.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>${mockito-core.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-junit-jupiter</artifactId>
- <version>${mockito-junit-jupiter.version}</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
- </dependencyManagement>
-
</project>