Package org.eclipse.jgit.lib
Class GpgSigner
- java.lang.Object
-
- org.eclipse.jgit.lib.GpgSigner
-
- Direct Known Subclasses:
BouncyCastleGpgSigner
public abstract class GpgSigner extends java.lang.Object
Creates GPG signatures for Git objects.- Since:
- 5.3
-
-
Field Summary
Fields Modifier and Type Field Description private static GpgSigner
defaultSigner
private static org.slf4j.Logger
LOG
-
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(java.lang.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
.private static GpgSigner
loadGpgSigner()
static void
setDefault(GpgSigner signer)
Set the default signer.abstract void
sign(CommitBuilder commit, java.lang.String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider)
Signs the specified commit.
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
defaultSigner
private static GpgSigner defaultSigner
-
-
Method Detail
-
loadGpgSigner
private static GpgSigner loadGpgSigner()
-
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 java.lang.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 java.lang.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)
-
-