aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceClient
diff options
context:
space:
mode:
Diffstat (limited to 'certServiceClient')
-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
87 files changed, 0 insertions, 5153 deletions
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