cccb744d598ae852ea7cf999b8b5cd6892249dbb
[oom/platform/cert-service.git] / certService / src / main / java / org / onap / aaf / certservice / cmpv2client / api / CmpClient.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.aaf.certservice.cmpv2client.api;
22
23 import java.util.Date;
24
25 import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
26 import org.onap.aaf.certservice.certification.model.CsrModel;
27 import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException;
28 import org.onap.aaf.certservice.cmpv2client.model.Cmpv2CertificationModel;
29
30 /**
31  * This class represent CmpV2Client Interface for obtaining X.509 Digital Certificates in a Public
32  * Key Infrastructure (PKI), making use of Certificate Management Protocol (CMPv2) operating on
33  * newest version: cmp2000(2).
34  */
35 public interface CmpClient {
36
37   /**
38    * Requests for a External Root CA Certificate to be created for the passed public keyPair wrapped
39    * in a CSRMeta with common details, accepts self-signed certificate. Basic Authentication using
40    * IAK/RV, Verification of the signature (proof-of-possession) on the request is performed and an
41    * Exception thrown if verification fails or issue encountered in fetching certificate from CA.
42    *
43    * @param csrModel  Certificate Signing Request model. Must not be {@code null}.
44    * @param server    CMPv2 Server. Must not be {@code null}.
45    * @param notBefore An optional validity to set in the created certificate, Certificate not valid
46    *                  before this date.
47    * @param notAfter  An optional validity to set in the created certificate, Certificate not valid
48    *                  after this date.
49    * @return model for certification containing certificate chain and trusted certificates
50    * @throws CmpClientException if client error occurs.
51    */
52   Cmpv2CertificationModel createCertificate(
53       CsrModel csrModel,
54       Cmpv2Server server,
55       Date notBefore,
56       Date notAfter)
57       throws CmpClientException;
58
59   /**
60    * Requests for a External Root CA Certificate to be created for the passed public keyPair wrapped
61    * in a CSRMeta with common details, accepts self-signed certificate. Basic Authentication using
62    * IAK/RV, Verification of the signature (proof-of-possession) on the request is performed and an
63    * Exception thrown if verification fails or issue encountered in fetching certificate from CA.
64    *
65    * @param csrModel  Certificate Signing Request Model. Must not be {@code null}.
66    * @param server    CMPv2 server. Must not be {@code null}.
67    * @return model for certification containing certificate chain and trusted certificates
68    * @throws CmpClientException if client error occurs.
69    */
70   Cmpv2CertificationModel createCertificate(
71       CsrModel csrModel,
72       Cmpv2Server server)
73       throws CmpClientException;
74 }