Search in sources :

Example 91 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class RemoveCertCmd method execute0.

@Override
protected Object execute0() throws Exception {
    BigInteger serialNo = getSerialNumber();
    String msg = "certificate (serial number = 0x" + serialNo.toString(16) + ")";
    try {
        caManager.removeCertificate(caName, serialNo);
        println("removed " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure) BigInteger(java.math.BigInteger)

Example 92 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class UnRevRmCertAction method getSerialNumber.

protected BigInteger getSerialNumber() throws CmdFailure, IllegalCmdParamException, CertificateException, IOException {
    CaEntry ca = caManager.getCa(caName);
    if (ca == null) {
        throw new CmdFailure("CA " + caName + " not available");
    }
    if (!(ca instanceof X509CaEntry)) {
        throw new CmdFailure("CA " + caName + " is not an X.509-CA");
    }
    BigInteger serialNumber;
    if (serialNumberS != null) {
        serialNumber = toBigInt(serialNumberS);
    } else if (certFile != null) {
        X509Certificate caCert = ((X509CaEntry) ca).getCert();
        X509Certificate cert = X509Util.parseCert(IoUtil.read(certFile));
        if (!X509Util.issues(caCert, cert)) {
            throw new CmdFailure("certificate '" + certFile + "' is not issued by CA " + caName);
        }
        serialNumber = cert.getSerialNumber();
    } else {
        throw new IllegalCmdParamException("neither serialNumber nor certFile is specified");
    }
    return serialNumber;
}
Also used : X509CaEntry(org.xipki.ca.server.mgmt.api.x509.X509CaEntry) CaEntry(org.xipki.ca.server.mgmt.api.CaEntry) CmdFailure(org.xipki.console.karaf.CmdFailure) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) BigInteger(java.math.BigInteger) X509Certificate(java.security.cert.X509Certificate) X509CaEntry(org.xipki.ca.server.mgmt.api.x509.X509CaEntry)

Example 93 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class ScepRemoveCmd method execute0.

@Override
protected Object execute0() throws Exception {
    String msg = "SCEP " + name;
    try {
        caManager.removeScep(name);
        println("removed " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 94 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class CaCheckCmd method execute0.

@Override
protected Object execute0() throws Exception {
    X509ChangeCaEntry ey = getChangeCaEntry();
    String caName = ey.getIdent().getName();
    println("checking CA" + caName);
    CaEntry entry = caManager.getCa(caName);
    if (entry == null) {
        throw new CmdFailure("could not find CA '" + caName + "'");
    }
    if (!(entry instanceof X509CaEntry)) {
        throw new CmdFailure("CA '" + caName + "' is not an X509-CA");
    }
    X509CaEntry ca = (X509CaEntry) entry;
    // CA cert uris
    if (ey.getCaCertUris() != null) {
        MgmtQaShellUtil.assertEquals("CA cert URIs", ey.getCaCertUris(), ca.getCaCertUris());
    }
    // CA certificate
    if (ey.getCert() != null) {
        if (!ey.getCert().equals(ca.getCert())) {
            throw new CmdFailure("CA cert is not as expected");
        }
    }
    // SN size
    if (ey.getSerialNoBitLen() != null) {
        assertObjEquals("serial number bit length", ey.getSerialNoBitLen(), ca.getSerialNoBitLen());
    }
    // CMP control name
    if (ey.getCmpControlName() != null) {
        MgmtQaShellUtil.assertEquals("CMP control name", ey.getCmpControlName(), ca.getCmpControlName());
    }
    // CRL signer name
    if (ey.getCrlSignerName() != null) {
        MgmtQaShellUtil.assertEquals("CRL signer name", ey.getCrlSignerName(), ca.getCrlSignerName());
    }
    // CRL uris
    if (ey.getCrlUris() != null) {
        MgmtQaShellUtil.assertEquals("CRL URIs", ey.getCrlUris(), ca.getCrlUris());
    }
    // DeltaCRL uris
    if (ey.getDeltaCrlUris() != null) {
        MgmtQaShellUtil.assertEquals("Delta CRL URIs", ey.getDeltaCrlUris(), ca.getDeltaCrlUris());
    }
    // Duplicate key mode
    if (ey.getDuplicateKeyPermitted() != null) {
        assertObjEquals("Duplicate key permitted", ey.getDuplicateKeyPermitted(), ca.isDuplicateKeyPermitted());
    }
    // Duplicate subject mode
    if (ey.getDuplicateSubjectPermitted() != null) {
        assertObjEquals("Duplicate subject permitted", ey.getDuplicateSubjectPermitted(), ca.isDuplicateSubjectPermitted());
    }
    // Expiration period
    if (ey.getExpirationPeriod() != null) {
        assertObjEquals("Expiration period", ey.getExpirationPeriod(), ca.getExpirationPeriod());
    }
    // Extra control
    if (ey.getExtraControl() != null) {
        assertObjEquals("Extra control", ey.getExtraControl(), ca.getExtraControl());
    }
    // Max validity
    if (ey.getMaxValidity() != null) {
        assertObjEquals("Max validity", ey.getMaxValidity(), ca.getMaxValidity());
    }
    // Keep expired certificate
    if (ey.getKeepExpiredCertInDays() != null) {
        assertObjEquals("keepExiredCertInDays", ey.getKeepExpiredCertInDays(), ca.getKeepExpiredCertInDays());
    }
    // Num CRLs
    if (ey.getNumCrls() != null) {
        assertObjEquals("num CRLs", ey.getNumCrls(), ca.getNumCrls());
    }
    // OCSP uris
    if (ey.getOcspUris() != null) {
        MgmtQaShellUtil.assertEquals("OCSP URIs", ey.getOcspUris(), ca.getOcspUris());
    }
    // Permissions
    if (ey.getPermission() != null) {
        assertObjEquals("permission", ey.getPermission(), ca.getPermission());
    }
    // Responder name
    if (ey.getResponderName() != null) {
        MgmtQaShellUtil.assertEquals("responder name", ey.getResponderName(), ca.getResponderName());
    }
    // Signer Type
    if (ey.getSignerType() != null) {
        MgmtQaShellUtil.assertEquals("signer type", ey.getSignerType(), ca.getSignerType());
    }
    if (ey.getSignerConf() != null) {
        ConfPairs ex = new ConfPairs(ey.getSignerConf());
        ex.removePair("keystore");
        ConfPairs is = new ConfPairs(ca.getSignerConf());
        is.removePair("keystore");
        assertObjEquals("signer conf", ex, is);
    }
    // Status
    if (ey.getStatus() != null) {
        assertObjEquals("status", ey.getStatus(), ca.getStatus());
    }
    // validity mode
    if (ey.getValidityMode() != null) {
        assertObjEquals("validity mode", ey.getValidityMode(), ca.getValidityMode());
    }
    println(" checked CA" + caName);
    return null;
}
Also used : X509CaEntry(org.xipki.ca.server.mgmt.api.x509.X509CaEntry) CaEntry(org.xipki.ca.server.mgmt.api.CaEntry) X509ChangeCaEntry(org.xipki.ca.server.mgmt.api.x509.X509ChangeCaEntry) CmdFailure(org.xipki.console.karaf.CmdFailure) ConfPairs(org.xipki.common.ConfPairs) X509ChangeCaEntry(org.xipki.ca.server.mgmt.api.x509.X509ChangeCaEntry) X509CaEntry(org.xipki.ca.server.mgmt.api.x509.X509CaEntry)

Example 95 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class CrlSignerRemoveCmd method execute0.

@Override
protected Object execute0() throws Exception {
    String msg = "CRL signer " + name;
    try {
        caManager.removeCrlSigner(name);
        println("removed " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure)

Aggregations

CmdFailure (org.xipki.console.karaf.CmdFailure)99 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)52 File (java.io.File)20 X509Certificate (java.security.cert.X509Certificate)20 IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)15 BigInteger (java.math.BigInteger)9 NameId (org.xipki.ca.api.NameId)9 X509CRL (java.security.cert.X509CRL)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 CaEntry (org.xipki.ca.server.mgmt.api.CaEntry)6 RequestResponseDebug (org.xipki.common.RequestResponseDebug)6 PublisherEntry (org.xipki.ca.server.mgmt.api.PublisherEntry)5 ScepClient (org.xipki.scep.client.ScepClient)4 DEROctetString (org.bouncycastle.asn1.DEROctetString)3 CertificationRequest (org.bouncycastle.asn1.pkcs.CertificationRequest)3 X500Name (org.bouncycastle.asn1.x500.X500Name)3 Client (org.jscep.client.Client)3 CertprofileEntry (org.xipki.ca.server.mgmt.api.CertprofileEntry)3 X509CrlSignerEntry (org.xipki.ca.server.mgmt.api.x509.X509CrlSignerEntry)3