Class BouncyCastleGpgSigner

java.lang.Object
org.eclipse.jgit.lib.GpgSigner
org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgSigner
All Implemented Interfaces:
GpgObjectSigner

public class BouncyCastleGpgSigner extends GpgSigner implements GpgObjectSigner
GPG Signer using the BouncyCastle library.
  • Constructor Details

    • BouncyCastleGpgSigner

      public BouncyCastleGpgSigner()
      Create a new instance.

      The BounceCastleProvider will be registered if necessary.

  • Method Details

    • canLocateSigningKey

      public boolean canLocateSigningKey(@Nullable String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider) throws CanceledException
      Description copied from class: GpgSigner
      Indicates if a signing key is available for the specified committer and/or signing key.
      Specified by:
      canLocateSigningKey in class GpgSigner
      Parameters:
      gpgSigningKey - the signing key to locate (passed as is to the GPG signing tool as is; eg., value of user.signingkey)
      committer - the signing identity (to help with key lookup in case signing key is not specified)
      credentialsProvider - provider to use when querying for signing key credentials (eg. passphrase)
      Returns:
      true if a signing key is available, false otherwise
      Throws:
      CanceledException - when signing was canceled (eg., user aborted when entering passphrase)
    • canLocateSigningKey

      public boolean canLocateSigningKey(@Nullable String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider, GpgConfig config) throws CanceledException, UnsupportedSigningFormatException
      Description copied from interface: GpgObjectSigner
      Indicates if a signing key is available for the specified committer and/or signing key.
      Specified by:
      canLocateSigningKey in interface GpgObjectSigner
      Parameters:
      gpgSigningKey - the signing key to locate (passed as is to the GPG signing tool as is; eg., value of user.signingkey)
      committer - the signing identity (to help with key lookup in case signing key is not specified)
      credentialsProvider - provider to use when querying for signing key credentials (eg. passphrase)
      config - GPG settings from the git config
      Returns:
      true if a signing key is available, false otherwise
      Throws:
      CanceledException - when signing was canceled (eg., user aborted when entering passphrase)
      UnsupportedSigningFormatException - if a config is given and the wanted key format is not supported
    • sign

      public void sign(@NonNull CommitBuilder commit, @Nullable String gpgSigningKey, @NonNull PersonIdent committer, CredentialsProvider credentialsProvider) throws CanceledException
      Description copied from class: GpgSigner
      Signs the specified commit.

      Implementors should obtain the payload for signing from the specified commit via CommitBuilder.build() and create a proper GpgSignature. The generated signature must be set on the specified commit (see ObjectBuilder.setGpgSignature(GpgSignature)).

      Any existing signature on the commit must be discarded prior obtaining the payload via CommitBuilder.build().

      Specified by:
      sign in class GpgSigner
      Parameters:
      commit - the commit to sign (must not be null and must be complete to allow proper calculation of payload)
      gpgSigningKey - the signing key to locate (passed as is to the GPG signing tool as is; eg., value of user.signingkey)
      committer - the signing identity (to help with key lookup in case signing key is not specified)
      credentialsProvider - provider to use when querying for signing key credentials (eg. passphrase)
      Throws:
      CanceledException - when signing was canceled (eg., user aborted when entering passphrase)
    • signObject

      public void signObject(@NonNull ObjectBuilder object, @Nullable String gpgSigningKey, @NonNull PersonIdent committer, CredentialsProvider credentialsProvider, GpgConfig config) throws CanceledException, UnsupportedSigningFormatException
      Description copied from interface: GpgObjectSigner
      Signs the specified object.

      Implementors should obtain the payload for signing from the specified object via ObjectBuilder.build() and create a proper GpgSignature. The generated signature must be set on the specified object (see ObjectBuilder.setGpgSignature(GpgSignature)).

      Any existing signature on the object must be discarded prior obtaining the payload via ObjectBuilder.build().

      Specified by:
      signObject in interface GpgObjectSigner
      Parameters:
      object - the object to sign (must not be null and must be complete to allow proper calculation of payload)
      gpgSigningKey - the signing key to locate (passed as is to the GPG signing tool as is; eg., value of user.signingkey)
      committer - the signing identity (to help with key lookup in case signing key is not specified)
      credentialsProvider - provider to use when querying for signing key credentials (eg. passphrase)
      config - GPG settings from the git config
      Throws:
      CanceledException - when signing was canceled (eg., user aborted when entering passphrase)
      UnsupportedSigningFormatException - if a config is given and the wanted key format is not supported