use of org.xipki.console.karaf.IllegalCmdParamException in project xipki by xipki.
the class P11RSAKeyGenCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (keysize % 1024 != 0) {
throw new IllegalCmdParamException("keysize is not multiple of 1024: " + keysize);
}
P11Slot slot = getSlot();
P11ObjectIdentifier objId = slot.generateRSAKeypair(keysize, toBigInt(publicExponent), label, getControl());
finalize("RSA", objId);
return null;
}
use of org.xipki.console.karaf.IllegalCmdParamException in project xipki by xipki.
the class P12RSAKeyGenCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (keysize % 1024 != 0) {
throw new IllegalCmdParamException("keysize is not multiple of 1024: " + keysize);
}
P12KeyGenerationResult keypair = new P12KeyGenerator().generateRSAKeypair(keysize, toBigInt(publicExponent), getKeyGenParameters(), subject);
saveKey(keypair);
return null;
}
use of org.xipki.console.karaf.IllegalCmdParamException in project xipki by xipki.
the class CrlSignerUpdateCmd method getCrlSignerChangeEntry.
protected X509ChangeCrlSignerEntry getCrlSignerChangeEntry() throws Exception {
String signerCertConf = null;
if (CaManager.NULL.equalsIgnoreCase(signerCert)) {
signerCertConf = CaManager.NULL;
} else if (signerCert != null) {
byte[] certBytes = IoUtil.read(signerCert);
X509Util.parseCert(new ByteArrayInputStream(certBytes));
signerCertConf = Base64.encodeToString(certBytes);
}
if (signerConf != null) {
String tmpSignerType = signerType;
if (tmpSignerType == null) {
X509CrlSignerEntry entry = caManager.getCrlSigner(name);
if (entry == null) {
throw new IllegalCmdParamException("please specify the signerType");
}
tmpSignerType = entry.getType();
}
signerConf = ShellUtil.canonicalizeSignerConf(tmpSignerType, signerConf, passwordResolver, securityFactory);
}
X509ChangeCrlSignerEntry dbEntry = new X509ChangeCrlSignerEntry(name);
dbEntry.setSignerType(signerType);
dbEntry.setSignerConf(signerConf);
dbEntry.setCrlControl(crlControl);
dbEntry.setBase64Cert(signerCertConf);
return dbEntry;
}
use of org.xipki.console.karaf.IllegalCmdParamException in project xipki by xipki.
the class CrlAction method execute0.
@Override
protected Object execute0() throws Exception {
if (caName != null) {
caName = caName.toLowerCase();
}
Set<String> caNames = caClient.getCaNames();
if (isEmpty(caNames)) {
throw new CmdFailure("no CA is configured");
}
if (caName != null && !caNames.contains(caName)) {
throw new IllegalCmdParamException("CA " + caName + " is not within the configured CAs " + caNames);
}
if (caName == null) {
if (caNames.size() == 1) {
caName = caNames.iterator().next();
} else {
throw new IllegalCmdParamException("no CA is specified, one of " + caNames + " is required");
}
}
X509CRL crl = null;
try {
crl = retrieveCrl();
} catch (PkiErrorException ex) {
throw new CmdFailure("received no CRL from server: " + ex.getMessage());
}
if (crl == null) {
throw new CmdFailure("received no CRL from server");
}
saveVerbose("saved CRL to file", new File(outFile), crl.getEncoded());
return null;
}
use of org.xipki.console.karaf.IllegalCmdParamException in project xipki by xipki.
the class CaLoadTestEnrollCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (numThreads < 1) {
throw new IllegalCmdParamException("invalid number of threads " + numThreads);
}
if ("EC".equalsIgnoreCase(keyType) && StringUtil.isBlank(curveName)) {
throw new IllegalCmdParamException("curveName is not specified");
}
String description = StringUtil.concatObjectsCap(200, "subjectTemplate: ", subjectTemplate, "\nprofile: ", certprofile, "\nkeyType: ", keyType, "\nmaxRequests: ", maxRequests, "\nunit: ", num, " certificate", (num > 1 ? "s" : ""));
RandomDn randomDn = null;
if (randomDnStr != null) {
randomDn = RandomDn.getInstance(randomDnStr);
if (randomDn == null) {
throw new IllegalCmdParamException("invalid randomDN " + randomDnStr);
}
}
KeyEntry keyEntry;
if ("EC".equalsIgnoreCase(keyType)) {
keyEntry = new ECKeyEntry(curveName);
} else if ("RSA".equalsIgnoreCase(keyType)) {
keyEntry = new RSAKeyEntry(keysize.intValue());
} else if ("DSA".equalsIgnoreCase(keyType)) {
keyEntry = new DSAKeyEntry(keysize.intValue());
} else {
throw new IllegalCmdParamException("invalid keyType " + keyType);
}
LoadTestEntry loadtestEntry = new LoadTestEntry(certprofile, keyEntry, subjectTemplate, randomDn);
CaLoadTestEnroll loadTest = new CaLoadTestEnroll(caClient, loadtestEntry, maxRequests, num, description);
loadTest.setDuration(duration);
loadTest.setThreads(numThreads);
loadTest.test();
return null;
}
Aggregations