Java Key Create getKeyManagerFactory(InputStream key, String keyPassword)

Here you can find the source of getKeyManagerFactory(InputStream key, String keyPassword)

Description

get Key Manager Factory

License

Apache License

Declaration

private static KeyManagerFactory getKeyManagerFactory(InputStream key, String keyPassword) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.InputStream;
import java.security.KeyStore;

import javax.net.ssl.KeyManagerFactory;

public class Main {

    private static KeyManagerFactory getKeyManagerFactory(InputStream key, String keyPassword) {
        KeyManagerFactory kmf = null;

        try {//from ww w .j  ava2s . c o m
            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());

        } catch (Exception e) {
            e.printStackTrace();
        }

        return kmf;
    }
}

Related

  1. getKeyFromFile(String keyFile)
  2. getKeyGenerator(String algorithm)
  3. getKeyKeyManagerFactory(InputStream keyStore, String password, String algorithm, String keyStoreType)
  4. getKeyKeyManagerFactoryByPfx(InputStream keyStore, String password)
  5. getKeyManager(KeyStore keyStore, char[] keyStorePassword)
  6. getKeyManagerFactory(KeyStore keystore, String password)
  7. getKeyManagerFactory(KeyStore store, char[] password)
  8. getKeyManagerFactory(Map stores)
  9. getKeyManagers()