Package org.eclipse.jgit.transport.sshd
Interface KeyPasswordProvider
-
- All Known Implementing Classes:
IdentityPasswordProvider
public interface KeyPasswordProviderAKeyPasswordProviderprovides passwords for encrypted private keys.- Since:
- 5.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intgetAttempts()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.booleankeyLoaded(URIish uri, int attempt, Exception error)Invoked after a key has been loaded.voidsetAttempts(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. Returningnullor 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;IllegalArgumentExceptionmay 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 originalerroris 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 thaturirefers to a non-encrypted keyerror-nullif the key was loaded successfully; otherwise an exception indicating why the key could not be loaded- Returns:
trueto re-try again;falseto re-raise theerrorexception; Ignored if the key was loaded successfully, i.e., iferror == null.- Throws:
IOExceptionGeneralSecurityException
-
-