Java Key Create getKeyManagerFactory(Map stores)

Here you can find the source of getKeyManagerFactory(Map stores)

Description

get Key Manager Factory

License

Apache License

Declaration

private static KeyManagerFactory getKeyManagerFactory(Map<String, Object> stores)
            throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException 

Method Source Code

//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. jav  a2  s  .  c o m*/
     * 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);
    }
}

Related

  1. getKeyKeyManagerFactoryByPfx(InputStream keyStore, String password)
  2. getKeyManager(KeyStore keyStore, char[] keyStorePassword)
  3. getKeyManagerFactory(InputStream key, String keyPassword)
  4. getKeyManagerFactory(KeyStore keystore, String password)
  5. getKeyManagerFactory(KeyStore store, char[] password)
  6. getKeyManagers()
  7. getKeyManagers(KeyStore keyStore, String keyPassword)
  8. getKeyManagers(KeyStore ks, String password)
  9. getKeyPair()