aboutsummaryrefslogtreecommitdiffstats
path: root/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java
diff options
context:
space:
mode:
authorMichal Banka <michal.banka@nokia.com>2020-03-18 12:40:13 +0100
committerMichał Bańka <michal.banka@nokia.com>2020-03-20 12:33:21 +0000
commit5be846ddf01abf99ca1d15ec6ad0f3c53354272f (patch)
tree29948cad6b116a04cb7fa28a5e2de49251a64000 /certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java
parent4b65b3c32da416ebfecb7eac808d76d89ae4b2a8 (diff)
Removed unused parameters when creating certificate
Signed-off-by: Michal Banka <michal.banka@nokia.com> Change-Id: I72d9e3ea30d3c2ba8e4e6c7e5afa0cfad2508bc5 Issue-ID: AAF-1107
Diffstat (limited to 'certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java')
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java30
1 files changed, 10 insertions, 20 deletions
diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java
index 79656e91..08c43031 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/impl/CmpClientImpl.java
@@ -48,6 +48,7 @@ import org.bouncycastle.asn1.cmp.PKIBody;
import org.bouncycastle.asn1.cmp.PKIHeader;
import org.bouncycastle.asn1.cmp.PKIMessage;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
+import org.onap.aaf.certservice.certification.configuration.model.CaMode;
import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
import org.onap.aaf.certservice.certification.model.CsrModel;
import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
@@ -64,7 +65,6 @@ public class CmpClientImpl implements CmpClient {
private static final Logger LOG = LoggerFactory.getLogger(CmpClientImpl.class);
private final CloseableHttpClient httpClient;
- private static final String DEFAULT_PROFILE = "RA";
private static final String DEFAULT_CA_NAME = "Certification Authority";
public CmpClientImpl(CloseableHttpClient httpClient) {
@@ -73,16 +73,13 @@ public class CmpClientImpl implements CmpClient {
@Override
public List<List<X509Certificate>> createCertificate(
- String caName,
- String profile,
CsrModel csrModel,
Cmpv2Server server,
- X509Certificate cert,
Date notBefore,
Date notAfter)
throws CmpClientException {
- validate(csrModel, server, cert, caName, profile, httpClient, notBefore, notAfter);
+ validate(csrModel, server, httpClient, notBefore, notAfter);
KeyPair keyPair = new KeyPair(csrModel.getPublicKey(), csrModel.getPrivateKey());
final CreateCertRequest certRequest =
@@ -99,14 +96,13 @@ public class CmpClientImpl implements CmpClient {
final PKIMessage pkiMessage = certRequest.generateCertReq();
Cmpv2HttpClient cmpv2HttpClient = new Cmpv2HttpClient(httpClient);
- return retrieveCertificates(caName, csrModel, server, pkiMessage, cmpv2HttpClient);
+ return retrieveCertificates(csrModel, server, pkiMessage, cmpv2HttpClient);
}
@Override
- public List<List<X509Certificate>> createCertificate(
- String caName, String profile, CsrModel csrModel, Cmpv2Server server, X509Certificate csr)
+ public List<List<X509Certificate>> createCertificate(CsrModel csrModel, Cmpv2Server server)
throws CmpClientException {
- return createCertificate(caName, profile, csrModel, server, csr, null, null);
+ return createCertificate(csrModel, server, null, null);
}
private void checkCmpResponse(
@@ -197,23 +193,18 @@ public class CmpClientImpl implements CmpClient {
*
* @param csrModel Certificate Signing Request model. Must not be {@code null}.
* @param server CMPv2 Server. Must not be {@code null}.
- * @param cert Certificate object needed to validate response from CA server.
- * @param incomingCaName Date specifying certificate is not valid before this date.
- * @param incomingProfile Date specifying certificate is not valid after this date.
* @throws IllegalArgumentException if Before Date is set after the After Date.
*/
private static void validate(
final CsrModel csrModel,
final Cmpv2Server server,
- final X509Certificate cert,
- final String incomingCaName,
- final String incomingProfile,
final CloseableHttpClient httpClient,
final Date notBefore,
final Date notAfter) {
- String caName = CmpUtil.isNullOrEmpty(incomingCaName) ? incomingCaName : DEFAULT_CA_NAME;
- String caProfile = CmpUtil.isNullOrEmpty(incomingProfile) ? incomingProfile : DEFAULT_PROFILE;
+
+ String caName = CmpUtil.isNullOrEmpty(server.getCaName()) ? server.getCaName() : DEFAULT_CA_NAME;
+ String caProfile = server.getCaMode() != null ? String.valueOf(server.getCaMode()) : String.valueOf(CaMode.RA);
LOG.info(
"Validate before creating Certificate Request for CA :{} in Mode {} ", caName, caProfile);
@@ -224,7 +215,6 @@ public class CmpClientImpl implements CmpClient {
CmpUtil.notNull(server.getIssuerDN(), "Issuer DN");
CmpUtil.notNull(server.getUrl(), "External CA URL");
CmpUtil.notNull(server.getAuthentication().getIak(), "IAK/RV Password");
- CmpUtil.notNull(cert, "Certificate Signing Request (CSR)");
CmpUtil.notNull(httpClient, "Closeable Http Client");
if (notBefore != null && notAfter != null && notBefore.compareTo(notAfter) > 0) {
@@ -233,9 +223,9 @@ public class CmpClientImpl implements CmpClient {
}
private List<List<X509Certificate>> retrieveCertificates(
- String caName, CsrModel csrModel, Cmpv2Server server, PKIMessage pkiMessage, Cmpv2HttpClient cmpv2HttpClient)
+ CsrModel csrModel, Cmpv2Server server, PKIMessage pkiMessage, Cmpv2HttpClient cmpv2HttpClient)
throws CmpClientException {
- final byte[] respBytes = cmpv2HttpClient.postRequest(pkiMessage, server.getUrl(), caName);
+ final byte[] respBytes = cmpv2HttpClient.postRequest(pkiMessage, server.getUrl(), server.getCaName());
try {
final PKIMessage respPkiMessage = PKIMessage.getInstance(respBytes);
LOG.info("Received response from Server");