Package org.eclipse.jgit.transport.sshd
Interface KeyPasswordProvider
-
- All Known Implementing Classes:
IdentityPasswordProvider
public interface KeyPasswordProvider
AKeyPasswordProvider
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. Returningnull
or an empty array will skip this key. To cancel completely, the operation should raiseCancellationException
.- Parameters:
uri
- identifying the key resource that is being attempted to be loadedattempt
- 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 originalerror
is lost unless it is attached to that exception.- Parameters:
uri
- identifying the key resource the key was attempted to be loaded fromattempt
- the number of timesgetPassphrase(URIish, int)
had been called; zero indicates thaturi
refers to a non-encrypted keyerror
-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 theerror
exception; Ignored if the key was loaded successfully, i.e., iferror == null
.- Throws:
IOException
GeneralSecurityException
-
-