public class IdentityPasswordProvider extends Object implements KeyPasswordProvider
KeyPasswordProvider based on a CredentialsProvider.| Modifier and Type | Class and Description |
|---|---|
protected static class |
IdentityPasswordProvider.State
A simple state object for repeated attempts to get a password for a
resource.
|
| Constructor and Description |
|---|
IdentityPasswordProvider(CredentialsProvider provider)
Creates a new
IdentityPasswordProvider to get the passphrase for
an encrypted identity. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected char[] |
getPassword(URIish uri,
int attempt,
IdentityPasswordProvider.State state)
Retrieves a password to decrypt a private key.
|
protected boolean |
keyLoaded(URIish uri,
IdentityPasswordProvider.State state,
char[] password,
Exception err)
Invoked to inform the password provider about the decoding result.
|
boolean |
keyLoaded(URIish uri,
int attempt,
Exception error)
Invoked after a key has been loaded.
|
void |
setAttempts(int numberOfPasswordPrompts)
Define the maximum number of attempts to get a passphrase that should be
attempted for one identity resource through this provider.
|
public IdentityPasswordProvider(CredentialsProvider provider)
IdentityPasswordProvider to get the passphrase for
an encrypted identity.provider - to usepublic void setAttempts(int numberOfPasswordPrompts)
KeyPasswordProvidersetAttempts in interface KeyPasswordProvidernumberOfPasswordPrompts - number of times to ask for a passphrase;
IllegalArgumentException may be thrown if <= 0public int getAttempts()
KeyPasswordProvidergetAttempts in interface KeyPasswordProviderpublic char[] getPassphrase(URIish uri, int attempt) throws IOException
KeyPasswordProvidernull or an empty array will skip this key. To cancel completely,
the operation should raise
CancellationException.getPassphrase in interface KeyPasswordProvideruri - identifying the key resource that is being attempted to be
loadedattempt - the number of previous attempts to get a passphrase; >= 0IOException - if no password can be obtainedprotected char[] getPassword(URIish uri, int attempt, @NonNull IdentityPasswordProvider.State state) throws IOException
uri - identifying the resource to obtain a password forattempt - number of previous attempts to get a passphrasestate - encapsulating state information about attempts to get the
passwordnull or the empty string if none
available.IOException - if an error occursprotected boolean keyLoaded(URIish uri, IdentityPasswordProvider.State state, char[] password, Exception err) throws IOException, GeneralSecurityException
uri - identifying the key resource the key was attempted to be
loaded fromstate - associated with this keypassword - the password that was attemptederr - the attempt result - null for successIOExceptionGeneralSecurityExceptionpublic boolean keyLoaded(URIish uri, int attempt, Exception error) throws IOException, GeneralSecurityException
KeyPasswordProvidererror is lost unless it is attached to that exception.keyLoaded in interface KeyPasswordProvideruri - identifying the key resource the key was attempted to be
loaded fromattempt - the number of times KeyPasswordProvider.getPassphrase(URIish, int) had
been called; zero indicates that uri refers to a
non-encrypted keyerror - null if the key was loaded successfully; otherwise an
exception indicating why the key could not be loadedtrue to re-try again; false to re-raise the
error exception; Ignored if the key was loaded
successfully, i.e., if error == null.IOExceptionGeneralSecurityExceptionCopyright © 2019 Eclipse JGit Project. All rights reserved.