Class GHWebhookSignature
java.lang.Object
org.jenkinsci.plugins.github.webhook.GHWebhookSignature
Utility class for dealing with signatures of incoming requests.
- Since:
- 1.21.0
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.booleanmatches(String digest, SignatureAlgorithm algorithm) Validates a signature using the specified algorithm.sha1()Deprecated.Usesha256()for enhanced securitysha256()Computes a RFC 2104-compliant HMAC digest using SHA256 of a payload with a given key (secret).static GHWebhookSignaturewebhookSignature(String payload, Secret secret)
-
Field Details
-
INVALID_SIGNATURE
- See Also:
-
-
Method Details
-
webhookSignature
- Parameters:
payload- Clear-text to create signature of.secret- Key to sign with.
-
sha1
Deprecated.Usesha256()for enhanced securityComputes a RFC 2104-compliant HMAC digest using SHA1 of a payloadFrom with a given key (secret).- Returns:
- HMAC digest of payloadFrom using secret as key. Will return COMPUTED_INVALID_SIGNATURE on any exception during computation.
-
sha256
Computes a RFC 2104-compliant HMAC digest using SHA256 of a payload with a given key (secret). This is the recommended method for webhook signature validation.- Returns:
- HMAC digest of payload using secret as key. Will return COMPUTED_INVALID_SIGNATURE on any exception during computation.
- Since:
- 1.45.0
-
matches
Deprecated.Usematches(String, SignatureAlgorithm)for explicit algorithm selection- Parameters:
digest- computed signature from external place (GitHub)- Returns:
- true if computed and provided signatures identical
-
matches
Validates a signature using the specified algorithm. Uses constant-time comparison to prevent timing attacks.- Parameters:
digest- the signature to validate (without algorithm prefix)algorithm- the signature algorithm to use- Returns:
- true if computed and provided signatures match
- Since:
- 1.45.0
-
matches(String, SignatureAlgorithm)for explicit algorithm selection