Class BouncyCastleGpgKeyPassphrasePrompt

java.lang.Object
org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgKeyPassphrasePrompt
All Implemented Interfaces:
AutoCloseable

class BouncyCastleGpgKeyPassphrasePrompt extends Object implements AutoCloseable
Prompts for a passphrase and caches it until cleared.

Implements AutoCloseable so it can be used within a try-with-resources block.

  • Field Details

  • Constructor Details

    • BouncyCastleGpgKeyPassphrasePrompt

      public BouncyCastleGpgKeyPassphrasePrompt(CredentialsProvider credentialsProvider)
  • Method Details

    • clear

      public void clear()
      Clears any cached passphrase
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • createURI

      private URIish createURI(Path keyLocation) throws URISyntaxException
      Throws:
      URISyntaxException
    • getPassphrase

      public char[] getPassphrase(byte[] keyFingerprint, Path keyLocation) throws org.bouncycastle.openpgp.PGPException, CanceledException, UnsupportedCredentialItem, URISyntaxException
      Prompts use for a passphrase unless one was cached from a previous prompt.
      Parameters:
      keyFingerprint - the fingerprint to show to the user during prompting
      keyLocation - the location the key was loaded from
      Returns:
      the passphrase (maybe null)
      Throws:
      org.bouncycastle.openpgp.PGPException
      CanceledException - in case passphrase was not entered by user
      URISyntaxException
      UnsupportedCredentialItem
    • hasPassphrase

      public boolean hasPassphrase()
      Determines whether a passphrase was already obtained.
      Returns:
      true if a passphrase is already set, false otherwise