class BouncyCastleGpgKeyLocator
extends java.lang.Object
~/.gnupg/private-keys-v1.d
or
~/.gnupg/secring.gpg
Modifier and Type | Field and Description |
---|---|
private static java.nio.file.Path |
GPG_DIRECTORY |
private static org.slf4j.Logger |
log |
private BouncyCastleGpgKeyPassphrasePrompt |
passphrasePrompt |
private java.lang.String |
signingKey |
private static java.nio.file.Path |
USER_KEYBOX_PATH |
private static java.nio.file.Path |
USER_PGP_LEGACY_SECRING_FILE |
private static java.nio.file.Path |
USER_SECRET_KEY_DIR |
Constructor and Description |
---|
BouncyCastleGpgKeyLocator(java.lang.String signingKey,
BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt)
Create a new key locator for the specified signing key.
|
Modifier and Type | Method and Description |
---|---|
private org.bouncycastle.openpgp.PGPSecretKey |
attemptParseSecretKey(java.nio.file.Path keyFile,
org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider calculatorProvider,
org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory passphraseProvider,
org.bouncycastle.openpgp.PGPPublicKey publicKey) |
private boolean |
containsSigningKey(java.lang.String userId) |
private static java.nio.file.Path |
findGpgDirectory() |
private org.bouncycastle.openpgp.PGPPublicKey |
findPublicKeyByKeyId(org.bouncycastle.gpg.keybox.KeyBlob keyBlob) |
private org.bouncycastle.openpgp.PGPPublicKey |
findPublicKeyByUserId(org.bouncycastle.gpg.keybox.KeyBlob keyBlob) |
private org.bouncycastle.openpgp.PGPPublicKey |
findPublicKeyInKeyBox(java.nio.file.Path keyboxFile)
Finds a public key associated with the signing key.
|
BouncyCastleGpgKey |
findSecretKey()
Use pubring.kbx when available, if not fallback to secring.gpg or secret
key path provided to parse and return secret key
|
private BouncyCastleGpgKey |
findSecretKeyForKeyBoxPublicKey(org.bouncycastle.openpgp.PGPPublicKey publicKey,
java.nio.file.Path userKeyboxPath) |
private org.bouncycastle.openpgp.PGPSecretKey |
findSecretKeyInLegacySecring(java.lang.String signingkey,
java.nio.file.Path secringFile)
Return the first suitable key for signing in the key ring collection.
|
private org.bouncycastle.openpgp.PGPPublicKey |
getFirstPublicKey(org.bouncycastle.gpg.keybox.KeyBlob keyBlob) |
private org.bouncycastle.gpg.keybox.KeyBox |
readKeyBoxFile(java.nio.file.Path keyboxFile) |
private static final org.slf4j.Logger log
private static final java.nio.file.Path GPG_DIRECTORY
private static final java.nio.file.Path USER_KEYBOX_PATH
private static final java.nio.file.Path USER_SECRET_KEY_DIR
private static final java.nio.file.Path USER_PGP_LEGACY_SECRING_FILE
private final java.lang.String signingKey
private BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt
public BouncyCastleGpgKeyLocator(java.lang.String signingKey, @NonNull BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt)
The signing key must either be a hex representation of a specific key or a user identity substring (eg., email address). All keys in the KeyBox will be looked up in the order as returned by the KeyBox. A key id will be searched before attempting to find a key by user id.
signingKey
- the signing key to search forpassphrasePrompt
- the provider to use when asking for key passphraseprivate static java.nio.file.Path findGpgDirectory()
private org.bouncycastle.openpgp.PGPSecretKey attemptParseSecretKey(java.nio.file.Path keyFile, org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider calculatorProvider, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory passphraseProvider, org.bouncycastle.openpgp.PGPPublicKey publicKey)
private boolean containsSigningKey(java.lang.String userId)
private org.bouncycastle.openpgp.PGPPublicKey findPublicKeyByKeyId(org.bouncycastle.gpg.keybox.KeyBlob keyBlob) throws java.io.IOException
java.io.IOException
private org.bouncycastle.openpgp.PGPPublicKey findPublicKeyByUserId(org.bouncycastle.gpg.keybox.KeyBlob keyBlob) throws java.io.IOException
java.io.IOException
private org.bouncycastle.openpgp.PGPPublicKey findPublicKeyInKeyBox(java.nio.file.Path keyboxFile) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
keyboxFile
- the KeyBox filenull
)java.io.IOException
- in case of problems reading the filejava.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
public BouncyCastleGpgKey findSecretKey() throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, org.bouncycastle.openpgp.PGPException, CanceledException, UnsupportedCredentialItem, java.net.URISyntaxException
java.io.IOException
- in case of issues reading key filesjava.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
org.bouncycastle.openpgp.PGPException
- in case of issues finding a keyCanceledException
java.net.URISyntaxException
UnsupportedCredentialItem
private BouncyCastleGpgKey findSecretKeyForKeyBoxPublicKey(org.bouncycastle.openpgp.PGPPublicKey publicKey, java.nio.file.Path userKeyboxPath) throws org.bouncycastle.openpgp.PGPException, CanceledException, UnsupportedCredentialItem, java.net.URISyntaxException
org.bouncycastle.openpgp.PGPException
CanceledException
UnsupportedCredentialItem
java.net.URISyntaxException
private org.bouncycastle.openpgp.PGPSecretKey findSecretKeyInLegacySecring(java.lang.String signingkey, java.nio.file.Path secringFile) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
signingkey
- secringFile
- java.io.IOException
- on I/O related errorsorg.bouncycastle.openpgp.PGPException
- on BouncyCastle errorsprivate org.bouncycastle.openpgp.PGPPublicKey getFirstPublicKey(org.bouncycastle.gpg.keybox.KeyBlob keyBlob) throws java.io.IOException
java.io.IOException
private org.bouncycastle.gpg.keybox.KeyBox readKeyBoxFile(java.nio.file.Path keyboxFile) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException