Java Key Create getKeyKeyManagerFactoryByPfx(InputStream keyStore, String password)

Here you can find the source of getKeyKeyManagerFactoryByPfx(InputStream keyStore, String password)

Description

get Key Key Manager Factory By Pfx

License

Apache License

Declaration

public static KeyManagerFactory getKeyKeyManagerFactoryByPfx(InputStream keyStore, String password)
            throws Exception 

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 {
    public static KeyManagerFactory getKeyKeyManagerFactoryByPfx(InputStream keyStore, String password)
            throws Exception {
        String algorithm = "sunx509";
        String keyStoreType = "PKCS12";
        return getKeyKeyManagerFactory(keyStore, password, algorithm, keyStoreType);
    }/*from  ww w  . ja v  a2 s.  com*/

    public static KeyManagerFactory getKeyKeyManagerFactory(InputStream keyStore, String password, String algorithm,
            String keyStoreType) throws Exception {
        KeyStore ks = KeyStore.getInstance(keyStoreType);
        ks.load(keyStore, password.toCharArray());
        keyStore.close();
        KeyManagerFactory k = KeyManagerFactory.getInstance(algorithm);
        k.init(ks, password.toCharArray());
        return k;
    }
}

Related

  1. getKeyFactory(String keyType)
  2. getKeyFromFile(String _sFilename, String _sPassword)
  3. getKeyFromFile(String keyFile)
  4. getKeyGenerator(String algorithm)
  5. getKeyKeyManagerFactory(InputStream keyStore, String password, String algorithm, String keyStoreType)
  6. getKeyManager(KeyStore keyStore, char[] keyStorePassword)
  7. getKeyManagerFactory(InputStream key, String keyPassword)
  8. getKeyManagerFactory(KeyStore keystore, String password)
  9. getKeyManagerFactory(KeyStore store, char[] password)