Package org.ejbca.util.keystore

Examples of org.ejbca.util.keystore.KeyStoreContainer


            final String caname = args[5];
            final String dn = CertTools.stringToBCDNString(StringTools.strip(args[6]));
            final int validity = Integer.parseInt(args[7]);
            HardCATokenInfo catokeninfo = new HardCATokenInfo();
            byte keyStoreID[];{
                KeyStoreContainer ksc = KeyStoreContainerFactory.getInstance(args[4],args[2], args[3], args.length>8 ? args[8] : null, null, null);
                ksc.generate("2048", DEFAULT_KEY);
                ksc.generate("2048", SIGN_KEY);
                keyStoreID = ksc.storeKeyStore();
                catokeninfo.setAuthenticationCode(new String(ksc.getPassPhraseGetSetEntry()));
            }
            getLogger().info("Initializing CA");           
            getLogger().info("Generating rootCA keystore:");
            getLogger().info("CA name: "+caname);
            getLogger().info("DN: "+dn);
View Full Code Here


                                    final String keyStoreType,
                                    final String storeID,
                                    final int nrOfTests) throws Exception {
        termOut.println("Test of keystore with ID "+storeID+'.');
        NormalTest tests[] = null;
        final KeyStoreContainer keyStore = getKeyStore(providerClassName, encryptProviderClassName,
                                                           keyStoreType, storeID);
        for (int i = 0; i<nrOfTests || nrOfTests<1; i++) {
            try {
                if ( tests==null || nrOfTests==-5 ) {
                    tests = getTests(keyStore);
View Full Code Here

                                    final String keyStoreType,
                                    final String storeID,
                                    final int numberOfThreads,
                                    final String alias,
                                    final boolean isSign) throws Exception {
        final KeyStoreContainer keyStore = getKeyStore(providerClassName, encryptProviderClassName,
                                                       keyStoreType, storeID);
        if ( keyStore.getKeyStore().isKeyEntry(alias) ) {
            PrivateKey privateKey = (PrivateKey)keyStore.getKey(alias);
            new KeyStoreContainerTest.StressTest(alias,
                           new KeyPair(keyStore.getKeyStore().getCertificate(alias).getPublicKey(), privateKey),
                           keyStore.getProviderName(),
                           numberOfThreads,
                           -1,
                           isSign);
        } else {
            termOut.println("Key alias does not exist.");
View Full Code Here

    }
    static private KeyStoreContainer getKeyStore(final String providerName,
                                                 final String encryptProviderClassName,
                                                 final String keyStoreType,
                                                 final String storeID) throws Exception {
        KeyStoreContainer keyStore = null;
        while( keyStore==null ) {
            try {
                keyStore = KeyStoreContainerFactory.getInstance(keyStoreType, providerName,
                                                   encryptProviderClassName, storeID, null, null);
            } catch( Throwable t ) {
View Full Code Here

                tooFewArguments(args);
            } else {
                if ( args[1].toLowerCase().trim().contains(GENERATE_MODULE_SWITCH) ) {
                    setModuleProtection();
                }
                KeyStoreContainer store = KeyStoreContainerFactory.getInstance(args[4], args[2], args[3], args.length>7 ? args[7] : null, null, null);
                String keyEntryName = args.length>6 ? args[6] :"myKey";
                store.generate(args[5], keyEntryName);
                System.err.println("Created certificate with entry "+keyEntryName+'.');
            }
            return true;
        }
        if ( args[1].toLowerCase().trim().equals(DELETE_SWITCH)) {
View Full Code Here

            int keySize = KeyTools.getKeyLength(pubK);
            String alg = pubK.getAlgorithm();
            log.debug("Generating new PKCS#11 "+alg+" key with spec "+paramspec+" (size="+keySize+") with label "+newKeyLabel+", on slot "+slot+", using sharedLibrary "+sharedLibrary+", and attributesFile "+attributesFile);
          }
        }
        KeyStoreContainer cont = KeyStoreContainerFactory.getInstance(KeyStoreContainer.KEYSTORE_TYPE_PKCS11, token.getProvider(), pwp);
        cont.setPassPhraseLoadSave(authCode);
        if (keyspec != null) {
          log.debug("Generating from string keyspec: "+keyspec);
          cont.generate(keyspec, newKeyLabel);
        } else {
          log.debug("Generating from AlgorithmParameterSpec: "+paramspec);
          cont.generate(paramspec, newKeyLabel);
        }
        // Set properties so that we will start using the new key, or not, depending on the activate argument
        KeyStrings kstr = new KeyStrings(properties);
        String certsignkeystr = kstr.getKey(SecConst.CAKEYPURPOSE_CERTSIGN);
        log.debug("CAKEYPURPOSE_CERTSIGN keystring is: "+certsignkeystr);
View Full Code Here

TOP

Related Classes of org.ejbca.util.keystore.KeyStoreContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.