Java Key Create getKeyStore(String file_name, char[] storepass)

Here you can find the source of getKeyStore(String file_name, char[] storepass)

Description

get Key Store

License

Open Source License

Parameter

Parameter Description
file_name - a keystore file name to be loaded
storepass - the password for managing the keystore

Declaration


public static KeyStore getKeyStore(String file_name, char[] storepass)
        throws java.io.IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException 

Method Source Code


//package com.java2s;
/*/*from ww  w . j  av a 2  s  .  c o m*/
 *        JacORB - a free Java ORB
 *
 *   Copyright (C) 2000  Gerald Brose.
 *
 *   This library is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU Library General Public
 *   License as published by the Free Software Foundation; either
 *   version 2 of the License, or (at your option) any later version.
 *
 *   This library is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *   Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this library; if not, write to the Free
 *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

import java.security.*;
import java.security.cert.*;
import java.io.*;

public class Main {
    /**
     * @returns - a fully loaded and operational KeyStore
     * @param file_name - a keystore file name to be loaded
     * @param storepass - the password for managing the keystore
     */

    public static KeyStore getKeyStore(String file_name, char[] storepass)
            throws java.io.IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException {
        FileInputStream in = new FileInputStream(file_name);

        KeyStore ks;
        //   ks = KeyStore.getInstance("jks");

        try {
            ks = KeyStore.getInstance("IAIKKeyStore", "IAIK");
        } catch (java.security.NoSuchProviderException ex) {
            System.err.println(ex.toString());
            ks = KeyStore.getInstance("jks");
        }
        ks.load(in, storepass);
        in.close();
        return ks;
    }
}

Related

  1. getKeyStore(File file, char[] storePass)
  2. getKeyStore(File keystore)
  3. getKeyStore(File keyStore)
  4. getKeyStore(final URL url, final String password)
  5. getKeyStore(InputStream ksStream, char[] storePass)
  6. getKeyStore(String filename, char[] password)
  7. getKeyStore(String filename, String password)
  8. getKeyStore(String keyStoreName, String password)
  9. getKeyStore(String keystorePath, String keystorePassword)