public static SecretKey getSecretKey ( File keystore , String entryName , String keyStorePassword ) throws KeyStoreException , NoSuchAlgorithmException , CertificateException , FileNotFoundException , IOException , UnrecoverableEntryException { KeyStore keyStore = KeyStore . getInstance ( "JCEKS" ) ; FileInputStream fis = null ; if ( keystore == null || ! keystore . exists ( ) || FileUtils . sizeOf ( keystore ) == 0 ) { throw new FileNotFoundException ( ) ; } if ( StringUtils . isEmpty ( keyStorePassword ) ) { throw new KeyStoreException ( "No Keystore password provided." ) ; } if ( StringUtils . isEmpty ( entryName ) ) { throw new KeyStoreException ( "No Keystore entry name provided." ) ; } fis = new FileInputStream ( keystore ) ; return getSecretKey ( fis , entryName , keyStorePassword ) ; }
Method which will load a secret key from disk with the specified entry name .