use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class CmpControlInfoCmd method execute0.
@Override
protected Object execute0() throws Exception {
StringBuilder sb = new StringBuilder();
if (name == null) {
Set<String> names = caManager.getCmpControlNames();
int size = names.size();
if (size == 0 || size == 1) {
sb.append((size == 0) ? "no" : "1");
sb.append(" CMP control is configured\n");
} else {
sb.append(size).append(" CMP controls are configured:\n");
}
List<String> sorted = new ArrayList<>(names);
Collections.sort(sorted);
for (String m : sorted) {
sb.append("\t").append(m).append("\n");
}
} else {
CmpControlEntry entry = caManager.getCmpControl(name);
if (entry == null) {
throw new CmdFailure("\tno CMP control named '" + name + "' is configured");
} else {
sb.append(entry.toString());
}
}
println(sb.toString());
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class UnrevokeCertCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (!(certFile == null ^ getSerialNumber() == null)) {
throw new IllegalCmdParamException("exactly one of cert and serial must be specified");
}
CertIdOrError certIdOrError;
if (certFile != null) {
X509Certificate cert = X509Util.parseCert(certFile);
RequestResponseDebug debug = getRequestResponseDebug();
try {
certIdOrError = caClient.unrevokeCert(caName, cert, debug);
} finally {
saveRequestResponse(debug);
}
} else {
RequestResponseDebug debug = getRequestResponseDebug();
try {
certIdOrError = caClient.unrevokeCert(caName, getSerialNumber(), debug);
} finally {
saveRequestResponse(debug);
}
}
if (certIdOrError.getError() != null) {
PkiStatusInfo error = certIdOrError.getError();
throw new CmdFailure("releasing revocation failed: " + error);
} else {
println("unrevoked certificate");
}
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class CaProfileRemoveCmd method execute0.
@Override
protected Object execute0() throws Exception {
for (String profileName : profileNames) {
String msg = StringUtil.concat("certificate profile ", profileName, " from CA ", caName);
try {
caManager.removeCertprofileFromCa(profileName, caName);
println("removed " + msg);
} catch (CaMgmtException ex) {
throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
}
}
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class CaPublisherInfoCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (caManager.getCa(caName) == null) {
throw new CmdFailure("could not find CA '" + caName + "'");
}
List<PublisherEntry> entries = caManager.getPublishersForCa(caName);
if (isNotEmpty(entries)) {
StringBuilder sb = new StringBuilder();
sb.append("publishers for CA ").append(caName).append("\n");
for (PublisherEntry entry : entries) {
sb.append("\t").append(entry.getIdent().getName()).append("\n");
}
println(sb.toString());
} else {
println(StringUtil.concat("no publisher for CA ", caName, " is configured"));
}
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class CaRequestorInfoCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (caManager.getCa(caName) == null) {
throw new CmdFailure("could not find CA '" + caName + "'");
}
StringBuilder sb = new StringBuilder();
Set<CaHasRequestorEntry> entries = caManager.getRequestorsForCa(caName);
if (isNotEmpty(entries)) {
sb.append("requestors trusted by CA " + caName).append("\n");
for (CaHasRequestorEntry entry : entries) {
sb.append("\t").append(entry).append("\n");
}
} else {
sb.append("\tno requestor for CA " + caName + " is configured");
}
println(sb.toString());
return null;
}
Aggregations