Top Description Methods
org.eclipse.jgit.transport.sshd

public Interface KeyPasswordProvider

Known Direct Implementers
org.eclipse.jgit.transport.sshd.IdentityPasswordProvider
Imports
java.io.IOException, java.security.GeneralSecurityException, org.eclipse.jgit.transport.URIish

A KeyPasswordProvider provides passwords for encrypted private keys.
Since
5.2

Method Summary

Modifier and TypeMethod and Description
public default int

Returns:

the number of times to ask for a passphrase; should be >= 1.
getAttempts
()

Gets the maximum number of attempts to get a passphrase that should be attempted for one identity resource through this provider.

public char[]

Returns:

the passphrase
getPassphrase
(URIish
identifying the key resource that is being attempted to be loaded
uri
,
int
the number of previous attempts to get a passphrase; >= 0
attempt
)

Obtains a passphrase to use to decrypt an ecrypted private key.

public boolean

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.
keyLoaded
(URIish
identifying the key resource the key was attempted to be loaded from
uri
,
int
the number of times getPassphrase(URIish, int) had been called; zero indicates that uri refers to a non-encrypted key
attempt
,
Exception
null if the key was loaded successfully; otherwise an exception indicating why the key could not be loaded
error
)

Invoked after a key has been loaded.

public void
setAttempts(int
number of times to ask for a passphrase; IllegalArgumentException may be thrown if <= 0
maxNumberOfAttempts
)

Define the maximum number of attempts to get a passphrase that should be attempted for one identity resource through this provider.

Method Detail

getAttemptsback to summary
public 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:int

the number of times to ask for a passphrase; should be >= 1.

getPassphraseback to summary
public 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 java.util.concurrent.CancellationException.

Parameters
uri:URIish

identifying the key resource that is being attempted to be loaded

attempt:int

the number of previous attempts to get a passphrase; >= 0

Returns:char[]

the passphrase

Exceptions
IOException:
if no password can be obtained
keyLoadedback to summary
public 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:URIish

identifying the key resource the key was attempted to be loaded from

attempt:int

the number of times getPassphrase(URIish, int) had been called; zero indicates that uri refers to a non-encrypted key

error:Exception

null if the key was loaded successfully; otherwise an exception indicating why the key could not be loaded

Returns:boolean

true to re-try again; false to re-raise the error exception; Ignored if the key was loaded successfully, i.e., if error == null.

Exceptions
IOException:
if an IO error occurred
GeneralSecurityException:
something went wrong
setAttemptsback to summary
public 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:int

number of times to ask for a passphrase; IllegalArgumentException may be thrown if <= 0