Search in sources :

Example 31 with IllegalCmdParamException

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;
}
Also used : P11Slot(org.xipki.security.pkcs11.P11Slot) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) P11ObjectIdentifier(org.xipki.security.pkcs11.P11ObjectIdentifier)

Example 32 with IllegalCmdParamException

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;
}
Also used : P12KeyGenerator(org.xipki.security.pkcs12.P12KeyGenerator) P12KeyGenerationResult(org.xipki.security.pkcs12.P12KeyGenerationResult) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException)

Example 33 with IllegalCmdParamException

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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) X509CrlSignerEntry(org.xipki.ca.server.mgmt.api.x509.X509CrlSignerEntry) X509ChangeCrlSignerEntry(org.xipki.ca.server.mgmt.api.x509.X509ChangeCrlSignerEntry)

Example 34 with IllegalCmdParamException

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;
}
Also used : PkiErrorException(org.xipki.ca.client.api.PkiErrorException) X509CRL(java.security.cert.X509CRL) CmdFailure(org.xipki.console.karaf.CmdFailure) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) File(java.io.File)

Example 35 with IllegalCmdParamException

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;
}
Also used : DSAKeyEntry(org.xipki.ca.client.shell.loadtest.KeyEntry.DSAKeyEntry) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) RandomDn(org.xipki.ca.client.shell.loadtest.LoadTestEntry.RandomDn) RSAKeyEntry(org.xipki.ca.client.shell.loadtest.KeyEntry.RSAKeyEntry) ECKeyEntry(org.xipki.ca.client.shell.loadtest.KeyEntry.ECKeyEntry) RSAKeyEntry(org.xipki.ca.client.shell.loadtest.KeyEntry.RSAKeyEntry) DSAKeyEntry(org.xipki.ca.client.shell.loadtest.KeyEntry.DSAKeyEntry) ECKeyEntry(org.xipki.ca.client.shell.loadtest.KeyEntry.ECKeyEntry)

Aggregations

IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)42 CmdFailure (org.xipki.console.karaf.CmdFailure)15 File (java.io.File)8 X509Certificate (java.security.cert.X509Certificate)6 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)6 P11Slot (org.xipki.security.pkcs11.P11Slot)6 BigInteger (java.math.BigInteger)5 RequestResponseDebug (org.xipki.common.RequestResponseDebug)5 P11ObjectIdentifier (org.xipki.security.pkcs11.P11ObjectIdentifier)5 FileInputStream (java.io.FileInputStream)4 NameId (org.xipki.ca.api.NameId)4 X509CRL (java.security.cert.X509CRL)3 Date (java.util.Date)3 LinkedList (java.util.LinkedList)3 Certificate (org.bouncycastle.asn1.x509.Certificate)3 CertIdOrError (org.xipki.ca.client.api.CertIdOrError)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 Key (java.security.Key)2