summaryrefslogtreecommitdiffstats
path: root/certService/src/main/java
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2020-02-16 12:56:55 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-16 12:56:55 +0000
commitbd10fbac3f2369faa7ea83d2f9800b0dbc96933d (patch)
tree64389747ed07bf5669371b8a5e52a93230371f32 /certService/src/main/java
parent8209f7c8dc47546a354978e36b96d3b80b5b55d9 (diff)
parent1a82cc89e4846e60842cad12516ccf3544fb2051 (diff)
Merge "Add more logs and handling DecoderException"
Diffstat (limited to 'certService/src/main/java')
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java2
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java8
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/PKCS10CertificationRequestFactory.java9
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java9
4 files changed, 24 insertions, 4 deletions
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java
index 1b10c379..507ce3c1 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java
@@ -40,7 +40,7 @@ public class CertificationModelFactory {
public CertificationModel createCertificationModel(CsrModel csr, String caName) {
- LOGGER.info("Generating certificates for CA named: {}, and certificate signing request:\n{}",
+ LOGGER.info("Generating certification model for CA named: {}, and certificate signing request:\n{}",
caName, csr);
return new CertificationModel(
Arrays.asList(ENTITY_CERT, INTERMEDIATE_CERT),
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java
index 4abf4d04..f89c34e5 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java
@@ -29,6 +29,8 @@ import org.onap.aaf.certservice.certification.exceptions.CsrDecryptionException;
import org.onap.aaf.certservice.certification.exceptions.DecryptionException;
import org.onap.aaf.certservice.certification.exceptions.KeyDecryptionException;
import org.onap.aaf.certservice.certification.model.CsrModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -71,6 +73,7 @@ public class CsrModelFactory {
public static class StringBase64 {
private final String value;
private final Base64.Decoder decoder = Base64.getDecoder();
+ private static final Logger LOGGER = LoggerFactory.getLogger(StringBase64.class);
public StringBase64(String value) {
this.value = value;
@@ -78,8 +81,11 @@ public class CsrModelFactory {
public Optional<String> asString() {
try {
- return Optional.of(new String(decoder.decode(value)));
+ String decodedString = new String(decoder.decode(value));
+ LOGGER.debug("Decoded string: {}", decodedString);
+ return Optional.of(decodedString);
} catch(RuntimeException e) {
+ LOGGER.error("Exception occurred during decoding:", e);
return Optional.empty();
}
}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/PKCS10CertificationRequestFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/PKCS10CertificationRequestFactory.java
index 8f89de2f..b255b7c2 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/PKCS10CertificationRequestFactory.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/PKCS10CertificationRequestFactory.java
@@ -21,17 +21,24 @@
package org.onap.aaf.certservice.certification;
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
+import org.bouncycastle.util.encoders.DecoderException;
import org.bouncycastle.util.io.pem.PemObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Optional;
public class PKCS10CertificationRequestFactory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PKCS10CertificationRequestFactory.class);
+
public Optional<PKCS10CertificationRequest> createKCS10CertificationRequest(PemObject pemObject) {
try {
+ LOGGER.debug("Creating certification request from pem object");
return Optional.of(new PKCS10CertificationRequest(pemObject.getContent()));
- } catch (IOException e) {
+ } catch (DecoderException | IOException e) {
+ LOGGER.error("Exception occurred during creation of certification request:", e);
return Optional.empty();
}
}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java
index 514101b9..c2293d2d 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java
@@ -24,18 +24,25 @@ import java.io.IOException;
import java.io.StringReader;
import java.util.Optional;
+import org.bouncycastle.util.encoders.DecoderException;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PemObjectFactory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PemObjectFactory.class);
+
public Optional<PemObject> createPemObject(String pem) {
try (StringReader stringReader = new StringReader(pem);
PemReader pemReader = new PemReader(stringReader)) {
+ LOGGER.debug("Creating pem object from: {}", pem);
return Optional.ofNullable(pemReader.readPemObject());
- } catch (IOException e) {
+ } catch (DecoderException | IOException e) {
+ LOGGER.error("Exception occurred during creation of PEM:", e);
return Optional.empty();
}
}