Package org.eclipse.jgit.lib
Class GpgSigner
java.lang.Object
org.eclipse.jgit.lib.GpgSigner
- Direct Known Subclasses:
BouncyCastleGpgSigner
Creates GPG signatures for Git objects.
- Since:
- 5.3
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancanLocateSigningKey(String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider) Indicates if a signing key is available for the specified committer and/or signing key.static GpgSignerGet the default signer, ornull.private static GpgSignerstatic voidsetDefault(GpgSigner signer) Set the default signer.abstract voidsign(CommitBuilder commit, String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider) Signs the specified commit.
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
defaultSigner
-
-
Constructor Details
-
GpgSigner
public GpgSigner()
-
-
Method Details
-
loadGpgSigner
-
getDefault
Get the default signer, ornull.- Returns:
- the default signer, or
null.
-
setDefault
Set the default signer.- Parameters:
signer- the new default signer, may benullto 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 benulland 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:
trueif a signing key is available,falseotherwise- Throws:
CanceledException- when signing was canceled (eg., user aborted when entering passphrase)
-