Search in sources :

Example 96 with CmdFailure

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

the class PublisherRemoveCmd method execute0.

@Override
protected Object execute0() throws Exception {
    String msg = "publisher " + name;
    try {
        caManager.removePublisher(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 97 with CmdFailure

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

the class RepublishCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (publisherNames == null) {
        throw new RuntimeException("should not reach here");
    }
    boolean allPublishers = false;
    for (String publisherName : publisherNames) {
        if ("all".equalsIgnoreCase(publisherName)) {
            allPublishers = true;
            break;
        }
    }
    if (allPublishers) {
        publisherNames = null;
    }
    if ("all".equalsIgnoreCase(caName)) {
        caName = null;
    }
    String msg = "certificates";
    try {
        caManager.republishCertificates(caName, publisherNames, numThreads);
        println("republished " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not republish " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 98 with CmdFailure

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

the class ResponderCheckCmd method execute0.

@Override
protected Object execute0() throws Exception {
    println("checking responder " + name);
    ResponderEntry cr = caManager.getResponder(name);
    if (cr == null) {
        throw new CmdFailure("responder named '" + name + "' is not configured");
    }
    if (CaManager.NULL.equalsIgnoreCase(certFile)) {
        if (cr.getBase64Cert() != null) {
            throw new CmdFailure("Cert: is configured but expected is none");
        }
    } else if (certFile != null) {
        byte[] ex = IoUtil.read(certFile);
        if (cr.getBase64Cert() == null) {
            throw new CmdFailure("Cert: is not configured explicitly as expected");
        }
        if (!Arrays.equals(ex, Base64.decode(cr.getBase64Cert()))) {
            throw new CmdFailure("Cert: the expected one and the actual one differ");
        }
    }
    String signerConf = getSignerConf();
    if (signerConf != null) {
        MgmtQaShellUtil.assertEquals("conf", signerConf, cr.getConf());
    }
    println(" checked responder " + name);
    return null;
}
Also used : CmdFailure(org.xipki.console.karaf.CmdFailure) ResponderEntry(org.xipki.ca.server.mgmt.api.ResponderEntry)

Example 99 with CmdFailure

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

the class GetCertCmd method execute0.

@Override
protected Object execute0() throws Exception {
    Client client = getScepClient();
    BigInteger serial = toBigInt(serialNumber);
    CertStore certs = client.getCertificate(getIdentityCert(), getIdentityKey(), serial, null);
    X509Certificate cert = extractEeCerts(certs);
    if (cert == null) {
        throw new CmdFailure("received no certificate from server");
    }
    saveVerbose("saved returned certificate to file", new File(outputFile), cert.getEncoded());
    return null;
}
Also used : CmdFailure(org.xipki.console.karaf.CmdFailure) BigInteger(java.math.BigInteger) Client(org.jscep.client.Client) CertStore(java.security.cert.CertStore) File(java.io.File) X509Certificate(java.security.cert.X509Certificate)

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