code: public static PrivateKey readPasswordProtectedPrivateKey(final File encryptedPrivateKeyFile,
  		final String password, final String algorithm)
  		throws IOException, NoSuchAlgorithmException, NoSuchPaddingException,
  		InvalidKeySpecException, InvalidKeyException, InvalidAlgorithmParameterException
  	{
  		byte[] encryptedPrivateKeyBytes = null;
  		boolean pemFormat = PrivateKeyReader.isPemFormat(encryptedPrivateKeyFile);
  		if (pemFormat)
  		{
  			KeyPair keyPair = getKeyPair(encryptedPrivateKeyFile, password);
  			if (keyPair != null)
  			{
  				return keyPair.getPrivate();
  			}
  		}
  		else
  		{
  			encryptedPrivateKeyBytes = Files.readAllBytes(encryptedPrivateKeyFile.toPath());
  			return readPasswordProtectedPrivateKey(encryptedPrivateKeyBytes, password, algorithm);
  		}
  		return null;
  	}
docs: Reads from the given {@link File} that contains the password protected private key and
  returns it
  
  @param encryptedPrivateKeyFile
  the file that contains the password protected private key
  @param password
  the password
  @param algorithm
  the algorithm
  @return the {@link PrivateKey} object
  @throws IOException
  Signals that an I/O exception has occurred.
  @throws NoSuchAlgorithmException
  is thrown if instantiation of the SecretKeyFactory object fails.
  @throws NoSuchPaddingException
  the no such padding exception
  @throws InvalidKeySpecException
  is thrown if generation of the SecretKey object fails.
  @throws InvalidKeyException
  is thrown if initialization of the cipher object fails.
  @throws InvalidAlgorithmParameterException
  is thrown if initialization of the cipher object fails.