List of utility methods to do Key Create
KeyManagerFactory | getKeyManagerFactory(KeyStore keystore, String password) Given a keystore and keystore password (as generated by #pemsToKeyAndTrustStores ), return a key manager factory that contains the keystore. KeyManagerFactory factory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
factory.init(keystore, password.toCharArray());
return factory;
|
KeyManagerFactory | getKeyManagerFactory(KeyStore store, char[] password) get Key Manager Factory KeyManagerFactory kmFactory = null; try { kmFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmFactory.init(store, password); } catch (NoSuchAlgorithmException nsae) { return kmFactory; |
KeyManagerFactory | getKeyManagerFactory(Map get Key Manager Factory KeyStore keystore = (KeyStore) stores.get("keystore"); String password = (String) stores.get("keystore-pw"); return getKeyManagerFactory(keystore, password); |
KeyManager[] | getKeyManagers() get Key Managers String pass = "lib.pass"; try { KeyStore keyStore = KeyStore.getInstance("JKS"); keyStore.load(new FileInputStream("keystore.jks"), pass.toCharArray()); KeyManagerFactory keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, pass.toCharArray()); return keyManagerFactory.getKeyManagers(); ... |
KeyManager[] | getKeyManagers(KeyStore keyStore, String keyPassword) get Key Managers String alg = KeyManagerFactory.getDefaultAlgorithm(); char[] keyPass = keyPassword != null ? keyPassword.toCharArray() : null; KeyManagerFactory fac = KeyManagerFactory.getInstance(alg); fac.init(keyStore, keyPass); return fac.getKeyManagers(); |
KeyManager[] | getKeyManagers(KeyStore ks, String password) get Key Managers KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, password.toCharArray());
return kmf.getKeyManagers();
|
KeyPair | getKeyPair() get Key Pair KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance(KEY_ALGORITHM);
kpGenerator.initialize(KEY_SIZE);
KeyPair keyPair = kpGenerator.generateKeyPair();
return keyPair;
|
KeyPair | getKeyPair() The method gets the key pair. return kpg.genKeyPair();
|
KeyPair | getKeyPair() Generate a RSA key pair. KeyPairGenerator keyGen = null; SecureRandom random = null; try { keyGen = KeyPairGenerator.getInstance("RSA"); random = SecureRandom.getInstance("SHA1PRNG", "SUN"); keyGen.initialize(1024, random); } catch (NoSuchAlgorithmException e) { } catch (NoSuchProviderException e) { ... |
KeyPair | getKeyPair(KeyStore keyStore, String alias, String password) get Key Pair Key key = keyStore.getKey(alias, password.toCharArray()); if (key instanceof PrivateKey) { Certificate cert = keyStore.getCertificate(alias); PublicKey publicKey = cert.getPublicKey(); return new KeyPair(publicKey, (PrivateKey) key); return null; |