Package org.eclipse.jgit.gpg.bc.internal
Class BouncyCastleGpgSignatureVerifier
- java.lang.Object
-
- org.eclipse.jgit.gpg.bc.internal.BouncyCastleGpgSignatureVerifier
-
- All Implemented Interfaces:
GpgSignatureVerifier
public class BouncyCastleGpgSignatureVerifier extends java.lang.Object implements GpgSignatureVerifier
AGpgSignatureVerifier
to verify GPG signatures using BouncyCastle.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
BouncyCastleGpgSignatureVerifier.VerificationResult
-
Nested classes/interfaces inherited from interface org.eclipse.jgit.lib.GpgSignatureVerifier
GpgSignatureVerifier.SignatureVerification, GpgSignatureVerifier.TrustLevel
-
-
Field Summary
Fields Modifier and Type Field Description private LRUMap<java.lang.String,java.lang.Object>
byFingerprint
private LRUMap<java.lang.String,java.lang.Object>
bySigner
private static java.lang.Object
NO_KEY
-
Constructor Summary
Constructors Constructor Description BouncyCastleGpgSignatureVerifier()
Creates a new instance and registers the BouncyCastle security provider if needed.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
AGpgSignatureVerifier
may cache public keys to speed up verifying signatures on multiple objects.java.lang.String
getName()
Retrieves the name of this verifier.private GpgSignatureVerifier.TrustLevel
parseGpgTrustPacket(byte[] packet)
(package private) static org.bouncycastle.openpgp.PGPSignature
parseSignature(java.io.InputStream in)
private static void
registerBouncyCastleProviderIfNecessary()
GpgSignatureVerifier.SignatureVerification
verify(byte[] data, byte[] signatureData)
Verifies a given signature for given data.GpgSignatureVerifier.SignatureVerification
verifySignature(RevObject object, GpgConfig config)
Verifies the signature on a signed commit or tag.
-
-
-
Method Detail
-
registerBouncyCastleProviderIfNecessary
private static void registerBouncyCastleProviderIfNecessary()
-
getName
public java.lang.String getName()
Description copied from interface:GpgSignatureVerifier
Retrieves the name of this verifier. This should be a short string identifying the engine that verified the signature, like "gpg" if GPG is used, or "bc" for a BouncyCastle implementation.- Specified by:
getName
in interfaceGpgSignatureVerifier
- Returns:
- the name
-
verifySignature
@Nullable public GpgSignatureVerifier.SignatureVerification verifySignature(@NonNull RevObject object, @NonNull GpgConfig config) throws java.io.IOException
Description copied from interface:GpgSignatureVerifier
Verifies the signature on a signed commit or tag.- Specified by:
verifySignature
in interfaceGpgSignatureVerifier
- Parameters:
object
- to verifyconfig
- theGpgConfig
to use- Returns:
- a
GpgSignatureVerifier.SignatureVerification
describing the outcome of the verification, ornull
if the object was not signed - Throws:
java.io.IOException
- if an error occurs getting a public key
-
parseSignature
static org.bouncycastle.openpgp.PGPSignature parseSignature(java.io.InputStream in) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
- Throws:
java.io.IOException
org.bouncycastle.openpgp.PGPException
-
verify
public GpgSignatureVerifier.SignatureVerification verify(byte[] data, byte[] signatureData) throws java.io.IOException
Description copied from interface:GpgSignatureVerifier
Verifies a given signature for given data.- Specified by:
verify
in interfaceGpgSignatureVerifier
- Parameters:
data
- the signature is forsignatureData
- the ASCII-armored signature- Returns:
- a
GpgSignatureVerifier.SignatureVerification
describing the outcome - Throws:
java.io.IOException
- if the signature cannot be parsed
-
parseGpgTrustPacket
private GpgSignatureVerifier.TrustLevel parseGpgTrustPacket(byte[] packet)
-
clear
public void clear()
Description copied from interface:GpgSignatureVerifier
AGpgSignatureVerifier
may cache public keys to speed up verifying signatures on multiple objects. This clears this cache, if any.- Specified by:
clear
in interfaceGpgSignatureVerifier
-
-