code: public static SecretKey getSecretKey(InputStream keyInputStream,
  			String entryName, String keyStorePassword)
  			throws KeyStoreException, NoSuchAlgorithmException,
  			CertificateException, IOException, UnrecoverableEntryException {
  		KeyStore keyStore = KeyStore.getInstance("JCEKS");
  
  		if (keyInputStream == null) {
  			throw new KeyStoreException("No Keystore stream provided.");
  		}
  		if (StringUtils.isEmpty(keyStorePassword)) {
  			throw new KeyStoreException("No Keystore password provided.");
  		}
  		if (StringUtils.isEmpty(entryName)) {
  			throw new KeyStoreException("No Keystore entry name provided.");
  		}
  
  		keyStore.load(keyInputStream, keyStorePassword.toCharArray());
  		KeyStore.ProtectionParameter protectionParameter = new KeyStore.PasswordProtection(
  				keyStorePassword.toCharArray());
  		KeyStore.SecretKeyEntry pkEntry = (KeyStore.SecretKeyEntry) keyStore
  				.getEntry(entryName, protectionParameter);
  		try {
  			return pkEntry.getSecretKey();
  		} finally {
  			keyInputStream.close();
  		}
  
  	}
docs: Method which will load a secret key from an input stream with the
  specified entry name.
  
  @param keystore
  {@link KeyStore} file to read.
  @param entryName
  Entry name of the key to be retrieved
  @param keyStorePassword
  Password used to open the {@link KeyStore}
  @return
  @throws KeyStoreException
  @throws NoSuchAlgorithmException
  @throws CertificateException
  @throws IOException
  @throws UnrecoverableEntryException