summaryrefslogtreecommitdiffstats
path: root/certService/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'certService/src/main/java')
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/api/CertificationService.java31
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CertificationData.java127
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java51
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java4
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java6
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/CsrDecryptionException.java2
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/DecryptionException.java27
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/PemDecryptionException.java28
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/model/CertificationModel.java44
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/model/ErrorResponseModel.java36
10 files changed, 346 insertions, 10 deletions
diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/CertificationService.java b/certService/src/main/java/org/onap/aaf/certservice/api/CertificationService.java
index a46e07fc..75fc0f52 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/api/CertificationService.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/api/CertificationService.java
@@ -20,10 +20,15 @@
package org.onap.aaf.certservice.api;
+import com.google.gson.Gson;
+import org.onap.aaf.certservice.certification.CertificationModelFactory;
import org.onap.aaf.certservice.certification.CsrModelFactory;
import org.onap.aaf.certservice.certification.CsrModelFactory.StringBase64;
import org.onap.aaf.certservice.certification.exceptions.CsrDecryptionException;
+import org.onap.aaf.certservice.certification.exceptions.PemDecryptionException;
+import org.onap.aaf.certservice.certification.model.CertificationModel;
import org.onap.aaf.certservice.certification.model.CsrModel;
+import org.onap.aaf.certservice.certification.model.ErrorResponseModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,10 +46,12 @@ public class CertificationService {
private static final Logger LOGGER = LoggerFactory.getLogger(CertificationService.class);
private final CsrModelFactory csrModelFactory;
+ private final CertificationModelFactory certificationModelFactory;
@Autowired
- CertificationService(CsrModelFactory csrModelFactory) {
+ CertificationService(CsrModelFactory csrModelFactory, CertificationModelFactory certificationModelFactory) {
this.csrModelFactory = csrModelFactory;
+ this.certificationModelFactory = certificationModelFactory;
}
/**
@@ -56,7 +63,7 @@ public class CertificationService {
* @param encodedPrivateKey Private key for CSR, needed for PoP, encoded in Base64 form
* @return JSON containing trusted certificates and certificate chain
*/
- @GetMapping("v1/certificate/{caName}")
+ @GetMapping(value = "v1/certificate/{caName}", produces = "application/json; charset=utf-8")
public ResponseEntity<String> signCertificate(
@PathVariable String caName,
@RequestHeader("CSR") String encodedCsr,
@@ -71,12 +78,26 @@ public class CertificationService {
new StringBase64(encodedPrivateKey)
);
LOGGER.debug("Received CSR meta data: \n{}", csrModel);
- return new ResponseEntity<>(csrModel.toString(), HttpStatus.OK);
+ CertificationModel certificationModel = certificationModelFactory
+ .createCertificationModel(csrModel,caName);
+ return new ResponseEntity<>(
+ new Gson().toJson(certificationModel),
+ HttpStatus.OK);
} catch (CsrDecryptionException e) {
- LOGGER.error("Exception occurred during certificate signing:", e);
- return new ResponseEntity<>("Wrong certificate signing request (CSR) format", HttpStatus.BAD_REQUEST);
+ LOGGER.error("Exception occurred during decoding certificate sign request:", e);
+ return getErrorResponseEntity("Wrong certificate signing request (CSR) format");
+ } catch (PemDecryptionException e) {
+ LOGGER.error("Exception occurred during decoding key:", e);
+ return getErrorResponseEntity("Wrong key (PK) format");
}
}
+ private ResponseEntity<String> getErrorResponseEntity(String errorMessage) {
+ ErrorResponseModel errorResponse = new ErrorResponseModel(errorMessage);
+ return new ResponseEntity<>(
+ new Gson().toJson(errorResponse),
+ HttpStatus.BAD_REQUEST);
+ }
+
}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationData.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationData.java
new file mode 100644
index 00000000..a347762e
--- /dev/null
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationData.java
@@ -0,0 +1,127 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaf.certservice.certification;
+
+
+final class CertificationData {
+
+ private CertificationData() {}
+
+ private static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n";
+ private static final String END_CERTIFICATE = "-----END CERTIFICATE-----";
+
+ static final String EXTRA_CA_CERT = ""
+ + BEGIN_CERTIFICATE
+ + "MIIDvzCCAqcCFF5DejiyfoNfPiiMmBXulniBewBGMA0GCSqGSIb3DQEBCwUAMIGb\n"
+ + "MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2Fu\n"
+ + "LUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwE\n"
+ + "T05BUDEVMBMGA1UEAwwMbmV3Lm9uYXAub3JnMR4wHAYJKoZIhvcNAQkBFg90ZXN0\n"
+ + "ZXJAb25hcC5vcmcwHhcNMjAwMjEyMDk1OTM3WhcNMjEwMjExMDk1OTM3WjCBmzEL\n"
+ + "MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbi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olhCHoLFj6w1IkG88UCmbwN\n"
+ + "d7BoGMy06y5MJxyXEZG0vR7eNeLey0TIh+rAszAFPsIQvrOHW+HuA+WLQAj1mhnm\n"
+ + END_CERTIFICATE;
+
+}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java
new file mode 100644
index 00000000..1b10c379
--- /dev/null
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/CertificationModelFactory.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaf.certservice.certification;
+
+import org.onap.aaf.certservice.certification.model.CertificationModel;
+import org.onap.aaf.certservice.certification.model.CsrModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+
+import static org.onap.aaf.certservice.certification.CertificationData.CA_CERT;
+import static org.onap.aaf.certservice.certification.CertificationData.ENTITY_CERT;
+import static org.onap.aaf.certservice.certification.CertificationData.INTERMEDIATE_CERT;
+import static org.onap.aaf.certservice.certification.CertificationData.EXTRA_CA_CERT;
+
+@Service
+public class CertificationModelFactory {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CertificationModelFactory.class);
+
+
+ public CertificationModel createCertificationModel(CsrModel csr, String caName) {
+ LOGGER.info("Generating certificates for CA named: {}, and certificate signing request:\n{}",
+ caName, csr);
+ return new CertificationModel(
+ Arrays.asList(ENTITY_CERT, INTERMEDIATE_CERT),
+ Arrays.asList(CA_CERT, EXTRA_CA_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 98daa6eb..c1262e1e 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
@@ -26,6 +26,7 @@ import java.util.Base64;
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
import org.bouncycastle.util.io.pem.PemObject;
import org.onap.aaf.certservice.certification.exceptions.CsrDecryptionException;
+import org.onap.aaf.certservice.certification.exceptions.PemDecryptionException;
import org.onap.aaf.certservice.certification.model.CsrModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,7 +39,8 @@ public class CsrModelFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(CsrModelFactory.class);
private final PemObjectFactory pemObjectFactory = new PemObjectFactory();
- public CsrModel createCsrModel(StringBase64 csr, StringBase64 privateKey) throws CsrDecryptionException {
+ public CsrModel createCsrModel(StringBase64 csr, StringBase64 privateKey)
+ throws CsrDecryptionException, PemDecryptionException {
LOGGER.debug("Decoded CSR: \n{}", csr);
try {
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 08ffc56d..61ea0aaf 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
@@ -26,18 +26,18 @@ import java.io.StringReader;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemReader;
-import org.onap.aaf.certservice.certification.exceptions.CsrDecryptionException;
+import org.onap.aaf.certservice.certification.exceptions.PemDecryptionException;
public class PemObjectFactory {
- public PemObject createPemObject(String pem) throws CsrDecryptionException {
+ public PemObject createPemObject(String pem) throws PemDecryptionException {
try (StringReader stringReader = new StringReader(pem);
PemReader pemReader = new PemReader(stringReader)) {
return pemReader.readPemObject();
} catch (IOException e) {
- throw new CsrDecryptionException("Unable to create PEM", e);
+ throw new PemDecryptionException("Unable to create PEM", e);
}
}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/CsrDecryptionException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/CsrDecryptionException.java
index fb16ad91..2f3f3659 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/CsrDecryptionException.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/CsrDecryptionException.java
@@ -20,7 +20,7 @@
package org.onap.aaf.certservice.certification.exceptions;
-public class CsrDecryptionException extends Exception {
+public class CsrDecryptionException extends DecryptionException {
public CsrDecryptionException(String message, Throwable cause) {
super(message, cause);
}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/DecryptionException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/DecryptionException.java
new file mode 100644
index 00000000..67249cd5
--- /dev/null
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/DecryptionException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaf.certservice.certification.exceptions;
+
+public class DecryptionException extends Exception {
+ public DecryptionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/PemDecryptionException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/PemDecryptionException.java
new file mode 100644
index 00000000..564660e5
--- /dev/null
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/exceptions/PemDecryptionException.java
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaf.certservice.certification.exceptions;
+
+public class PemDecryptionException extends DecryptionException {
+ public PemDecryptionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/model/CertificationModel.java b/certService/src/main/java/org/onap/aaf/certservice/certification/model/CertificationModel.java
new file mode 100644
index 00000000..b851d0d9
--- /dev/null
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/model/CertificationModel.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaf.certservice.certification.model;
+
+import java.util.Collections;
+import java.util.List;
+
+public class CertificationModel {
+
+ private final List<String> certificateChain;
+ private final List<String> trustedCertificates;
+
+ public CertificationModel(List<String> certificateChain, List<String> trustedCertificates) {
+ this.certificateChain = certificateChain;
+ this.trustedCertificates = trustedCertificates;
+ }
+
+ public List<String> getCertificateChain() {
+ return Collections.unmodifiableList(certificateChain);
+ }
+
+ public List<String> getTrustedCertificates() {
+ return Collections.unmodifiableList(trustedCertificates);
+ }
+
+}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/model/ErrorResponseModel.java b/certService/src/main/java/org/onap/aaf/certservice/certification/model/ErrorResponseModel.java
new file mode 100644
index 00000000..bca7915d
--- /dev/null
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/model/ErrorResponseModel.java
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaf.certservice.certification.model;
+
+public class ErrorResponseModel {
+
+ private final String errorMessage;
+
+ public ErrorResponseModel(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+}
+