Search in sources :

Example 56 with CmdFailure

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

the class PublisherCheckCmd method execute0.

@Override
protected Object execute0() throws Exception {
    println("checking publisher " + name);
    PublisherEntry cp = caManager.getPublisher(name);
    if (cp == null) {
        throw new CmdFailure("publisher named '" + name + "' is not configured");
    }
    if (cp.getType() != null) {
        MgmtQaShellUtil.assertEquals("type", type, cp.getType());
    }
    if (cp.getConf() != null) {
        MgmtQaShellUtil.assertEquals("signer conf", conf, cp.getConf());
    }
    println(" checked publisher " + name);
    return null;
}
Also used : PublisherEntry(org.xipki.ca.server.mgmt.api.PublisherEntry) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 57 with CmdFailure

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

the class CertPollCmd method execute0.

@Override
protected Object execute0() throws Exception {
    PKCS10CertificationRequest csr = new PKCS10CertificationRequest(IoUtil.read(csrFile));
    Client client = getScepClient();
    TransactionId transId = TransactionId.createTransactionId(CertificationRequestUtils.getPublicKey(csr), "SHA-1");
    EnrollmentResponse resp = client.poll(getIdentityCert(), getIdentityKey(), new X500Principal(csr.getSubject().getEncoded()), transId);
    if (resp.isFailure()) {
        throw new CmdFailure("server returned 'failure'");
    }
    if (resp.isPending()) {
        throw new CmdFailure("server returned 'pending'");
    }
    X509Certificate cert = extractEeCerts(resp.getCertStore());
    if (cert == null) {
        throw new Exception("received no certificate");
    }
    saveVerbose("saved polled certificate to file", new File(outputFile), cert.getEncoded());
    return null;
}
Also used : PKCS10CertificationRequest(org.bouncycastle.pkcs.PKCS10CertificationRequest) CmdFailure(org.xipki.console.karaf.CmdFailure) X500Principal(javax.security.auth.x500.X500Principal) EnrollmentResponse(org.jscep.client.EnrollmentResponse) Client(org.jscep.client.Client) File(java.io.File) X509Certificate(java.security.cert.X509Certificate) TransactionId(org.jscep.transaction.TransactionId)

Example 58 with CmdFailure

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

the class EnrollCertAction method execute0.

@Override
protected Object execute0() throws Exception {
    Client client = getScepClient();
    PKCS10CertificationRequest csr = new PKCS10CertificationRequest(IoUtil.read(csrFile));
    EnrollmentResponse resp = requestCertificate(client, csr, getIdentityKey(), getIdentityCert());
    if (resp.isFailure()) {
        throw new CmdFailure("server returned 'failure'");
    }
    if (resp.isPending()) {
        throw new CmdFailure("server returned 'pending'");
    }
    X509Certificate cert = extractEeCerts(resp.getCertStore());
    if (cert == null) {
        throw new Exception("received no certificate");
    }
    saveVerbose("saved enrolled certificate to file", new File(outputFile), cert.getEncoded());
    return null;
}
Also used : PKCS10CertificationRequest(org.bouncycastle.pkcs.PKCS10CertificationRequest) CmdFailure(org.xipki.console.karaf.CmdFailure) EnrollmentResponse(org.jscep.client.EnrollmentResponse) Client(org.jscep.client.Client) File(java.io.File) X509Certificate(java.security.cert.X509Certificate) TransactionException(org.jscep.transaction.TransactionException) ClientException(org.jscep.client.ClientException)

Example 59 with CmdFailure

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

the class CaPublisherCheckCmd method execute0.

@Override
protected Object execute0() throws Exception {
    println("checking CA publisher CA='" + caName + "', publisher='" + publisherName + "'");
    if (caManager.getCa(caName) == null) {
        throw new CmdFailure("could not find CA '" + caName + "'");
    }
    List<PublisherEntry> entries = caManager.getPublishersForCa(caName);
    String upPublisherName = publisherName.toLowerCase();
    for (PublisherEntry m : entries) {
        if (m.getIdent().getName().equals(upPublisherName)) {
            println(" checked CA publisher CA='" + caName + "', publisher='" + publisherName + "'");
            return null;
        }
    }
    throw new CmdFailure("CA is not associated with publisher '" + publisherName + "'");
}
Also used : PublisherEntry(org.xipki.ca.server.mgmt.api.PublisherEntry) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 60 with CmdFailure

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

the class CmpControlCheckCmd method execute0.

@Override
protected Object execute0() throws Exception {
    println("checking CMP control " + name);
    CmpControlEntry ce = caManager.getCmpControl(name);
    if (ce == null) {
        throw new CmdFailure("no CMP control named '" + name + "' is configured");
    }
    String is = ce.getConf();
    String ex = new CmpControl(new CmpControlEntry(name, conf)).getDbEntry().getConf();
    MgmtQaShellUtil.assertEquals("CMP control", ex, is);
    println(" checked CMP control " + name);
    return null;
}
Also used : CmdFailure(org.xipki.console.karaf.CmdFailure) CmpControlEntry(org.xipki.ca.server.mgmt.api.CmpControlEntry) CmpControl(org.xipki.ca.server.mgmt.api.CmpControl)

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