aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceClient/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'certServiceClient/src/main')
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/CsrFactory.java14
-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.java6
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java6
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemToPKCS12Converter.java10
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java5
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactory.java5
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java11
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java14
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java5
10 files changed, 57 insertions, 20 deletions
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 b536127c..a7fb3f35 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
@@ -54,7 +54,7 @@ import static org.onap.aaf.certservice.client.certification.EncryptionAlgorithmC
public class CsrFactory {
- private final Logger LOGGER = LoggerFactory.getLogger(CsrFactory.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(CsrFactory.class);
private static final String SANS_DELIMITER = ":";
private final CsrConfiguration configuration;
@@ -65,13 +65,14 @@ public class CsrFactory {
public String createCsrInPem(KeyPair keyPair) throws CsrGenerationException {
- PKCS10CertificationRequest request;
+ LOGGER.info("Creation of CSR has been started with following parameters: {}", configuration.toString());
String csrParameters = getMandatoryParameters().append(getOptionalParameters()).toString();
X500Principal subject = new X500Principal(csrParameters);
- request = createPKCS10Csr(subject, keyPair);
- return convertPKC10CsrToPem(request);
- }
+ 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",
@@ -114,9 +115,10 @@ public class CsrFactory {
return contentSigner;
}
- private String convertPKC10CsrToPem(PKCS10CertificationRequest request) throws CsrGenerationException {
+ 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());
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 5d56f08c..988d37d8 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
@@ -39,6 +39,7 @@ public class KeyPairFactory {
public KeyPair create() throws KeyPairGenerationException {
try {
+ LOGGER.info("KeyPair generation started with algorithm: {} and key size: {}", encryptionAlgorithm, keySize);
return createKeyPairGenerator().generateKeyPair();
} catch (NoSuchAlgorithmException e) {
LOGGER.error("Generation of KeyPair failed, exception message: {}" , e.getMessage());
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 4e88a805..7391b119 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
@@ -34,11 +34,11 @@ import org.slf4j.LoggerFactory;
public class PrivateKeyToPemEncoder {
- public static final String PEM_OBJECT_TYPE = "RSA PRIVATE KEY";
- private final Logger LOGGER = LoggerFactory.getLogger(PrivateKeyToPemEncoder.class);
+ 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("Encoding PrivateKey to PEM");
+ 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()));
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java
index 8e6fb89c..9b0cfb78 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PKCS12FilesCreator.java
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
class PKCS12FilesCreator {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PKCS12FilesCreator.class);
private static final String KEYSTORE_JKS = "keystore.jks";
private static final String KEYSTORE_PASS = "keystore.pass";
private static final String TRUSTSTORE_JKS = "truststore.jks";
@@ -37,7 +38,6 @@ class PKCS12FilesCreator {
private final String keystorePassPath;
private final String truststoreJksPath;
private final String truststorePassPath;
- private final Logger LOGGER = LoggerFactory.getLogger(PKCS12FilesCreator.class);
PKCS12FilesCreator(String path) {
@@ -48,7 +48,7 @@ class PKCS12FilesCreator {
}
void saveKeystoreData(byte[] keystoreData, String keystorePassword) throws PemToPKCS12ConverterException {
- LOGGER.debug("Creating PKCS12 keystore files and saving data. Keystore path: {}", keystoreJksPath);
+ LOGGER.debug("Attempt to create PKCS12 keystore files and saving data. Keystore path: {}", keystoreJksPath);
saveDataToLocation(keystoreData, keystoreJksPath);
saveDataToLocation(keystorePassword.getBytes(), keystorePassPath);
@@ -56,7 +56,7 @@ class PKCS12FilesCreator {
void saveTruststoreData(byte[] truststoreData, String truststorePassword)
throws PemToPKCS12ConverterException {
- LOGGER.debug("Creating PKCS12 truststore files and saving data. Truststore path: {}", truststoreJksPath);
+ LOGGER.debug("Attempt to create PKCS12 truststore files and saving data. Truststore path: {}", truststoreJksPath);
saveDataToLocation(truststoreData, truststoreJksPath);
saveDataToLocation(truststorePassword.getBytes(), truststorePassPath);
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemToPKCS12Converter.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemToPKCS12Converter.java
index 8c794e72..ef1666dc 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemToPKCS12Converter.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/PemToPKCS12Converter.java
@@ -41,20 +41,20 @@ import org.slf4j.LoggerFactory;
class PemToPKCS12Converter {
- private final static String PKCS12 = "PKCS12";
- private final static 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 Logger LOGGER = LoggerFactory.getLogger(PemToPKCS12Converter.class);
+ private static final String PKCS12 = "PKCS12";
+ 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 final Logger LOGGER = LoggerFactory.getLogger(PemToPKCS12Converter.class);
byte[] convertKeystore(List<String> certificateChain, Password password, String alias, PrivateKey privateKey)
throws PemToPKCS12ConverterException {
- LOGGER.debug("Converting PEM certificates to PKCS12 keystore.");
+ LOGGER.info("Conversion of PEM certificates to PKCS12 keystore");
return convert(certificateChain, password, certs -> getKeyStore(alias, password, certs, privateKey));
}
byte[] convertTruststore(List<String> trustAnchors, Password password, String alias)
throws PemToPKCS12ConverterException {
- LOGGER.debug("Converting PEM certificates to PKCS12 truststore.");
+ LOGGER.info("Conversion of PEM certificates to PKCS12 truststore");
return convert(trustAnchors, password, certs -> getTrustStore(alias, certs));
}
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
index 26a2b1b1..a03ded6c 100644
--- 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
@@ -24,9 +24,12 @@ 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;
public class ClientConfigurationFactory extends AbstractConfigurationFactory<ClientConfiguration> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ClientConfigurationFactory.class);
private final EnvsForClient envsForClient;
public ClientConfigurationFactory(EnvsForClient envsForClient) {
@@ -54,6 +57,8 @@ public class ClientConfigurationFactory extends AbstractConfigurationFactory<Cli
.map(configuration::setCaName)
.orElseThrow(() -> new ClientConfigurationException(ClientConfigurationEnvs.CA_NAME + " 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
index a6e86187..a94c906f 100644
--- 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
@@ -24,9 +24,12 @@ 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;
@@ -67,6 +70,8 @@ public class CsrConfigurationFactory extends AbstractConfigurationFactory<CsrCon
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/model/ClientConfiguration.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java
index d1c1c685..ff2db831 100644
--- 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
@@ -20,6 +20,8 @@
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;
@@ -72,4 +74,13 @@ public class ClientConfiguration implements ConfigurationModel {
this.caName = caName;
return this;
}
+
+ @Override
+ public String toString() {
+ return String.format("%s: %s, %s: %s, %s: %s, %s: %s",
+ ClientConfigurationEnvs.REQUEST_URL, urlToCertService,
+ ClientConfigurationEnvs.REQUEST_TIMEOUT, requestTimeout,
+ ClientConfigurationEnvs.OUTPUT_PATH, certsOutputPath,
+ ClientConfigurationEnvs.CA_NAME, caName);
+ }
}
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
index aaaf10fa..55f33c9f 100644
--- 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
@@ -21,6 +21,8 @@
package org.onap.aaf.certservice.client.configuration.model;
+import org.onap.aaf.certservice.client.configuration.CsrConfigurationEnvs;
+
public class CsrConfiguration implements ConfigurationModel {
private String commonName;
@@ -94,4 +96,16 @@ public class CsrConfiguration implements ConfigurationModel {
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/HttpClient.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java
index 0cb88051..7512830d 100644
--- 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
@@ -38,12 +38,11 @@ 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 Logger LOGGER = LoggerFactory.getLogger(HttpClient.class);
-
private final Gson gson = new Gson();
private final CloseableHttpClientProvider httpClientProvider;
private final String certServiceAddress;
@@ -57,7 +56,7 @@ public class HttpClient {
throws CertServiceApiResponseException, HttpClientException {
try (CloseableHttpClient httpClient = httpClientProvider.getClient()) {
- LOGGER.info("Sending request to API. Url: {}{} ", certServiceAddress, caName);
+ 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);