use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class ExportConfCmd method execute0.
@Override
protected Object execute0() throws Exception {
String msg = "configuration to file " + confFile;
try {
caManager.exportConf(confFile, caNames);
println("exported " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not export " + msg + ", error: " + ex.getMessage(), ex);
}
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class ProfileAddCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (conf == null && confFile != null) {
conf = new String(IoUtil.read(confFile));
}
CertprofileEntry entry = new CertprofileEntry(new NameId(null, name), type, conf);
String msg = "certificate profile " + name;
try {
caManager.addCertprofile(entry);
println("added " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex);
}
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class ProfileInfoCmd method execute0.
@Override
protected Object execute0() throws Exception {
StringBuilder sb = new StringBuilder();
if (name == null) {
Set<String> names = caManager.getCertprofileNames();
int size = names.size();
if (size == 0 || size == 1) {
sb.append((size == 0) ? "no" : "1");
sb.append(" profile is configured\n");
} else {
sb.append(size).append(" profiles are configured:\n");
}
List<String> sorted = new ArrayList<>(names);
Collections.sort(sorted);
for (String entry : sorted) {
sb.append("\t").append(entry).append("\n");
}
} else {
CertprofileEntry entry = caManager.getCertprofile(name);
if (entry == null) {
throw new CmdFailure("\tno certificate profile named '" + name + "' is configured");
} 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 ProfileUpdateCmd 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 = "certificate profile " + name;
try {
caManager.changeCertprofile(name, type, conf);
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 CaAddCmd method execute0.
@Override
protected Object execute0() throws Exception {
X509CaEntry caEntry = getCaEntry();
if (certFile != null) {
X509Certificate caCert = X509Util.parseCert(certFile);
caEntry.setCert(caCert);
}
String msg = "CA " + caEntry.getIdent().getName();
try {
caManager.addCa(caEntry);
println("added " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex);
}
}
Aggregations