Top Description Fields Constructors Methods
org.eclipse.jgit.lib

public final Class SignatureVerifiers

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.charset.StandardCharsets, java.text.MessageFormat, java.util.Arrays, .EnumMap, .Map, .ServiceConfigurationError, .ServiceLoader, java.util.concurrent.ConcurrentHashMap, org.eclipse.jgit.annotations.NonNull, .Nullable, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.revwalk.RevCommit, .RevObject, .RevTag, org.eclipse.jgit.util.RawParseUtils, org.slf4j.Logger, .LoggerFactory

Manages the available signers.
Since
7.0

Field Summary

Modifier and TypeField and Description
private static final Map<GpgConfig.GpgFormat, SignatureVerifierFactory>
private static final Logger
private static final byte[]
private static final byte[]
private static final Map<GpgConfig.GpgFormat, SignatureVerifier>
private static final byte[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SignatureVerifier

Returns:

a Signer, or null if none is available
get
(GpgConfig.GpgFormat
GpgConfig.GpgFormat the signer must support
format
)

Retrieves a Signer that can produce signatures of the given type format.

public static GpgConfig.GpgFormat

Returns:

the signature type, or null if unknown
getFormat
(byte[]
to get the type of
signature
)

Determines the type of a given signature.

private static Map<GpgConfig.GpgFormat, SignatureVerifierFactory>
public static void
set(GpgConfig.GpgFormat
signature type to set the verifier for
format
,
SignatureVerifier
the SignatureVerifier to use for signatures of type format; if null, a default implementation, if available, may be used.
verifier
)

Sets a specific signature verifier to use for a specific signature type.

public static SignatureVerifier.SignatureVerification

Returns:

a SignatureVerifier.SignatureVerification describing the outcome of the verification, or null if the object does not have a signature of a known type
verify
(Repository
the Repository the object is from
repository
,
GpgConfig
the GpgConfig to use
config
,
RevObject
to verify
object
)

Verifies the signature on a signed commit or tag.

public static SignatureVerifier.SignatureVerification

Returns:

a SignatureVerifier.SignatureVerification describing the outcome of the verification, or null if the signature type is unknown
verify
(Repository
the Repository the object is from
repository
,
GpgConfig
the GpgConfig to use
config
,
byte[]
to verify the signature of
data
,
byte[]
the given signature of the data
signature
)

Verifies a given signature for some give data.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FACTORIESback to summary
private static final Map<GpgConfig.GpgFormat, SignatureVerifierFactory> FACTORIES
LOGback to summary
private static final Logger LOG
PGP_PREFIXback to summary
private static final byte[] PGP_PREFIX
SSH_PREFIXback to summary
private static final byte[] SSH_PREFIX
VERIFIERSback to summary
private static final Map<GpgConfig.GpgFormat, SignatureVerifier> VERIFIERS
X509_PREFIXback to summary
private static final byte[] X509_PREFIX

Constructor Detail

SignatureVerifiersback to summary
private SignatureVerifiers()

Method Detail

getback to summary
public static SignatureVerifier get(GpgConfig.GpgFormat format)

Retrieves a Signer that can produce signatures of the given type format.

Parameters
format:GpgConfig.GpgFormat

GpgConfig.GpgFormat the signer must support

Returns:SignatureVerifier

a Signer, or null if none is available

getFormatback to summary
public static GpgConfig.GpgFormat getFormat(byte[] signature)

Determines the type of a given signature.

Parameters
signature:byte[]

to get the type of

Returns:GpgConfig.GpgFormat

the signature type, or null if unknown

Annotations
@Nullable
loadSignatureVerifiersback to summary
private static Map<GpgConfig.GpgFormat, SignatureVerifierFactory> loadSignatureVerifiers()
setback to summary
public static void set(GpgConfig.GpgFormat format, SignatureVerifier verifier)

Sets a specific signature verifier to use for a specific signature type.

Parameters
format:GpgConfig.GpgFormat

signature type to set the verifier for

verifier:SignatureVerifier

the SignatureVerifier to use for signatures of type format; if null, a default implementation, if available, may be used.

verifyback to summary
public static SignatureVerifier.SignatureVerification verify(Repository repository, GpgConfig config, RevObject object) throws IOException

Verifies the signature on a signed commit or tag.

Parameters
repository:Repository

the Repository the object is from

config:GpgConfig

the GpgConfig to use

object:RevObject

to verify

Returns:SignatureVerifier.SignatureVerification

a SignatureVerifier.SignatureVerification describing the outcome of the verification, or null if the object does not have a signature of a known type

Annotations
@Nullable
Exceptions
IOException:
if an error occurs getting a public key
JGitInternalException:
if signature verification fails
verifyback to summary
public static SignatureVerifier.SignatureVerification verify(Repository repository, GpgConfig config, byte[] data, byte[] signature) throws IOException

Verifies a given signature for some give data.

Parameters
repository:Repository

the Repository the object is from

config:GpgConfig

the GpgConfig to use

data:byte[]

to verify the signature of

signature:byte[]

the given signature of the data

Returns:SignatureVerifier.SignatureVerification

a SignatureVerifier.SignatureVerification describing the outcome of the verification, or null if the signature type is unknown

Annotations
@Nullable
Exceptions
IOException:
if an error occurs getting a public key
JGitInternalException:
if signature verification fails