Here you can find the source of getKeyManagerFactory(KeyStore keystore, String password)
Parameter | Description |
---|---|
keystore | The keystore to get a key manager for |
password | The password for the keystore |
Parameter | Description |
---|---|
NoSuchAlgorithmException | an exception |
KeyStoreException | an exception |
UnrecoverableKeyException | an exception |
public static KeyManagerFactory getKeyManagerFactory(KeyStore keystore, String password) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException
//package com.java2s; //License from project: Apache License import javax.net.ssl.KeyManagerFactory; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.util.Map; public class Main { /**/*ww w . j a va 2 s. c om*/ * Given a keystore and keystore password (as generated by {@link #pemsToKeyAndTrustStores}), * return a key manager factory that contains the keystore. * * @param keystore The keystore to get a key manager for * @param password The password for the keystore * @return A key manager factory for the provided keystore * @throws NoSuchAlgorithmException * @throws KeyStoreException * @throws UnrecoverableKeyException */ public static KeyManagerFactory getKeyManagerFactory(KeyStore keystore, String password) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { KeyManagerFactory factory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); factory.init(keystore, password.toCharArray()); return factory; } private static KeyManagerFactory getKeyManagerFactory(Map<String, Object> stores) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { KeyStore keystore = (KeyStore) stores.get("keystore"); String password = (String) stores.get("keystore-pw"); return getKeyManagerFactory(keystore, password); } }