use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class CaRevokeCmd method execute0.
@Override
protected Object execute0() throws Exception {
CrlReason crlReason = CrlReason.forNameOrText(reason);
if (!PERMITTED_REASONS.contains(crlReason)) {
throw new IllegalCmdParamException("reason " + reason + " is not permitted");
}
if (!caManager.getCaNames().contains(caName)) {
throw new IllegalCmdParamException("invalid CA name " + caName);
}
Date revocationDate = null;
revocationDate = isNotBlank(revocationDateS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(revocationDateS) : new Date();
Date invalidityDate = null;
if (isNotBlank(invalidityDateS)) {
invalidityDate = DateUtil.parseUtcTimeyyyyMMddhhmmss(invalidityDateS);
}
CertRevocationInfo revInfo = new CertRevocationInfo(crlReason, revocationDate, invalidityDate);
String msg = "CA " + caName;
try {
caManager.revokeCa(caName, revInfo);
println("revoked " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not revoke " + msg + ", error: " + ex.getMessage(), ex);
}
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class CaSystemRestartCmd method execute0.
@Override
protected Object execute0() throws Exception {
try {
caManager.restartCaSystem();
} catch (CaMgmtException ex) {
throw new CmdFailure("could not restart CA system, error: " + ex.getMessage(), ex);
}
StringBuilder sb = new StringBuilder("restarted CA system\n");
sb.append(" successful CAs:\n");
String prefix = " ";
printCaNames(sb, caManager.getSuccessfulCaNames(), prefix);
sb.append(" failed CAs:\n");
printCaNames(sb, caManager.getFailedCaNames(), prefix);
sb.append(" inactive CAs:\n");
printCaNames(sb, caManager.getInactiveCaNames(), prefix);
println(sb.toString());
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class RequestorUpdateCmd method execute0.
@Override
protected Object execute0() throws Exception {
// check if the certificate is valid
byte[] certBytes = IoUtil.read(certFile);
X509Util.parseCert(new ByteArrayInputStream(certBytes));
String msg = "CMP requestor " + name;
try {
caManager.changeRequestor(name, Base64.encodeToString(certBytes));
println("updated " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not update " + msg + ", error: " + ex.getMessage(), ex);
}
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class ResponderInfoCmd method execute0.
@Override
protected Object execute0() throws Exception {
StringBuilder sb = new StringBuilder();
if (name == null) {
Set<String> names = caManager.getResponderNames();
int size = names.size();
if (size == 0 || size == 1) {
sb.append((size == 0) ? "no" : "1").append(" responder is configured\n");
} else {
sb.append(size).append(" responders are configured:\n");
}
List<String> sorted = new ArrayList<>(names);
Collections.sort(sorted);
for (String entry : sorted) {
sb.append("\t").append(entry).append("\n");
}
} else {
ResponderEntry entry = caManager.getResponder(name);
if (entry == null) {
throw new CmdFailure("could not find CMP responder '" + name + "'");
} else {
sb.append(entry.toString(verbose));
}
}
println(sb.toString());
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class ScepUpdateCmd method execute0.
@Override
protected Object execute0() throws Exception {
Boolean realActive;
if (active != null) {
if (inactive != null) {
throw new IllegalCmdParamException("maximal one of --active and --inactive can be set");
}
realActive = Boolean.TRUE;
} else if (inactive != null) {
realActive = Boolean.FALSE;
} else {
realActive = null;
}
ChangeScepEntry entry = new ChangeScepEntry(name);
if (realActive != null) {
entry.setActive(realActive);
}
if (caName != null) {
entry.setCa(new NameId(null, caName));
}
if (responderName != null) {
entry.setResponderName(responderName);
}
if (CollectionUtil.isNonEmpty(profiles)) {
if (profiles.contains("NONE")) {
profiles.clear();
}
}
if (control != null) {
entry.setControl(control);
}
String msg = "SCEP responder " + name;
try {
caManager.changeScep(entry);
println("updated " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not update " + msg + ", error: " + ex.getMessage(), ex);
}
}
Aggregations