public class RequestValidator extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
SIGNATURE_HEADER
Signature of signed request is set with header name 'MessageBird-Signature-JWT'
|
| Constructor and Description |
|---|
RequestValidator(String signatureKey)
RequestValidator validates request signature with a customer signature key.
|
RequestValidator(String signatureKey,
boolean skipURLValidation)
RequestValidator validates webhook signature with a customer signature key.
|
| Modifier and Type | Method and Description |
|---|---|
com.auth0.jwt.interfaces.DecodedJWT |
validateSignature(Clock clock,
String signature,
String url,
byte[] requestBody)
Returns raw signature payload after validating a signature successfully,
otherwise throws
RequestValidationException. |
com.auth0.jwt.interfaces.DecodedJWT |
validateSignature(String signature,
byte[] requestBody)
Validates request signature with URL validation disabled.
|
com.auth0.jwt.interfaces.DecodedJWT |
validateSignature(String signature,
String url,
byte[] requestBody)
Returns raw signature payload after validating a signature successfully,
otherwise throws
RequestValidationException. |
public static final String SIGNATURE_HEADER
public RequestValidator(String signatureKey)
signatureKey - customer signature key. Can be retrieved through
Developer Settings.
This is NOT your API key.public RequestValidator(String signatureKey, boolean skipURLValidation)
signatureKey - customer signature key. Can be retrieved through
Developer Settings.
This is NOT your API key.skipURLValidation - whether url_hash claim validation should be skipped.
Note that when true, no query parameters should be trusted.public com.auth0.jwt.interfaces.DecodedJWT validateSignature(Clock clock, String signature, String url, byte[] requestBody) throws RequestValidationException
RequestValidationException.
This JWT is signed with a MessageBird account unique secret key, ensuring the request is from MessageBird and a specific account. The JWT contains the following claims:
clock - custom Clock instance to validate timestamp claims.signature - the actual signature.url - the raw url including the protocol, hostname and query string,
https://example.com/?example=42.requestBody - the raw request body.DecodedJWT object.RequestValidationException - when the signature is invalid.public com.auth0.jwt.interfaces.DecodedJWT validateSignature(String signature, String url, byte[] requestBody) throws RequestValidationException
RequestValidationException.signature - the actual signature.url - the raw url including the protocol, hostname and query string,
https://example.com/?example=42.requestBody - the raw request body.DecodedJWT object.RequestValidationException - when the signature is invalid.validateSignature(Clock, String, String, byte[])public com.auth0.jwt.interfaces.DecodedJWT validateSignature(String signature, byte[] requestBody) throws RequestValidationException
RequestValidator is constructed
with skipURLValidation set to true.signature - the actual signature.requestBody - the raw request body.DecodedJWT object.RequestValidationException - when the signature is invalid.validateSignature(String, String, byte[])Copyright © 2024. All rights reserved.