Class BouncyCastleGpgSigner
- All Implemented Interfaces:
GpgObjectSigner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanLocateSigningKey(String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider) Indicates if a signing key is available for the specified committer and/or signing key.booleancanLocateSigningKey(String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider, GpgConfig config) Indicates if a signing key is available for the specified committer and/or signing key.(package private) static StringextractSignerId(String pgpUserId) private BouncyCastleGpgKeylocateSigningKey(String gpgSigningKey, PersonIdent committer, BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt) private static voidvoidsign(CommitBuilder commit, String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider) Signs the specified commit.voidsignObject(ObjectBuilder object, String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider, GpgConfig config) Signs the specified object.Methods inherited from class org.eclipse.jgit.lib.GpgSigner
getDefault, setDefault
-
Constructor Details
-
BouncyCastleGpgSigner
public BouncyCastleGpgSigner()Create a new instance.The BounceCastleProvider will be registered if necessary.
-
-
Method Details
-
registerBouncyCastleProviderIfNecessary
private static void registerBouncyCastleProviderIfNecessary() -
canLocateSigningKey
public boolean canLocateSigningKey(@Nullable String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider) throws CanceledException Description copied from class:GpgSignerIndicates if a signing key is available for the specified committer and/or signing key.- Specified by:
canLocateSigningKeyin classGpgSigner- 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)
-
canLocateSigningKey
public boolean canLocateSigningKey(@Nullable String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider, GpgConfig config) throws CanceledException, UnsupportedSigningFormatException Description copied from interface:GpgObjectSignerIndicates if a signing key is available for the specified committer and/or signing key.- Specified by:
canLocateSigningKeyin interfaceGpgObjectSigner- 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)config- GPG settings from the git config- Returns:
trueif a signing key is available,falseotherwise- 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
-
locateSigningKey
private BouncyCastleGpgKey locateSigningKey(@Nullable String gpgSigningKey, PersonIdent committer, BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt) throws CanceledException, UnsupportedCredentialItem, IOException, NoSuchAlgorithmException, NoSuchProviderException, org.bouncycastle.openpgp.PGPException, URISyntaxException - Throws:
CanceledExceptionUnsupportedCredentialItemIOExceptionNoSuchAlgorithmExceptionNoSuchProviderExceptionorg.bouncycastle.openpgp.PGPExceptionURISyntaxException
-
sign
public void sign(@NonNull CommitBuilder commit, @Nullable String gpgSigningKey, @NonNull PersonIdent committer, CredentialsProvider credentialsProvider) throws CanceledException Description copied from class:GpgSignerSigns 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().- Specified by:
signin classGpgSigner- 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)
-
signObject
public void signObject(@NonNull ObjectBuilder object, @Nullable String gpgSigningKey, @NonNull PersonIdent committer, CredentialsProvider credentialsProvider, GpgConfig config) throws CanceledException, UnsupportedSigningFormatException Description copied from interface:GpgObjectSignerSigns the specified object.Implementors should obtain the payload for signing from the specified object via
ObjectBuilder.build()and create a properGpgSignature. The generated signature must be set on the specifiedobject(seeObjectBuilder.setGpgSignature(GpgSignature)).Any existing signature on the object must be discarded prior obtaining the payload via
ObjectBuilder.build().- Specified by:
signObjectin interfaceGpgObjectSigner- Parameters:
object- the object 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)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
-
extractSignerId
-