Class WebhookHandler
java.lang.Object
com.fortemate.dicechess.runtime.WebhookHandler
Authenticates and dispatches DiceChess webhook deliveries to a
BotStrategy.
The unsigned legacy version-1 ownership handshake is preserved. Version-2 verification challenges are authenticated against the pending key and return a cryptographic activation response proof. Game decisions are authenticated over the exact raw body under active and/or pending keys before any decision-specific state is read. A strategy runtime exception is converted to a bounded error response and its message is never returned to the caller.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringHeader carrying the hex HMAC-SHA256 signature (seeSignatures).static final StringHeader carrying the delivery's Unix-epoch-seconds timestamp. -
Constructor Summary
ConstructorsConstructorDescriptionWebhookHandler(WebhookHandler source, ResignPolicy resignPolicy) Creates a handler identical tosourceexcept for its resign policy.WebhookHandler(WebhookKeys keys, BotStrategy strategy) Creates a handler with an immutable key configuration and without theGET /games/{id}/movesfallback.WebhookHandler(WebhookKeys keys, String playApiBaseUrl, BotStrategy strategy) Creates a handler with an immutable key configuration that fetchesGET /games/{id}/moveswhen a turn's inline move tree is capped.WebhookHandler(WebhookKeys keys, String playApiBaseUrl, BotStrategy strategy, ResignPolicy resignPolicy) Creates a handler with an immutable key configuration and custom resign policy.WebhookHandler(String secret, BotStrategy strategy) Creates a handler with a single active secret and without theGET /games/{id}/movesfallback.WebhookHandler(String secret, String playApiBaseUrl, BotStrategy strategy) Creates a handler with a single active secret that fetchesGET /games/{id}/moveswhen a turn's inline move tree is capped.WebhookHandler(String secret, String playApiBaseUrl, BotStrategy strategy, ResignPolicy resignPolicy) Creates a handler with a single active secret and custom resign policy. -
Method Summary
Modifier and TypeMethodDescriptionHandles one webhook request.keys()Returns the immutable key configuration used by this handler.Returns the resign policy used by this handler.
-
Field Details
-
TIMESTAMP_HEADER
Header carrying the delivery's Unix-epoch-seconds timestamp.- See Also:
-
SIGNATURE_HEADER
Header carrying the hex HMAC-SHA256 signature (seeSignatures).- See Also:
-
-
Constructor Details
-
WebhookHandler
Creates a handler with a single active secret and without theGET /games/{id}/movesfallback.- Parameters:
secret- the webhook secret issued by the platformstrategy- the decision-oriented bot strategy
-
WebhookHandler
Creates a handler with a single active secret that fetchesGET /games/{id}/moveswhen a turn's inline move tree is capped. The fallback endpoint is public and needs no additional credential.- Parameters:
secret- the webhook secret issued by the platformplayApiBaseUrl- play-api's base URL; a trailing slash is toleratedstrategy- the decision-oriented bot strategy
-
WebhookHandler
public WebhookHandler(String secret, String playApiBaseUrl, BotStrategy strategy, ResignPolicy resignPolicy) Creates a handler with a single active secret and custom resign policy.- Parameters:
secret- the webhook secret issued by the platformplayApiBaseUrl- play-api's base URL; a trailing slash is toleratedstrategy- the decision-oriented bot strategyresignPolicy- the policy consulted before strategy dispatch
-
WebhookHandler
Creates a handler with an immutable key configuration and without theGET /games/{id}/movesfallback.- Parameters:
keys- the active and/or pending webhook keysstrategy- the decision-oriented bot strategy
-
WebhookHandler
Creates a handler with an immutable key configuration that fetchesGET /games/{id}/moveswhen a turn's inline move tree is capped. The fallback endpoint is public and needs no additional credential.- Parameters:
keys- the active and/or pending webhook keysplayApiBaseUrl- play-api's base URL; a trailing slash is toleratedstrategy- the decision-oriented bot strategy
-
WebhookHandler
public WebhookHandler(WebhookKeys keys, String playApiBaseUrl, BotStrategy strategy, ResignPolicy resignPolicy) Creates a handler with an immutable key configuration and custom resign policy.- Parameters:
keys- the active and/or pending webhook keysplayApiBaseUrl- play-api's base URL; a trailing slash is toleratedstrategy- the decision-oriented bot strategyresignPolicy- the policy consulted before strategy dispatch
-
WebhookHandler
Creates a handler identical tosourceexcept for its resign policy.Used to derive a draining handler from a running one without rebuilding, or losing, the keys, the play-api base URL and the strategy the application configured.
- Parameters:
source- the handler to copyresignPolicy- the policy the copy consults before strategy dispatch
-
-
Method Details
-
keys
Returns the immutable key configuration used by this handler.- Returns:
- the webhook keys
-
resignPolicy
Returns the resign policy used by this handler.- Returns:
- the resign policy
-
handle
Handles one webhook request.- Parameters:
headers- the request headers; lookup is case-insensitiverawBody- the request body exactly as receivednowEpochSeconds- the verifier's current Unix epoch time in seconds- Returns:
- status 200 for a successful handshake/decision, 400 for a malformed or unknown envelope, 401 for a missing/expired/wrong signature, or 500 for a strategy failure
-