Here you can find the source of getKeyStore(String filename, char[] password)
public static KeyStore getKeyStore(String filename, char[] password) throws GeneralSecurityException
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 TXT e-solutions SpA * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * This work was performed within the IoT_at_Work Project * and partially funded by the European Commission's * 7th Framework Programme under the research area ICT-2009.1.3 * Internet of Things and enterprise environments. * * * Authors://from w ww.j a v a2 s . co m * Cristoforo Seccia (TXT e-solutions SpA) * * Contributors: * Domenico Rotondi (TXT e-solutions SpA) *******************************************************************************/ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; public class Main { public static KeyStore getKeyStore(String filename, char[] password) throws GeneralSecurityException { try { KeyStore result = KeyStore.getInstance(KeyStore.getDefaultType()); FileInputStream in = new FileInputStream(filename); result.load(in, password); in.close(); return result; } catch (IOException ex) { throw new GeneralSecurityException(ex.getMessage(), ex); } catch (NoSuchAlgorithmException ex) { throw new GeneralSecurityException(ex.getMessage(), ex); } catch (CertificateException ex) { throw new GeneralSecurityException(ex.getMessage(), ex); } } public static KeyStore getKeyStore(InputStream in, char[] password) throws GeneralSecurityException { try { KeyStore result = KeyStore.getInstance(KeyStore.getDefaultType()); result.load(in, password); return result; } catch (IOException ex) { throw new GeneralSecurityException(ex.getMessage(), ex); } catch (NoSuchAlgorithmException ex) { throw new GeneralSecurityException(ex.getMessage(), ex); } catch (CertificateException ex) { throw new GeneralSecurityException(ex.getMessage(), ex); } } }