Search in sources :

Example 1 with PkiStatusInfo

use of org.xipki.cmp.PkiStatusInfo in project xipki by xipki.

the class RevokeCertCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (!(certFile == null ^ getSerialNumber() == null)) {
        throw new IllegalCmdParamException("exactly one of cert and serial must be specified");
    }
    CrlReason crlReason = CrlReason.forNameOrText(reason);
    if (!CrlReason.PERMITTED_CLIENT_CRLREASONS.contains(crlReason)) {
        throw new IllegalCmdParamException("reason " + reason + " is not permitted");
    }
    CertIdOrError certIdOrError;
    Date invalidityDate = null;
    if (isNotBlank(invalidityDateS)) {
        invalidityDate = DateUtil.parseUtcTimeyyyyMMddhhmmss(invalidityDateS);
    }
    if (certFile != null) {
        X509Certificate cert = X509Util.parseCert(certFile);
        RequestResponseDebug debug = getRequestResponseDebug();
        try {
            certIdOrError = caClient.revokeCert(caName, cert, crlReason.getCode(), invalidityDate, debug);
        } finally {
            saveRequestResponse(debug);
        }
    } else {
        RequestResponseDebug debug = getRequestResponseDebug();
        try {
            certIdOrError = caClient.revokeCert(caName, getSerialNumber(), crlReason.getCode(), invalidityDate, debug);
        } finally {
            saveRequestResponse(debug);
        }
    }
    if (certIdOrError.getError() != null) {
        PkiStatusInfo error = certIdOrError.getError();
        throw new CmdFailure("revocation failed: " + error);
    } else {
        println("revoked certificate");
    }
    return null;
}
Also used : RequestResponseDebug(org.xipki.common.RequestResponseDebug) CmdFailure(org.xipki.console.karaf.CmdFailure) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) CertIdOrError(org.xipki.ca.client.api.CertIdOrError) PkiStatusInfo(org.xipki.cmp.PkiStatusInfo) CrlReason(org.xipki.security.CrlReason) Date(java.util.Date) X509Certificate(java.security.cert.X509Certificate)

Example 2 with PkiStatusInfo

use of org.xipki.cmp.PkiStatusInfo in project xipki by xipki.

the class RemoveCertCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (!(certFile == null ^ getSerialNumber() == null)) {
        throw new IllegalCmdParamException("exactly one of cert and serial must be specified");
    }
    CertIdOrError certIdOrError;
    if (certFile != null) {
        X509Certificate cert = X509Util.parseCert(certFile);
        RequestResponseDebug debug = getRequestResponseDebug();
        try {
            certIdOrError = caClient.removeCert(caName, cert, debug);
        } finally {
            saveRequestResponse(debug);
        }
    } else {
        RequestResponseDebug debug = getRequestResponseDebug();
        try {
            certIdOrError = caClient.removeCert(caName, getSerialNumber(), debug);
        } finally {
            saveRequestResponse(debug);
        }
    }
    if (certIdOrError.getError() != null) {
        PkiStatusInfo error = certIdOrError.getError();
        throw new CmdFailure("removing certificate failed: " + error);
    } else {
        println("removed certificate");
    }
    return null;
}
Also used : RequestResponseDebug(org.xipki.common.RequestResponseDebug) CmdFailure(org.xipki.console.karaf.CmdFailure) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) CertIdOrError(org.xipki.ca.client.api.CertIdOrError) PkiStatusInfo(org.xipki.cmp.PkiStatusInfo) X509Certificate(java.security.cert.X509Certificate)

Example 3 with PkiStatusInfo

use of org.xipki.cmp.PkiStatusInfo in project xipki by xipki.

the class UnrevokeCertCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (!(certFile == null ^ getSerialNumber() == null)) {
        throw new IllegalCmdParamException("exactly one of cert and serial must be specified");
    }
    CertIdOrError certIdOrError;
    if (certFile != null) {
        X509Certificate cert = X509Util.parseCert(certFile);
        RequestResponseDebug debug = getRequestResponseDebug();
        try {
            certIdOrError = caClient.unrevokeCert(caName, cert, debug);
        } finally {
            saveRequestResponse(debug);
        }
    } else {
        RequestResponseDebug debug = getRequestResponseDebug();
        try {
            certIdOrError = caClient.unrevokeCert(caName, getSerialNumber(), debug);
        } finally {
            saveRequestResponse(debug);
        }
    }
    if (certIdOrError.getError() != null) {
        PkiStatusInfo error = certIdOrError.getError();
        throw new CmdFailure("releasing revocation failed: " + error);
    } else {
        println("unrevoked certificate");
    }
    return null;
}
Also used : RequestResponseDebug(org.xipki.common.RequestResponseDebug) CmdFailure(org.xipki.console.karaf.CmdFailure) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) CertIdOrError(org.xipki.ca.client.api.CertIdOrError) PkiStatusInfo(org.xipki.cmp.PkiStatusInfo) X509Certificate(java.security.cert.X509Certificate)

Aggregations

X509Certificate (java.security.cert.X509Certificate)3 CertIdOrError (org.xipki.ca.client.api.CertIdOrError)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 Date (java.util.Date)1 CrlReason (org.xipki.security.CrlReason)1