aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--certServiceClient/pom.xml3
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/AppExitHandler.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java4
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitStatus.java19
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/api/ExitableException.java2
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java (renamed from certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProvider.java)13
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/CsrFactory.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/EncryptionAlgorithmConstants.java3
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/KeyPairFactory.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoder.java9
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreator.java3
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreator.java17
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java3
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/Password.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreator.java7
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemConverter.java45
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGenerator.java4
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/StoreEntryOperation.java2
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/KeyPairGenerationException.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/exception/PemConversionException.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java12
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/common/Base64Encoder.java2
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForCsr.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java1
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java10
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java4
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java2
-rw-r--r--certServiceClient/src/main/resources/log4j2.xml3
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java2
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProviderTest.java (renamed from certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProviderTest.java)15
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java3
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/KeyPairFactoryTest.java3
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorTest.java28
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemArtifactsCreatorTest.java23
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/PemConverterTest.java53
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/RandomPasswordGeneratorTest.java3
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java17
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java9
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java1
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactoryTest.java22
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactoryTest.java22
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/httpclient/HttpClientTest.java8
45 files changed, 210 insertions, 177 deletions
diff --git a/certServiceClient/pom.xml b/certServiceClient/pom.xml
index d2e5cb28..2698e50c 100644
--- a/certServiceClient/pom.xml
+++ b/certServiceClient/pom.xml
@@ -68,7 +68,8 @@
</filter>
</filters>
<transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.onap.aaf.certservice.client.MainApp</mainClass>
</transformer>
</transformers>
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
index 0bb983ed..af30ff3e 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/AppExitHandler.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/AppExitHandler.java
@@ -16,6 +16,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client;
import org.onap.aaf.certservice.client.api.ExitStatus;
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java
index 27e8a4f0..56c355e4 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/CertServiceClient.java
@@ -20,10 +20,10 @@
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.certification.conversion.ArtifactsCreatorProvider;
import org.onap.aaf.certservice.client.common.Base64Encoder;
import org.onap.aaf.certservice.client.configuration.EnvsForClient;
import org.onap.aaf.certservice.client.configuration.EnvsForCsr;
@@ -78,7 +78,7 @@ public class CertServiceClient {
base64Encoder.encode(pkEncoder.encodePrivateKeyToPem(keyPair.getPrivate())));
ArtifactsCreatorProvider
- .getCreator(clientConfiguration.getOutputType(),
+ .get(clientConfiguration.getOutputType(),
clientConfiguration.getCertsOutputPath())
.create(certServiceData.getCertificateChain(),
certServiceData.getTrustedCertificates(),
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
index 1d321688..a84485eb 100644
--- 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
@@ -16,19 +16,20 @@
* 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"),
+ 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");
@@ -44,7 +45,7 @@ public enum ExitStatus {
return value;
}
- public String getMessage(){
+ 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
index fc1bc760..439c0488 100644
--- 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
@@ -16,6 +16,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.api;
public abstract class ExitableException extends Exception {
@@ -26,5 +27,6 @@ public abstract class ExitableException extends Exception {
public ExitableException(String message) {
super(message);
}
+
public abstract ExitStatus applicationExitStatus();
}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java
index d3d8a11b..06a4cc6e 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProvider.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java
@@ -16,9 +16,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aaf.certservice.client.certification.conversion;
-import org.onap.aaf.certservice.client.certification.PrivateKeyToPemEncoder;
+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 {
@@ -34,18 +37,20 @@ public enum ArtifactsCreatorProvider {
return ConvertedArtifactsCreatorFactory.createConverter(destPath, getExtension(), getKeyStoreType());
}
},
- PEM("PEM"){
+ PEM("PEM") {
@Override
ArtifactsCreator create(String destPath) {
return new PemArtifactsCreator(new CertFileWriter(destPath), new PrivateKeyToPemEncoder());
}
};
+
private final String keyStoreType;
+
ArtifactsCreatorProvider(String keyStoreType) {
this.keyStoreType = keyStoreType;
}
- public static ArtifactsCreator getCreator(String outputType, String destPath) {
+ public static ArtifactsCreator get(String outputType, String destPath) {
return valueOf(outputType).create(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
index a7fb3f35..e381a8ce 100644
--- 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
@@ -31,7 +31,6 @@ 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;
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
index 96b3650c..63ede568 100644
--- 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
@@ -21,7 +21,8 @@ package org.onap.aaf.certservice.client.certification;
public final class EncryptionAlgorithmConstants {
- private EncryptionAlgorithmConstants() {}
+ private EncryptionAlgorithmConstants() {
+ }
public static final String RSA_ENCRYPTION_ALGORITHM = "RSA";
public static final String SIGN_ALGORITHM = "SHA1withRSA";
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
index e7d63e2f..e997cd0d 100644
--- 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
@@ -16,6 +16,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.certification;
import org.onap.aaf.certservice.client.certification.exception.KeyPairGenerationException;
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
index 7391b119..fa6485e5 100644
--- 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
@@ -21,17 +21,16 @@
package org.onap.aaf.certservice.client.certification;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.security.PrivateKey;
-
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);
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
index 8907c481..428b85aa 100644
--- 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
@@ -16,6 +16,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.certification.conversion;
import org.onap.aaf.certservice.client.api.ExitableException;
@@ -24,6 +25,6 @@ import java.security.PrivateKey;
import java.util.List;
public interface ArtifactsCreator {
- void create(List<String> keystoreData, List<String> truststoreData, PrivateKey privateKey)
+ 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
index 4e300074..0ecee793 100644
--- 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
@@ -19,14 +19,15 @@
package org.onap.aaf.certservice.client.certification.conversion;
-import java.security.PrivateKey;
-import java.util.List;
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);
@@ -42,8 +43,8 @@ public class ConvertedArtifactsCreator implements ArtifactsCreator {
private final PemConverter converter;
private final CertFileWriter fileWriter;
- public ConvertedArtifactsCreator(CertFileWriter fileWriter, RandomPasswordGenerator passwordGenerator,
- PemConverter converter, String fileExtension) {
+ ConvertedArtifactsCreator(CertFileWriter fileWriter, RandomPasswordGenerator passwordGenerator,
+ PemConverter converter, String fileExtension) {
this.passwordGenerator = passwordGenerator;
this.converter = converter;
this.fileWriter = fileWriter;
@@ -52,13 +53,13 @@ public class ConvertedArtifactsCreator implements ArtifactsCreator {
@Override
public void create(List<String> keystoreData, List<String> truststoreData, PrivateKey privateKey)
- throws PemConversionException, CertFileWriterException {
- createKeystore(keystoreData,privateKey);
+ throws PemConversionException, CertFileWriterException {
+ createKeystore(keystoreData, privateKey);
createTruststore(truststoreData);
}
private void createKeystore(List<String> data, PrivateKey privateKey)
- throws PemConversionException, CertFileWriterException {
+ throws PemConversionException, CertFileWriterException {
Password password = passwordGenerator.generate(PASSWORD_LENGTH);
String keystoreArtifactName = String.format("%s.%s", KEYSTORE, fileExtension);
String keystorePass = String.format("%s.%s", KEYSTORE, PASS_EXT);
@@ -70,7 +71,7 @@ public class ConvertedArtifactsCreator implements ArtifactsCreator {
}
private void createTruststore(List<String> data)
- throws PemConversionException, CertFileWriterException {
+ throws PemConversionException, CertFileWriterException {
Password password = passwordGenerator.generate(PASSWORD_LENGTH);
String truststoreArtifactName = String.format("%s.%s", TRUSTSTORE, fileExtension);
String truststorePass = String.format("%s.%s", TRUSTSTORE, PASS_EXT);
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
index 5a37482a..586e2952 100644
--- 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
@@ -23,7 +23,8 @@ import org.onap.aaf.certservice.client.certification.writer.CertFileWriter;
public class ConvertedArtifactsCreatorFactory {
- private ConvertedArtifactsCreatorFactory() { }
+ private ConvertedArtifactsCreatorFactory() {
+ }
public static ConvertedArtifactsCreator createConverter(String destPath, String fileExtension, String keyStoreType) {
return new ConvertedArtifactsCreator(
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
index 9275817d..6ea1a219 100644
--- 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
@@ -17,7 +17,6 @@
* ============LICENSE_END=========================================================
*/
-
package org.onap.aaf.certservice.client.certification.conversion;
class Password {
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
index 7a4cbfa9..4bec222f 100644
--- 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
@@ -19,8 +19,6 @@
package org.onap.aaf.certservice.client.certification.conversion;
-import java.security.PrivateKey;
-import java.util.List;
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;
@@ -28,6 +26,9 @@ 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);
@@ -45,7 +46,7 @@ public class PemArtifactsCreator implements ArtifactsCreator {
@Override
public void create(List<String> keystoreData, List<String> truststoreData, PrivateKey privateKey)
- throws PkEncodingException, CertFileWriterException {
+ 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);
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
index 083e4bcf..5e82c177 100644
--- 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
@@ -19,6 +19,14 @@
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;
@@ -31,19 +39,12 @@ import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.util.List;
import java.util.Optional;
-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;
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 final LoadStoreParameter EMPTY_KEYSTORE_CONFIGURATION = null;
+ private static final LoadStoreParameter EMPTY_KEYSTORE_CONFIGURATION = null;
private final String keyStoreType;
public PemConverter(String keyStoreType) {
@@ -51,19 +52,19 @@ class PemConverter {
}
byte[] convertKeystore(List<String> certificateChain, Password password, String alias, PrivateKey privateKey)
- throws PemConversionException {
+ 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 {
+ 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 {
+ throws PemConversionException {
checkPassword(password);
final Certificate[] X509Certificates = convertToCertificateArray(certificates);
return getKeyStoreBytes(password, operation, X509Certificates);
@@ -77,7 +78,7 @@ class PemConverter {
}
private byte[] getKeyStoreBytes(Password password, StoreEntryOperation op, Certificate[] x509Certificates)
- throws PemConversionException {
+ throws PemConversionException {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
KeyStore ks = op.getStore(x509Certificates);
ks.store(bos, password.toCharArray());
@@ -89,31 +90,31 @@ class PemConverter {
}
private KeyStore getKeyStore(String alias, Password password, Certificate[] certificates, PrivateKey privateKey)
- throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
+ 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 {
+ throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
KeyStore ks = getKeyStoreInstance();
- long i = 1L;
+ long index = 1L;
for (Certificate c : certificates) {
- ks.setCertificateEntry(alias + i++, c);
+ ks.setCertificateEntry(alias + index++, c);
}
return ks;
}
private KeyStore getKeyStoreInstance()
- throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
+ 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 {
+ throws PemConversionException {
Certificate[] parsedCertificates = new Certificate[certificates.size()];
for (String certificate : certificates) {
parsedCertificates[certificates.indexOf(certificate)] = parseCertificate(certificate);
@@ -124,11 +125,11 @@ class PemConverter {
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));
+ .orElseThrow(
+ () -> new PemConversionException("The certificate couldn't be parsed correctly. " + certificate));
return new JcaX509CertificateConverter()
- .setProvider(new BouncyCastleProvider())
- .getCertificate(certHolder);
+ .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
index 6515ea54..8ad85d2c 100644
--- 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
@@ -19,10 +19,10 @@
package org.onap.aaf.certservice.client.certification.conversion;
-import java.security.SecureRandom;
-
import org.apache.commons.lang3.RandomStringUtils;
+import java.security.SecureRandom;
+
class RandomPasswordGenerator {
private static final String ALPHA = "abcdefghijklmnopqrstuvwxyz";
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
index 6ee7817b..7a41d1fe 100644
--- 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
@@ -30,5 +30,5 @@ import java.security.cert.CertificateException;
public interface StoreEntryOperation {
KeyStore getStore(Certificate[] certificates)
- throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException;
+ throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException;
}
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
index ec6fbb9c..11030ff3 100644
--- 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
@@ -16,6 +16,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.certification.exception;
import org.onap.aaf.certservice.client.api.ExitStatus;
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
index 11c448ee..4d1cdaa6 100644
--- 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
@@ -28,6 +28,7 @@ public class PemConversionException extends ExitableException {
public PemConversionException(Throwable e) {
super(e);
}
+
public PemConversionException(String message) {
super(message);
}
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
index 400c0b72..2829517c 100644
--- 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
@@ -19,14 +19,14 @@
package org.onap.aaf.certservice.client.certification.writer;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import java.nio.file.Path;
import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+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);
@@ -36,11 +36,11 @@ public class CertFileWriter {
this.destPath = destPath;
}
-public void saveData(byte[] data, String filename) throws CertFileWriterException {
+ 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) {
+ } catch (IOException e) {
LOGGER.error("File creation failed, exception message: {}", e.getMessage());
throw new CertFileWriterException(e);
}
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
index 1f90db1b..bfa43071 100644
--- 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
@@ -22,7 +22,7 @@ package org.onap.aaf.certservice.client.common;
import org.bouncycastle.util.encoders.Base64;
public class Base64Encoder {
- public String encode(String string){
+ 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/EnvProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java
index 1b8c3606..15339bbd 100644
--- 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.configuration;
import java.util.Optional;
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
index dedd4d6b..9321964c 100644
--- 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.configuration;
import java.util.Optional;
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
index 06225d68..9a892b24 100644
--- 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.configuration;
import java.util.Optional;
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
index f9360d73..ea280736 100644
--- 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.configuration.exception;
import org.onap.aaf.certservice.client.api.ExitStatus;
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
index a7cf4f7a..cf785a71 100644
--- 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.configuration.exception;
import org.onap.aaf.certservice.client.api.ExitStatus;
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
index a54c9263..24ed8b0d 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
@@ -21,7 +21,7 @@
package org.onap.aaf.certservice.client.configuration.factory;
-import org.onap.aaf.certservice.client.certification.conversion.ArtifactsCreatorProvider;
+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;
@@ -43,10 +43,10 @@ public abstract class AbstractConfigurationFactory<T extends ConfigurationModel>
}
public boolean isCommonNameValid(String commonName) {
- return !isSpecialCharsPresent(commonName) &&
- !isHttpProtocolsPresent(commonName) &&
- !isIpAddressPresent(commonName) &&
- !isPortNumberPresent(commonName);
+ return !isSpecialCharsPresent(commonName)
+ && !isHttpProtocolsPresent(commonName)
+ && !isIpAddressPresent(commonName)
+ && !isPortNumberPresent(commonName);
}
public boolean isSpecialCharsPresent(String stringToCheck) {
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
index 151c2a1c..ad5a5f1c 100644
--- 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
@@ -26,11 +26,11 @@ 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) {
+ public CertServiceApiResponseException(int responseCode, String messageFromApi) {
super(String.format("CertService HTTP unsuccessful response. Response code: %d . Message from Service: %s",
responseCode,
- messageFromAPI));
+ messageFromApi));
}
@Override
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
index 697d152a..bc48554a 100644
--- 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
@@ -26,7 +26,7 @@ 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 e){
+ public HttpClientException(Throwable e) {
super(e);
}
diff --git a/certServiceClient/src/main/resources/log4j2.xml b/certServiceClient/src/main/resources/log4j2.xml
index 37eb078b..bf4b6239 100644
--- a/certServiceClient/src/main/resources/log4j2.xml
+++ b/certServiceClient/src/main/resources/log4j2.xml
@@ -8,7 +8,8 @@
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">
+ <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"/>
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
index 7e7bf5db..36808941 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java
@@ -16,6 +16,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client;
import org.junit.jupiter.api.Test;
@@ -32,6 +33,7 @@ import static org.onap.aaf.certservice.client.api.ExitStatus.SUCCESS;
class CertServiceClientTest {
@Spy
AppExitHandler appExitHandler = new AppExitHandler();
+
@Test
public void shouldExitWithDefinedExitCode_onRunCallWhenNoEnvsPresent() {
// given
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProviderTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProviderTest.java
index 8a619991..46bacef8 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ArtifactsCreatorProviderTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProviderTest.java
@@ -17,12 +17,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.aaf.certservice.client.certification.conversion;
+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;
@@ -36,21 +39,21 @@ class ArtifactsCreatorProviderTest {
@ParameterizedTest
@ValueSource(strings = {JKS, P12})
- void artifactsProviderShouldReturnConvertedCreator(String outputType){
+ void artifactsProviderShouldReturnConvertedCreator(String outputType) {
// when
ArtifactsCreator artifactsCreator =
- ArtifactsCreatorProvider.getCreator(outputType, TEST_PATH);
+ ArtifactsCreatorProvider.get(outputType, TEST_PATH);
// then
assertThat(artifactsCreator).isInstanceOf(ConvertedArtifactsCreator.class);
}
@Test
- void artifactsProviderShouldReturnPemCreator(){
+ void artifactsProviderShouldReturnPemCreator() {
// when
ArtifactsCreator artifactsCreator =
- ArtifactsCreatorProvider.getCreator(PEM, TEST_PATH);
+ ArtifactsCreatorProvider.get(PEM, TEST_PATH);
// then
assertThat(artifactsCreator).isInstanceOf(PemArtifactsCreator.class);
}
@@ -59,7 +62,7 @@ class ArtifactsCreatorProviderTest {
@CsvSource({
"JKS, jks",
"P12, p12"})
- void getExtensionShouldProvideExtensionBasedOnArtifactType(String artifactType, String expectedExtension){
+ void getExtensionShouldProvideExtensionBasedOnArtifactType(String artifactType, String expectedExtension) {
//when
String actualExtension = ArtifactsCreatorProvider.valueOf(artifactType).getExtension();
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
index 809a91f2..e88976bf 100644
--- 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
@@ -37,7 +37,6 @@ public class CsrFactoryTest {
CsrConfiguration config = mock(CsrConfiguration.class);
-
@Test
void createEncodedCsr_shouldSucceedWhenAllFieldsAreSetCorrectly() throws KeyPairGenerationException, CsrGenerationException {
@@ -53,6 +52,6 @@ public class CsrFactoryTest {
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
index 6a4741a2..3d3d3c17 100644
--- 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
@@ -16,6 +16,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.certification;
import org.junit.jupiter.api.Test;
@@ -46,7 +47,7 @@ class KeyPairFactoryTest {
KeyPairFactory keyPairFactory = new KeyPairFactory(NOT_EXISTING_ENCRYPTION_ALGORITHM,
EncryptionAlgorithmConstants.KEY_SIZE);
// when, then
- assertThatThrownBy(() -> keyPairFactory.create()).isInstanceOf(KeyPairGenerationException.class);
+ 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/conversion/ConvertedArtifactsCreatorTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorTest.java
index 2da4ab98..e13f8be8 100644
--- 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
@@ -19,20 +19,20 @@
package org.onap.aaf.certservice.client.certification.conversion;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.security.PrivateKey;
-import java.util.List;
-
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;
@@ -44,7 +44,7 @@ class ConvertedArtifactsCreatorTest {
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 static final String P12_EXTENSION = "p12";
private CertFileWriter certFileWriter;
private RandomPasswordGenerator passwordGenerator;
@@ -64,7 +64,7 @@ class ConvertedArtifactsCreatorTest {
@Test
void convertedArtifactCreatorShouldTryCreateFileWithGivenExtension()
- throws CertFileWriterException, PemConversionException {
+ throws CertFileWriterException, PemConversionException {
//given
mockPasswordGeneratorAndPemConverter();
final String keystore = "keystore";
@@ -82,7 +82,7 @@ class ConvertedArtifactsCreatorTest {
@Test
void convertedArtifactsCreatorShouldCallConverterAndFilesCreatorMethods()
- throws PemConversionException, CertFileWriterException {
+ throws PemConversionException, CertFileWriterException {
// given
mockPasswordGeneratorAndPemConverter();
final String keystoreP12 = "keystore.p12";
@@ -95,16 +95,16 @@ class ConvertedArtifactsCreatorTest {
verify(converter, times(1))
.convertKeystore(SAMPLE_KEYSTORE_CERTIFICATE_CHAIN, SAMPLE_PASSWORD, CERTIFICATE_ALIAS, privateKey);
verify(certFileWriter, times(1))
- .saveData(SAMPLE_KEYSTORE_BYTES, keystoreP12);
+ .saveData(SAMPLE_KEYSTORE_BYTES, keystoreP12);
verify(certFileWriter, times(1))
- .saveData(SAMPLE_PASSWORD.getCurrentPassword().getBytes(), keystorePass);
+ .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 {
+ throws PemConversionException, CertFileWriterException {
// given
mockPasswordGeneratorAndPemConverter();
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
index 9963d245..5e79b96f 100644
--- 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
@@ -19,23 +19,24 @@
package org.onap.aaf.certservice.client.certification.conversion;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.security.PrivateKey;
-import java.util.List;
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 final String KEYSTORE_PEM = "keystore.pem";
- private final String TRUSTSTORE_PEM = "truststore.pem";
- private final String KEY_PEM = "key.pem";
- private final String KEY = "my private key";
+ 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);
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
index 0d67fba7..e3a58c3f 100644
--- 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
@@ -19,13 +19,12 @@
package org.onap.aaf.certservice.client.certification.conversion;
-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;
+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;
@@ -40,12 +39,14 @@ import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.util.List;
-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 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 {
@@ -72,7 +73,7 @@ class PemConverterTest {
@ParameterizedTest
@ValueSource(strings = {PKCS12, JKS})
void convertKeystoreShouldReturnKeystoreWithGivenPrivateKeyAndCertificateChain(String conversionTarget)
- throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, PemConversionException {
+ throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, PemConversionException {
// given
final String alias = "keystore-entry";
final Password password = new Password("d9D_u8LooYaXH4G48DtN#vw0");
@@ -80,7 +81,7 @@ class PemConverterTest {
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());
+ password.toCharArray());
final Certificate[] expectedChain = expectedKeyStore.getCertificateChain(alias);
privateKeyMockSetup();
@@ -109,7 +110,7 @@ class PemConverterTest {
// when
Exception exception = assertThrows(PemConversionException.class, () ->
- converter.convertKeystore(certificateChain, password, alias, privateKey)
+ converter.convertKeystore(certificateChain, password, alias, privateKey)
);
// then
@@ -119,7 +120,7 @@ class PemConverterTest {
@ParameterizedTest
@ValueSource(strings = {PKCS12, JKS})
void convertTruststoreShouldReturnTruststoreWithGivenCertificatesArray(String conversionTarget)
- throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException, PemConversionException {
+ throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException, PemConversionException {
// given
final PemConverter converter = new PemConverter(conversionTarget);
@@ -130,7 +131,7 @@ class PemConverterTest {
final List<String> trustedCertificates = getCertificates();
final KeyStore expectedTrustStore = KeyStore.getInstance(conversionTarget);
expectedTrustStore.load(new ByteArrayInputStream(Files.readAllBytes(Path.of(EXPECTED_TRUSTSTORE_PATH))),
- password.toCharArray());
+ password.toCharArray());
// when
final byte[] result = converter.convertTruststore(trustedCertificates, password, alias);
@@ -156,8 +157,8 @@ class PemConverterTest {
// when then
assertThatThrownBy(() ->
- converter.convertTruststore(trustedCertificates, password, alias))
- .isInstanceOf(PemConversionException.class).hasMessage(PASSWORD_ERROR_MSG);
+ converter.convertTruststore(trustedCertificates, password, alias))
+ .isInstanceOf(PemConversionException.class).hasMessage(PASSWORD_ERROR_MSG);
}
@Test
@@ -170,7 +171,7 @@ class PemConverterTest {
// when then
assertThatThrownBy(() -> converter.convertKeystore(certificateChain, password, alias, privateKey))
- .isInstanceOf(PemConversionException.class).hasMessage(KEY_ERROR_MSG);
+ .isInstanceOf(PemConversionException.class).hasMessage(KEY_ERROR_MSG);
}
@ParameterizedTest
@@ -185,7 +186,7 @@ class PemConverterTest {
// when then
assertThatThrownBy(() -> converter.convertKeystore(certificateChain, password, alias, privateKey))
- .isInstanceOf(PemConversionException.class).hasMessage(CERTIFICATES_ERROR_MSG);
+ .isInstanceOf(PemConversionException.class).hasMessage(CERTIFICATES_ERROR_MSG);
}
private void privateKeyMockSetup() {
@@ -196,10 +197,10 @@ class PemConverterTest {
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)
+ 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
index 169ce98a..483e35e0 100644
--- 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
@@ -19,9 +19,10 @@
package org.onap.aaf.certservice.client.certification.conversion;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
class RandomPasswordGeneratorTest {
@Test
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
index 443f5627..e7ebb32b 100644
--- 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
@@ -19,18 +19,19 @@
package org.onap.aaf.certservice.client.certification.writer;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+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 org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
class CertFileWriterTest {
@@ -54,7 +55,7 @@ class CertFileWriterTest {
@Test
void certFileWriterShouldCreateFilesWithDataInGivenLocation()
- throws IOException, CertFileWriterException {
+ throws IOException, CertFileWriterException {
// given
final byte[] data = new byte[]{-128, 1, 2, 3, 127};
File truststore = new File(OUTPUT_PATH + TRUSTSTORE_P12);
@@ -76,6 +77,6 @@ class CertFileWriterTest {
// when then
assertThatThrownBy(() -> certFileWriter.saveData(data, TRUSTSTORE_P12))
- .isInstanceOf(CertFileWriterException.class).hasMessage(ERROR_MESSAGE);
+ .isInstanceOf(CertFileWriterException.class).hasMessage(ERROR_MESSAGE);
}
}
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
index 7ef921a1..af6b2d9f 100644
--- 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.configuration;
import org.junit.jupiter.api.BeforeEach;
@@ -35,12 +36,12 @@ class EnvProviderTest {
private EnvProvider envProvider;
@BeforeEach
- public void setUp(){
- envProvider = Mockito.spy(EnvProvider.class);
+ public void setUp() {
+ envProvider = Mockito.spy(EnvProvider.class);
}
@Test
- public void shouldReturnSystemEnvVariableWhenItWasDefined(){
+ public void shouldReturnSystemEnvVariableWhenItWasDefined() {
// given
when(envProvider.getSystemEnv(TEST_ENV)).thenReturn(TEST_ENV_VALUE);
@@ -53,7 +54,7 @@ class EnvProviderTest {
}
@Test
- public void shouldReportThatSystemEnvVariableIsNotPresentWhenItWasNotDefined(){
+ public void shouldReportThatSystemEnvVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envProvider.readEnvVariable(TEST_ENV);
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
index 6273e2a6..9c0b9d8f 100644
--- 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aaf.certservice.client.configuration.factory;
import org.junit.jupiter.params.ParameterizedTest;
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
index 7239b21a..20a6c7ef 100644
--- 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
@@ -35,16 +35,16 @@ import static org.mockito.Mockito.when;
public class ClientConfigurationFactoryTest {
- private final String CA_NAME_VALID = "caaaftest2";
- private final String TIME_OUT_VALID = "30000";
- private final String OUTPUT_PATH_VALID = "/opt/app/osaaf";
- private final String URL_TO_CERT_SERVICE_VALID = "https://cert-service:8443/v1/certificate/";
- private final String URL_TO_CERT_SERVICE_DEFAULT = "https://aaf-cert-service:8443/v1/certificate/";
- private final String CA_NAME_INVALID = "caaaftest2#$";
- private final String OUTPUT_PATH_INVALID = "/opt//app/osaaf";
- private final String OUTPUT_TYPE_VALID = "JKS";
- private final String OUTPUT_TYPE_INVALID = "JKSS";
- private final String OUTPUT_TYPE_DEFAULT = "P12";
+ 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);
@@ -102,7 +102,7 @@ public class ClientConfigurationFactoryTest {
}
@Test
- void create_shouldReturnClientExceptionWhenCANameContainsSpecialCharacters() {
+ void create_shouldReturnClientExceptionWhenCaNameContainsSpecialCharacters() {
// given
when(envsForClient.getCaName()).thenReturn(Optional.of(CA_NAME_INVALID));
when(envsForClient.getOutputPath()).thenReturn(Optional.of(OUTPUT_PATH_VALID));
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
index 2edff2f1..5abd0b13 100644
--- 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
@@ -38,20 +38,20 @@ import static org.onap.aaf.certservice.client.api.ExitStatus.CSR_CONFIGURATION_E
public class CsrConfigurationFactoryTest {
- private final String COMMON_NAME_VALID = "onap.org";
- private final String SANS_VALID = "test-name";
- private final String COUNTRY_VALID = "US";
- private final String LOCATION_VALID = "San-Francisco";
- private final String ORGANIZATION_VALID = "Linux-Foundation";
- private final String ORGANIZATION_UNIT_VALID = "ONAP";
- private final String STATE_VALID = "California";
- private final String COMMON_NAME_INVALID = "onap.org*&";
- private final String COUNTRY_INVALID = "PLA";
- private final String ORGANIZATION_INVALID = "Linux?Foundation";
+ 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"){
+ private Condition<CsrConfigurationException> expectedExitCodeCondition = new Condition<>("Correct exit code") {
@Override
public boolean matches(CsrConfigurationException e) {
return e.applicationExitStatus() == CSR_CONFIGURATION_EXCEPTION;
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
index 60c2e93d..a109749b 100644
--- 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
@@ -106,18 +106,18 @@ class HttpClientTest {
//when //then
assertThatExceptionOfType(CertServiceApiResponseException.class)
- .isThrownBy(()->httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
+ .isThrownBy(() -> httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
}
@Test
- void shouldThrowHttpClientException_WhenCannotExecuteRequestToAPI() throws Exception {
+ 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, ""));
+ .isThrownBy(() -> httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
}
@Test
@@ -129,7 +129,7 @@ class HttpClientTest {
//when //then
assertThatExceptionOfType(HttpClientException.class)
- .isThrownBy(()->httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
+ .isThrownBy(() -> httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
}
private void mockServerResponse(int serverCodeResponse, String stringResponse)