Search in sources :

Example 16 with CrlReason

use of org.xipki.security.CrlReason in project xipki by xipki.

the class CaRevokeCmd method execute0.

@Override
protected Object execute0() throws Exception {
    CrlReason crlReason = CrlReason.forNameOrText(reason);
    if (!PERMITTED_REASONS.contains(crlReason)) {
        throw new IllegalCmdParamException("reason " + reason + " is not permitted");
    }
    if (!caManager.getCaNames().contains(caName)) {
        throw new IllegalCmdParamException("invalid CA name " + caName);
    }
    Date revocationDate = null;
    revocationDate = isNotBlank(revocationDateS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(revocationDateS) : new Date();
    Date invalidityDate = null;
    if (isNotBlank(invalidityDateS)) {
        invalidityDate = DateUtil.parseUtcTimeyyyyMMddhhmmss(invalidityDateS);
    }
    CertRevocationInfo revInfo = new CertRevocationInfo(crlReason, revocationDate, invalidityDate);
    String msg = "CA " + caName;
    try {
        caManager.revokeCa(caName, revInfo);
        println("revoked " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not revoke " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CertRevocationInfo(org.xipki.security.CertRevocationInfo) CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) CrlReason(org.xipki.security.CrlReason) Date(java.util.Date)

Aggregations

CrlReason (org.xipki.security.CrlReason)16 OperationException (org.xipki.ca.api.OperationException)10 Date (java.util.Date)9 BigInteger (java.math.BigInteger)7 CertRevocationInfo (org.xipki.security.CertRevocationInfo)5 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 DEROctetString (org.bouncycastle.asn1.DEROctetString)4 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)4 IOException (java.io.IOException)3 X509Certificate (java.security.cert.X509Certificate)3 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)3 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)3 X500Name (org.bouncycastle.asn1.x500.X500Name)3 Extension (org.bouncycastle.asn1.x509.Extension)3 Extensions (org.bouncycastle.asn1.x509.Extensions)3 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)3 X509CRL (java.security.cert.X509CRL)2 ParseException (java.text.ParseException)2 LinkedList (java.util.LinkedList)2