code: public static boolean checkPassPhrase(File keyFilePath, String passPhrase) {
          KeyPair key = parsePrivateKeyFile(keyFilePath);
          boolean isValidPhrase = passPhrase != null && !passPhrase.trim().isEmpty();
          if (key == null) {
              return false;
          } else if (key.isEncrypted() != isValidPhrase) {
              return false;
          } else if (key.isEncrypted()) {
              return key.decrypt(passPhrase);
          }
          return true;
      }
docs: Checks to see if the passPhrase is valid for the private key file.
  @param keyFilePath the private key file.
  @param passPhrase the password for the file.
  @return true if it is valid.