Interface KeyPasswordProvider

  • All Known Implementing Classes:
    IdentityPasswordProvider

    public interface KeyPasswordProvider
    A KeyPasswordProvider provides passwords for encrypted private keys.
    Since:
    5.2
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default int getAttempts()
      Gets the maximum number of attempts to get a passphrase that should be attempted for one identity resource through this provider.
      char[] getPassphrase​(URIish uri, int attempt)
      Obtains a passphrase to use to decrypt an ecrypted private key.
      boolean keyLoaded​(URIish uri, int attempt, Exception error)
      Invoked after a key has been loaded.
      void setAttempts​(int maxNumberOfAttempts)
      Define the maximum number of attempts to get a passphrase that should be attempted for one identity resource through this provider.
    • Method Detail

      • getPassphrase

        char[] getPassphrase​(URIish uri,
                             int attempt)
                      throws IOException
        Obtains a passphrase to use to decrypt an ecrypted private key. Returning null or an empty array will skip this key. To cancel completely, the operation should raise CancellationException.
        Parameters:
        uri - identifying the key resource that is being attempted to be loaded
        attempt - the number of previous attempts to get a passphrase; >= 0
        Returns:
        the passphrase
        Throws:
        IOException - if no password can be obtained
      • setAttempts

        void setAttempts​(int maxNumberOfAttempts)
        Define the maximum number of attempts to get a passphrase that should be attempted for one identity resource through this provider.
        Parameters:
        maxNumberOfAttempts - number of times to ask for a passphrase; IllegalArgumentException may be thrown if <= 0
      • getAttempts

        default int getAttempts()
        Gets the maximum number of attempts to get a passphrase that should be attempted for one identity resource through this provider. The default return 1.
        Returns:
        the number of times to ask for a passphrase; should be >= 1.
      • keyLoaded

        boolean keyLoaded​(URIish uri,
                          int attempt,
                          Exception error)
                   throws IOException,
                          GeneralSecurityException
        Invoked after a key has been loaded. If this raises an exception, the original error is lost unless it is attached to that exception.
        Parameters:
        uri - identifying the key resource the key was attempted to be loaded from
        attempt - the number of times getPassphrase(URIish, int) had been called; zero indicates that uri refers to a non-encrypted key
        error - null if the key was loaded successfully; otherwise an exception indicating why the key could not be loaded
        Returns:
        true to re-try again; false to re-raise the error exception; Ignored if the key was loaded successfully, i.e., if error == null.
        Throws:
        IOException
        GeneralSecurityException