Class WebhookSecret
java.lang.Object
com.kingsrook.qqq.backend.core.utils.webhooks.WebhookSecret
A webhook signing secret (Standard Webhooks format).
The text form is whsec_ followed by the base64 of the key bytes.
The HMAC key is the decoded bytes. A secret without the prefix is used as
raw UTF-8 bytes, so a secret shared with an older receiver still works.
toString() never reveals the key: it prints the fingerprint.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intKey length for generated secrets, in bytes (256 bits).static final intShortest key accepted, in bytes (128 bits).static final String -
Method Summary
Modifier and TypeMethodDescriptionbooleanEqual when the keys are equal (constant time).A short, non-reversible id for the secret (first 12 hex chars of its SHA-256), safe to store and show, so people can tell secrets apart.static WebhookSecretgenerate()A new random secret.inthashCode()Hash of the fingerprint.byte[]keyBytes()The HMAC key (a copy).static WebhookSecretParse the text form (whsec_<base64>, or raw text).reveal()The text form to give a receiver (whsec_<base64>).toString()Never prints the key.
-
Field Details
-
PREFIX
- See Also:
-
GENERATED_KEY_BYTES
public static final int GENERATED_KEY_BYTESKey length for generated secrets, in bytes (256 bits).- See Also:
-
MINIMUM_KEY_BYTES
public static final int MINIMUM_KEY_BYTESShortest key accepted, in bytes (128 bits).- See Also:
-
-
Method Details
-
generate
A new random secret. -
parse
Parse the text form (whsec_<base64>, or raw text). -
reveal
The text form to give a receiver (whsec_<base64>). -
keyBytes
public byte[] keyBytes()The HMAC key (a copy). -
fingerprint
A short, non-reversible id for the secret (first 12 hex chars of its SHA-256), safe to store and show, so people can tell secrets apart. -
toString
-
equals
-
hashCode
-