Search in sources :

Example 26 with CmdFailure

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

the class CrlSignerInfoCmd method execute0.

@Override
protected Object execute0() throws Exception {
    StringBuilder sb = new StringBuilder();
    if (name == null) {
        Set<String> names = caManager.getCrlSignerNames();
        int size = names.size();
        if (size == 0 || size == 1) {
            sb.append((size == 0) ? "no" : "1");
            sb.append(" CRL signer is configured\n");
        } else {
            sb.append(size).append(" CRL signers are configured:\n");
        }
        List<String> sorted = new ArrayList<>(names);
        Collections.sort(sorted);
        for (String entry : sorted) {
            sb.append("\t").append(entry).append("\n");
        }
    } else {
        X509CrlSignerEntry entry = caManager.getCrlSigner(name);
        if (entry == null) {
            throw new CmdFailure("\tno CRL signer named '" + name + "' is configured");
        } else {
            sb.append(entry.toString(verbose.booleanValue()));
        }
    }
    println(sb.toString());
    return null;
}
Also used : CmdFailure(org.xipki.console.karaf.CmdFailure) ArrayList(java.util.ArrayList) X509CrlSignerEntry(org.xipki.ca.server.mgmt.api.x509.X509CrlSignerEntry)

Example 27 with CmdFailure

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

the class CaProfileAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    for (String profileName : profileNames) {
        String msg = StringUtil.concat("certificate profile ", profileName, " to CA ", caName);
        try {
            caManager.addCertprofileToCa(profileName, caName);
            println("associated " + msg);
        } catch (CaMgmtException ex) {
            throw new CmdFailure("could not associate " + msg + ", error: " + ex.getMessage(), ex);
        }
    }
    return null;
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 28 with CmdFailure

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

the class CaRemoveCmd method execute0.

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

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

the class EnvAddCmd method execute0.

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

Example 30 with CmdFailure

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

the class EnvRemoveCmd method execute0.

@Override
protected Object execute0() throws Exception {
    String msg = "environment parameter " + name;
    try {
        caManager.removeEnvParam(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