List of utility methods to do Key Create
KeyFactory | getKeyFactory(final String algorithm) get Key Factory return KeyFactory.getInstance(algorithm);
|
KeyFactory | getKeyFactory(final String algorithm) get Key Factory synchronized (keyFactories) { KeyFactory kf = keyFactories.get(algorithm); if (kf != null) { return kf; try { kf = KeyFactory.getInstance(algorithm, "BC"); } catch (NoSuchAlgorithmException | NoSuchProviderException e) { ... |
KeyFactory | getKeyFactory(String keyType) get Key Factory if (keyType.startsWith("EC")) { return KeyFactory.getInstance("EC"); } else { return KeyFactory.getInstance(keyType); |
SecretKey | getKeyFromFile(String _sFilename, String _sPassword) getKeyFromFile - Gets key value from file, to be used for encryption/decryption SecretKey sk = null; File fKeyFile = new File(_sFilename); System.out.println("DEBUG->getKeyFromFile..."); if (fKeyFile.exists()) { try { KeyStore ks = KeyStore.getInstance("JCEKS"); ks.load(new FileInputStream(_sFilename), _sPassword.toCharArray()); sk = (SecretKey) ks.getKey(S_KEY_ALIAS, _sPassword.toCharArray()); ... |
Key | getKeyFromFile(String keyFile) get Key From File Key kp = null; try { InputStream is = new FileInputStream(keyFile); ObjectInputStream oos = new ObjectInputStream(is); kp = (Key) oos.readObject(); oos.close(); } catch (Exception e) { e.printStackTrace(); ... |
KeyGenerator | getKeyGenerator(String algorithm) Get the KeyGenerator of this algorithm try { return KeyGenerator.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("Algorithm not found for: " + algorithm, e); |
KeyManagerFactory | getKeyKeyManagerFactory(InputStream keyStore, String password, String algorithm, String keyStoreType) get Key Key Manager Factory KeyStore ks = KeyStore.getInstance(keyStoreType);
ks.load(keyStore, password.toCharArray());
keyStore.close();
KeyManagerFactory k = KeyManagerFactory.getInstance(algorithm);
k.init(ks, password.toCharArray());
return k;
|
KeyManagerFactory | getKeyKeyManagerFactoryByPfx(InputStream keyStore, String password) get Key Key Manager Factory By Pfx String algorithm = "sunx509"; String keyStoreType = "PKCS12"; return getKeyKeyManagerFactory(keyStore, password, algorithm, keyStoreType); |
X509KeyManager | getKeyManager(KeyStore keyStore, char[] keyStorePassword) get Key Manager KeyManagerFactory keyManagerFactory = KeyManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, keyStorePassword);
return (X509KeyManager) keyManagerFactory.getKeyManagers()[0];
|
KeyManagerFactory | getKeyManagerFactory(InputStream key, String keyPassword) get Key Manager Factory KeyManagerFactory kmf = null; try { String keyStoreType = "BKS"; KeyStore keyStore = KeyStore.getInstance(keyStoreType); keyStore.load(key, keyPassword.toCharArray()); String kmfAlgorithm = KeyManagerFactory.getDefaultAlgorithm(); kmf = KeyManagerFactory.getInstance(kmfAlgorithm); kmf.init(keyStore, keyPassword.toCharArray()); ... |