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);
}
}
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;
}
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);
}
}
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;
}
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);
}
}
Aggregations