Search in sources :

Example 1 with CsrEnrollCertRequest

use of org.xipki.ca.client.api.dto.CsrEnrollCertRequest in project xipki by xipki.

the class CaClientImpl method requestCert.

@Override
public EnrollCertResult requestCert(String caName, CertificationRequest csr, String profile, Date notBefore, Date notAfter, RequestResponseDebug debug) throws CaClientException, PkiErrorException {
    ParamUtil.requireNonNull("csr", csr);
    if (caName == null) {
        caName = getCaNameForProfile(profile);
    } else {
        caName = caName.toLowerCase();
    }
    if (caName == null) {
        throw new CaClientException("certprofile " + profile + " is not supported by any CA");
    }
    CaConf ca = casMap.get(caName);
    if (ca == null) {
        throw new CaClientException("could not find CA named " + caName);
    }
    final String id = "cert-1";
    CsrEnrollCertRequest request = new CsrEnrollCertRequest(id, profile, csr);
    EnrollCertResultResp result;
    try {
        result = ca.getRequestor().requestCertificate(request, notBefore, notAfter, debug);
    } catch (CmpRequestorException ex) {
        throw new CaClientException(ex.getMessage(), ex);
    }
    return parseEnrollCertResult(result);
}
Also used : CsrEnrollCertRequest(org.xipki.ca.client.api.dto.CsrEnrollCertRequest) EnrollCertResultResp(org.xipki.ca.client.api.dto.EnrollCertResultResp) CaClientException(org.xipki.ca.client.api.CaClientException)

Aggregations

CaClientException (org.xipki.ca.client.api.CaClientException)1 CsrEnrollCertRequest (org.xipki.ca.client.api.dto.CsrEnrollCertRequest)1 EnrollCertResultResp (org.xipki.ca.client.api.dto.EnrollCertResultResp)1