protected KeyStore getKeyStore ( InputStream storeStream , String storePath , String storeType , String storeProvider , String storePassword ) throws Exception { KeyStore keystore = null ; if ( storeStream != null || storePath != null ) { InputStream inStream = storeStream ; try { if ( inStream == null ) { inStream = new FileInputStream ( storePath ) ; //assume it's a file } if ( storeProvider != null ) { keystore = KeyStore . getInstance ( storeType , storeProvider ) ; } else { keystore = KeyStore . getInstance ( storeType ) ; } keystore . load ( inStream , storePassword == null ? null : storePassword . toCharArray ( ) ) ; } finally { if ( inStream != null ) { inStream . close ( ) ; } } } return keystore ; }
Loads keystore using an input stream or a file path in the same order of precedence .