Record Class WebhookKeys
java.lang.Object
java.lang.Record
com.fortemate.dicechess.runtime.WebhookKeys
- Record Components:
active- the currently active webhook secret, ornullif pending-onlypending- the candidate/pending webhook secret, ornullif active-only
Immutable configuration for active and pending webhook secrets.
Supports three valid states:
- Active only: normal steady-state operation.
- Active and pending: zero-downtime rotation cutover during which verification challenges are verified against the pending key, while gameplay deliveries accept either key.
- Pending only: initial registration of a new bot before promotion to active.
Secrets are held in their issued representation (e.g. 64 lowercase hex characters) and used directly as UTF-8 bytes for HMAC-SHA256 operations without hex decoding.
To prevent credential leakage, toString() never renders secret key values.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWebhookKeys(String active, String pending) Creates and validates an immutable webhook key configuration. -
Method Summary
Modifier and TypeMethodDescriptionactive()Returns the value of theactiverecord component.static WebhookKeysactiveAndPending(String active, String pending) Creates a configuration containing both an active and a pending key.static WebhookKeysactiveOnly(String active) Creates a configuration containing only an active key.final booleanIndicates whether some other object is "equal to" this one.static WebhookKeysCreates a key configuration from the default system environment variables ("DICECHESS_WEBHOOK_SECRET" and "DICECHESS_WEBHOOK_NEXT_SECRET").static WebhookKeysfromEnvironment(Map<String, String> env) Creates a key configuration from a specified environment map.booleanReturns whether an active key is configured.final inthashCode()Returns a hash code value for this object.booleanReturns whether a pending key is configured.static WebhookKeysConvenience factory for creating a configuration with optional active and pending keys.pending()Returns the value of thependingrecord component.static WebhookKeyspendingOnly(String pending) Creates a configuration containing only a pending key.toString()Returns a string representation of this record class.
-
Field Details
-
ENV_ACTIVE_SECRET
Standard environment variable name for the active webhook secret.- See Also:
-
ENV_PENDING_SECRET
Standard environment variable name for the pending/candidate webhook secret.- See Also:
-
-
Constructor Details
-
WebhookKeys
Creates and validates an immutable webhook key configuration.- Parameters:
active- the currently active webhook secret, ornullpending- the candidate/pending webhook secret, ornull- Throws:
IllegalArgumentException- if neither key is configured, or if any configured key is blank
-
-
Method Details
-
activeOnly
Creates a configuration containing only an active key.- Parameters:
active- the active webhook secret- Returns:
- the key configuration
- Throws:
NullPointerException- ifactiveisnullIllegalArgumentException- ifactiveis blank
-
pendingOnly
Creates a configuration containing only a pending key.- Parameters:
pending- the pending webhook secret- Returns:
- the key configuration
- Throws:
NullPointerException- ifpendingisnullIllegalArgumentException- ifpendingis blank
-
activeAndPending
Creates a configuration containing both an active and a pending key.- Parameters:
active- the active webhook secretpending- the pending webhook secret- Returns:
- the key configuration
- Throws:
NullPointerException- if either key isnullIllegalArgumentException- if either key is blank
-
of
Convenience factory for creating a configuration with optional active and pending keys.- Parameters:
active- the active secret, ornullpending- the pending secret, ornull- Returns:
- the key configuration
- Throws:
IllegalArgumentException- if neither key is configured, or if any configured key is blank
-
fromEnvironment
Creates a key configuration from the default system environment variables ("DICECHESS_WEBHOOK_SECRET" and "DICECHESS_WEBHOOK_NEXT_SECRET").- Returns:
- the key configuration resolved from environment variables
- Throws:
IllegalArgumentException- if neither environment variable is configured or non-blank
-
fromEnvironment
Creates a key configuration from a specified environment map.- Parameters:
env- the environment mapping to read keys from- Returns:
- the key configuration
- Throws:
NullPointerException- ifenvisnullIllegalArgumentException- if neither environment variable is configured or non-blank
-
hasActive
public boolean hasActive()Returns whether an active key is configured.- Returns:
trueif active key is present
-
hasPending
public boolean hasPending()Returns whether a pending key is configured.- Returns:
trueif pending key is present
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
active
-
pending
-