Package org.eclipse.jgit.gpg.bc.internal
Class BouncyCastleGpgKeyPassphrasePrompt
- java.lang.Object
-
- org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgKeyPassphrasePrompt
-
- All Implemented Interfaces:
java.lang.AutoCloseable
class BouncyCastleGpgKeyPassphrasePrompt extends java.lang.Object implements java.lang.AutoCloseable
Prompts for a passphrase and caches it untilcleared
.Implements
AutoCloseable
so it can be used within a try-with-resources block.
-
-
Field Summary
Fields Modifier and Type Field Description private CredentialsProvider
credentialsProvider
private CredentialItem.CharArrayType
passphrase
-
Constructor Summary
Constructors Constructor Description BouncyCastleGpgKeyPassphrasePrompt(CredentialsProvider credentialsProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears any cached passphrasevoid
close()
private URIish
createURI(java.nio.file.Path keyLocation)
char[]
getPassphrase(byte[] keyFingerprint, java.nio.file.Path keyLocation)
Prompts use for a passphrase unless one was cached from a previous prompt.boolean
hasPassphrase()
Determines whether a passphrase was already obtained.
-
-
-
Field Detail
-
passphrase
private CredentialItem.CharArrayType passphrase
-
credentialsProvider
private CredentialsProvider credentialsProvider
-
-
Constructor Detail
-
BouncyCastleGpgKeyPassphrasePrompt
public BouncyCastleGpgKeyPassphrasePrompt(CredentialsProvider credentialsProvider)
-
-
Method Detail
-
clear
public void clear()
Clears any cached passphrase
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
createURI
private URIish createURI(java.nio.file.Path keyLocation) throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
getPassphrase
public char[] getPassphrase(byte[] keyFingerprint, java.nio.file.Path keyLocation) throws org.bouncycastle.openpgp.PGPException, CanceledException, UnsupportedCredentialItem, java.net.URISyntaxException
Prompts use for a passphrase unless one was cached from a previous prompt.- Parameters:
keyFingerprint
- the fingerprint to show to the user during promptingkeyLocation
- the location the key was loaded from- Returns:
- the passphrase (maybe
null
) - Throws:
org.bouncycastle.openpgp.PGPException
CanceledException
- in case passphrase was not entered by userjava.net.URISyntaxException
UnsupportedCredentialItem
-
hasPassphrase
public boolean hasPassphrase()
Determines whether a passphrase was already obtained.- Returns:
true
if a passphrase is already set,false
otherwise
-
-