Package com.chargebee.v4.webhook
Class WebhookVerifier
java.lang.Object
com.chargebee.v4.webhook.WebhookVerifier
Utility class for verifying Chargebee webhook requests using HTTP Basic Authentication.
Chargebee supports optional HTTP Basic Authentication for webhooks. When configured, Chargebee sends the username and password in the Authorization header as Base64-encoded credentials.
To enable webhook authentication in Chargebee:
- Go to Settings → Configure Chargebee → Webhooks
- Edit your webhook endpoint
- Enable "Basic Authentication" and set username/password
Usage example:
WebhookVerifier verifier = new WebhookVerifier();
boolean isValid = verifier.verifyBasicAuth(
authorizationHeader,
expectedUsername,
expectedPassword
);
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionextractUsername(String authorizationHeader) Extracts username from the Authorization header.booleanverifyBasicAuth(String authorizationHeader, String expectedUsername, String expectedPassword) Verifies the webhook request using HTTP Basic Authentication.
-
Constructor Details
-
WebhookVerifier
public WebhookVerifier()
-
-
Method Details
-
verifyBasicAuth
public boolean verifyBasicAuth(String authorizationHeader, String expectedUsername, String expectedPassword) Verifies the webhook request using HTTP Basic Authentication.Chargebee sends credentials in the Authorization header as: "Basic base64(username:password)"
- Parameters:
authorizationHeader- The Authorization header value from the requestexpectedUsername- The expected username configured in ChargebeeexpectedPassword- The expected password configured in Chargebee- Returns:
- true if credentials match, false otherwise
-
extractUsername
Extracts username from the Authorization header.- Parameters:
authorizationHeader- The Authorization header value- Returns:
- The username, or null if extraction fails
-