public class BouncyCastleGpgSigner extends GpgSigner
Constructor and Description |
---|
BouncyCastleGpgSigner()
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
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.
|
private BouncyCastleGpgKey |
locateSigningKey(java.lang.String gpgSigningKey,
PersonIdent committer,
BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt) |
private static void |
registerBouncyCastleProviderIfNecessary() |
void |
sign(CommitBuilder commit,
java.lang.String gpgSigningKey,
PersonIdent committer,
CredentialsProvider credentialsProvider)
Signs the specified commit.
|
getDefault, setDefault
public BouncyCastleGpgSigner()
The BounceCastleProvider will be registered if necessary.
private static void registerBouncyCastleProviderIfNecessary()
public boolean canLocateSigningKey(@Nullable java.lang.String gpgSigningKey, PersonIdent committer, CredentialsProvider credentialsProvider) throws CanceledException
GpgSigner
canLocateSigningKey
in class GpgSigner
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)true
if a signing key is available,
false
otherwiseCanceledException
- when signing was canceled (eg., user aborted when entering
passphrase)private BouncyCastleGpgKey locateSigningKey(@Nullable java.lang.String gpgSigningKey, PersonIdent committer, BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt) throws CanceledException, UnsupportedCredentialItem, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, org.bouncycastle.openpgp.PGPException, java.net.URISyntaxException
CanceledException
UnsupportedCredentialItem
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
org.bouncycastle.openpgp.PGPException
java.net.URISyntaxException
public void sign(@NonNull CommitBuilder commit, @Nullable java.lang.String gpgSigningKey, @NonNull PersonIdent committer, CredentialsProvider credentialsProvider) throws CanceledException
GpgSigner
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
CommitBuilder.setGpgSignature(GpgSignature)
).
Any existing signature on the commit must be discarded prior obtaining
the payload via CommitBuilder.build()
.
sign
in class GpgSigner
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)CanceledException
- when signing was canceled (eg., user aborted when entering
passphrase)