use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class ProfileRemoveCmd method execute0.
@Override
protected Object execute0() throws Exception {
String msg = "certificate profile " + name;
try {
caManager.removeCertprofile(name);
println("removed " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
}
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class ResponderAddCmd method execute0.
@Override
protected Object execute0() throws Exception {
String base64Cert = null;
X509Certificate signerCert = null;
if (certFile != null) {
signerCert = X509Util.parseCert(certFile);
base64Cert = IoUtil.base64Encode(signerCert.getEncoded(), false);
}
if ("PKCS12".equalsIgnoreCase(signerType) || "JKS".equalsIgnoreCase(signerType)) {
signerConf = ShellUtil.canonicalizeSignerConf(signerType, signerConf, passwordResolver, securityFactory);
}
ResponderEntry entry = new ResponderEntry(name, signerType, signerConf, base64Cert);
String msg = "CMP responder " + name;
try {
caManager.addResponder(entry);
println("added " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex);
}
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class ScepAddCmd method execute0.
@Override
protected Object execute0() throws Exception {
ScepEntry entry = new ScepEntry(name, new NameId(null, caName), !inactive, responderName, profiles, scepControl);
String msg = "SCEP " + name;
try {
caManager.addScep(entry);
println("added " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex);
}
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method getCurrentCrl.
// method getCrl
@Override
public X509CRL getCurrentCrl(String caName) throws CaMgmtException {
caName = ParamUtil.requireNonBlank("caName", caName).toLowerCase();
X509Ca ca = getX509Ca(caName);
try {
X509CRL crl = ca.getCurrentCrl();
if (crl == null) {
LOG.warn("found no CRL for CA {}", caName);
}
return crl;
} catch (OperationException ex) {
throw new CaMgmtException(ex.getMessage(), ex);
}
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method addCa.
@Override
public void addCa(CaEntry caEntry) throws CaMgmtException {
ParamUtil.requireNonNull("caEntry", caEntry);
asssertMasterMode();
NameId ident = caEntry.getIdent();
String name = ident.getName();
if (caInfos.containsKey(name)) {
throw new CaMgmtException(concat("CA named ", name, " exists"));
}
String origSignerConf = caEntry.getSignerConf();
String newSignerConf = canonicalizeSignerConf(caEntry.getSignerType(), origSignerConf, null, securityFactory);
if (!origSignerConf.equals(newSignerConf)) {
caEntry.setSignerConf(newSignerConf);
}
if (caEntry instanceof X509CaEntry) {
try {
X509CaEntry tmpCaEntry = (X509CaEntry) caEntry;
List<String[]> signerConfs = CaEntry.splitCaSignerConfs(tmpCaEntry.getSignerConf());
ConcurrentContentSigner signer;
for (String[] m : signerConfs) {
SignerConf signerConf = new SignerConf(m[1]);
signer = securityFactory.createSigner(tmpCaEntry.getSignerType(), signerConf, tmpCaEntry.getCert());
if (tmpCaEntry.getCert() == null) {
if (signer.getCertificate() == null) {
throw new CaMgmtException("CA signer without certificate is not allowed");
}
tmpCaEntry.setCert(signer.getCertificate());
}
}
} catch (XiSecurityException | ObjectCreationException ex) {
throw new CaMgmtException(concat("could not create signer for new CA ", name, ": ", ex.getMessage()), ex);
}
}
queryExecutor.addCa(caEntry);
if (!createCa(name)) {
LOG.error("could not create CA {}", name);
} else {
if (startCa(name)) {
LOG.info("started CA {}", name);
} else {
LOG.error("could not start CA {}", name);
}
}
}
Aggregations