Search in sources :

Example 6 with CertIdOrError

use of org.xipki.ca.client.api.CertIdOrError in project xipki by xipki.

the class CaClientImpl method parseRevokeCertResult.

private Map<String, CertIdOrError> parseRevokeCertResult(RevokeCertResultType result) throws CaClientException {
    Map<String, CertIdOrError> ret = new HashMap<>();
    for (ResultEntry re : result.getResultEntries()) {
        CertIdOrError certIdOrError;
        if (re instanceof RevokeCertResultEntry) {
            RevokeCertResultEntry entry = (RevokeCertResultEntry) re;
            certIdOrError = new CertIdOrError(entry.getCertId());
        } else if (re instanceof ErrorResultEntry) {
            ErrorResultEntry entry = (ErrorResultEntry) re;
            certIdOrError = new CertIdOrError(entry.getStatusInfo());
        } else {
            throw new CaClientException("unknown type " + re.getClass().getName());
        }
        ret.put(re.getId(), certIdOrError);
    }
    return ret;
}
Also used : ErrorResultEntry(org.xipki.ca.client.api.dto.ErrorResultEntry) RevokeCertResultEntry(org.xipki.ca.client.api.dto.RevokeCertResultEntry) ResultEntry(org.xipki.ca.client.api.dto.ResultEntry) EnrollCertResultEntry(org.xipki.ca.client.api.dto.EnrollCertResultEntry) RevokeCertResultEntry(org.xipki.ca.client.api.dto.RevokeCertResultEntry) HashMap(java.util.HashMap) ErrorResultEntry(org.xipki.ca.client.api.dto.ErrorResultEntry) CertIdOrError(org.xipki.ca.client.api.CertIdOrError) CaClientException(org.xipki.ca.client.api.CaClientException)

Example 7 with CertIdOrError

use of org.xipki.ca.client.api.CertIdOrError in project xipki by xipki.

the class CaClientImpl method removeCert.

private CertIdOrError removeCert(CaConf ca, BigInteger serial, RequestResponseDebug debug) throws CaClientException, PkiErrorException {
    ParamUtil.requireNonNull("ca", ca);
    ParamUtil.requireNonNull("serial", serial);
    final String id = "cert-1";
    UnrevokeOrRemoveCertEntry entry = new UnrevokeOrRemoveCertEntry(id, ca.getSubject(), serial);
    if (ca.getCmpControl().isRrAkiRequired()) {
        entry.setAuthorityKeyIdentifier(ca.getSubjectKeyIdentifier());
    }
    UnrevokeOrRemoveCertRequest request = new UnrevokeOrRemoveCertRequest();
    request.addRequestEntry(entry);
    Map<String, CertIdOrError> result = removeCerts(request, debug);
    return (result == null) ? null : result.get(id);
}
Also used : UnrevokeOrRemoveCertRequest(org.xipki.ca.client.api.dto.UnrevokeOrRemoveCertRequest) CertIdOrError(org.xipki.ca.client.api.CertIdOrError) UnrevokeOrRemoveCertEntry(org.xipki.ca.client.api.dto.UnrevokeOrRemoveCertEntry)

Aggregations

CertIdOrError (org.xipki.ca.client.api.CertIdOrError)7 X509Certificate (java.security.cert.X509Certificate)3 PkiStatusInfo (org.xipki.cmp.PkiStatusInfo)3 RequestResponseDebug (org.xipki.common.RequestResponseDebug)3 CmdFailure (org.xipki.console.karaf.CmdFailure)3 IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)3 UnrevokeOrRemoveCertEntry (org.xipki.ca.client.api.dto.UnrevokeOrRemoveCertEntry)2 UnrevokeOrRemoveCertRequest (org.xipki.ca.client.api.dto.UnrevokeOrRemoveCertRequest)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 CaClientException (org.xipki.ca.client.api.CaClientException)1 EnrollCertResultEntry (org.xipki.ca.client.api.dto.EnrollCertResultEntry)1 ErrorResultEntry (org.xipki.ca.client.api.dto.ErrorResultEntry)1 ResultEntry (org.xipki.ca.client.api.dto.ResultEntry)1 RevokeCertRequest (org.xipki.ca.client.api.dto.RevokeCertRequest)1 RevokeCertRequestEntry (org.xipki.ca.client.api.dto.RevokeCertRequestEntry)1 RevokeCertResultEntry (org.xipki.ca.client.api.dto.RevokeCertResultEntry)1 CrlReason (org.xipki.security.CrlReason)1