Class BouncyCastleGpgKeyLocator

java.lang.Object
org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgKeyLocator

public class BouncyCastleGpgKeyLocator extends Object
Locates GPG keys from either ~/.gnupg/private-keys-v1.d or ~/.gnupg/secring.gpg
  • Constructor Summary

    Constructors
    Constructor
    Description
    BouncyCastleGpgKeyLocator(String signingKey, org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt)
    Create a new key locator for the specified signing key.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgKey
    If there is a private key directory containing keys, use pubring.kbx or pubring.gpg to find the public key; then try to find the secret key in the directory.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BouncyCastleGpgKeyLocator

      public BouncyCastleGpgKeyLocator(String signingKey, @NonNull org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt)
      Create a new key locator for the specified signing key.

      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.

      Parameters:
      signingKey - the signing key to search for
      passphrasePrompt - the provider to use when asking for key passphrase
  • Method Details

    • findSecretKey

      @NonNull public org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgKey findSecretKey() throws IOException, NoSuchAlgorithmException, NoSuchProviderException, org.bouncycastle.openpgp.PGPException, org.eclipse.jgit.api.errors.CanceledException, org.eclipse.jgit.errors.UnsupportedCredentialItem, URISyntaxException
      If there is a private key directory containing keys, use pubring.kbx or pubring.gpg to find the public key; then try to find the secret key in the directory.

      If there is no private key directory (or it doesn't contain any keys), try to find the key in secring.gpg directly.

      Returns:
      the secret key
      Throws:
      IOException - in case of issues reading key files
      NoSuchAlgorithmException - algorithm is not available
      NoSuchProviderException - provider is not available
      org.bouncycastle.openpgp.PGPException - in case of issues finding a key, including no key found
      org.eclipse.jgit.api.errors.CanceledException - operation was cancelled
      URISyntaxException - URI is invalid
      org.eclipse.jgit.errors.UnsupportedCredentialItem - credential item is not supported