Class BouncyCastleGpgKeyPassphrasePrompt

  • All Implemented Interfaces:
    java.lang.AutoCloseable

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

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

    • Constructor Detail

      • BouncyCastleGpgKeyPassphrasePrompt

        public BouncyCastleGpgKeyPassphrasePrompt​(CredentialsProvider credentialsProvider)
    • Method Detail

      • clear

        public void clear()
        Clears any cached passphrase
      • close

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

        private URIish createURI​(java.nio.file.Path keyLocation)
                          throws java.net.URISyntaxException
        Throws:
        java.net.URISyntaxException
      • getPassphrase

        public char[] getPassphrase​(byte[] keyFingerprint,
                                    java.nio.file.Path keyLocation)
                             throws org.bouncycastle.openpgp.PGPException,
                                    CanceledException,
                                    UnsupportedCredentialItem,
                                    java.net.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
        java.net.URISyntaxException
        UnsupportedCredentialItem
      • hasPassphrase

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