Package org.eclipse.jgit.lib
Class GpgSigner
- java.lang.Object
-
- org.eclipse.jgit.lib.GpgSigner
-
- Direct Known Subclasses:
BouncyCastleGpgSigner
public abstract class GpgSigner extends Object
Creates GPG signatures for Git objects.- Since:
- 5.3
-
-
Constructor Summary
Constructors Constructor Description GpgSigner()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
canLocateSigningKey(String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider)
Indicates if a signing key is available for the specified committer and/or signing key.static GpgSigner
getDefault()
Get the default signer, ornull
.static void
setDefault(GpgSigner signer)
Set the default signer.abstract void
sign(CommitBuilder commit, String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider)
Signs the specified commit.
-
-
-
Method Detail
-
getDefault
public static GpgSigner getDefault()
Get the default signer, ornull
.- Returns:
- the default signer, or
null
.
-
setDefault
public static void setDefault(GpgSigner signer)
Set the default signer.- Parameters:
signer
- the new default signer, may benull
to select no default.
-
sign
public abstract void sign(@NonNull CommitBuilder commit, @Nullable String gpgSigningKey, @NonNull PersonIdent committer, CredentialsProvider credentialsProvider) throws CanceledException
Signs the specified commit.Implementors should obtain the payload for signing from the specified commit via
CommitBuilder.build()
and create a properGpgSignature
. The generated signature must be set on the specifiedcommit
(seeObjectBuilder.setGpgSignature(GpgSignature)
).Any existing signature on the commit must be discarded prior obtaining the payload via
CommitBuilder.build()
.- Parameters:
commit
- the commit to sign (must not benull
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 ofuser.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)
-
canLocateSigningKey
public abstract boolean canLocateSigningKey(@Nullable String gpgSigningKey, @NonNull PersonIdent committer, CredentialsProvider credentialsProvider) throws CanceledException
Indicates if a signing key is available for the specified committer and/or signing key.- Parameters:
gpgSigningKey
- the signing key to locate (passed as is to the GPG signing tool as is; eg., value ofuser.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)
-
-