Search in sources :

Example 41 with IllegalCmdParamException

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

the class PublisherUpdateCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (type == null && conf == null && confFile == null) {
        throw new IllegalCmdParamException("nothing to update");
    }
    if (conf == null && confFile != null) {
        conf = new String(IoUtil.read(confFile));
    }
    String msg = "publisher " + name;
    try {
        caManager.changePublisher(name, type, conf);
        println("updated " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not update " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException)

Example 42 with IllegalCmdParamException

use of org.xipki.console.karaf.IllegalCmdParamException 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)

Aggregations

IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)42 CmdFailure (org.xipki.console.karaf.CmdFailure)15 File (java.io.File)8 X509Certificate (java.security.cert.X509Certificate)6 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)6 P11Slot (org.xipki.security.pkcs11.P11Slot)6 BigInteger (java.math.BigInteger)5 RequestResponseDebug (org.xipki.common.RequestResponseDebug)5 P11ObjectIdentifier (org.xipki.security.pkcs11.P11ObjectIdentifier)5 FileInputStream (java.io.FileInputStream)4 NameId (org.xipki.ca.api.NameId)4 X509CRL (java.security.cert.X509CRL)3 Date (java.util.Date)3 LinkedList (java.util.LinkedList)3 Certificate (org.bouncycastle.asn1.x509.Certificate)3 CertIdOrError (org.xipki.ca.client.api.CertIdOrError)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 Key (java.security.Key)2