Class EventWebhook
java.lang.Object
com.sendgrid.helpers.eventwebhook.EventWebhook
public class EventWebhook
extends java.lang.Object
This class allows you to easily use the Event Webhook feature. Read the docs
for more details:
https://sendgrid.com/docs/for-developers/tracking-events/event.
-
Constructor Summary
Constructors Constructor Description EventWebhook()
-
Method Summary
Modifier and Type Method Description java.security.interfaces.ECPublicKey
ConvertPublicKeyToECDSA(java.lang.String publicKey)
Convert the public key string to a ECPublicKey.boolean
VerifySignature(java.security.interfaces.ECPublicKey publicKey, java.lang.String payload, java.lang.String signature, java.lang.String timestamp)
Verify signed event webhook requests.
-
Constructor Details
-
EventWebhook
public EventWebhook()
-
-
Method Details
-
ConvertPublicKeyToECDSA
public java.security.interfaces.ECPublicKey ConvertPublicKeyToECDSA(java.lang.String publicKey) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.spec.InvalidKeySpecExceptionConvert the public key string to a ECPublicKey.- Parameters:
publicKey
- : verification key under Mail Settings- Returns:
- a public key using the ECDSA algorithm
- Throws:
java.security.NoSuchAlgorithmException
- This exception is thrown when a particular cryptographic algorithm is requested but is not available in the environment.java.security.NoSuchProviderException
- This exception is thrown when a particular security provider is requested but is not available in the environment.java.security.spec.InvalidKeySpecException
- This is the exception for invalid key specifications.
-
VerifySignature
public boolean VerifySignature(java.security.interfaces.ECPublicKey publicKey, java.lang.String payload, java.lang.String signature, java.lang.String timestamp) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.InvalidKeyException, java.security.SignatureExceptionVerify signed event webhook requests.- Parameters:
publicKey
- : elliptic curve public keypayload
- : event payload in the request bodysignature
- : value obtained from the 'X-Twilio-Email-Event-Webhook-Signature' headertimestamp
- : value obtained from the 'X-Twilio-Email-Event-Webhook-Timestamp' header- Returns:
- true or false if signature is valid
- Throws:
java.security.NoSuchAlgorithmException
- This exception is thrown when a particular cryptographic algorithm is requested but is not available in the environment.java.security.NoSuchProviderException
- This exception is thrown when a particular security provider is requested but is not available in the environment.java.security.InvalidKeyException
- This is the exception for invalid key specifications.java.security.SignatureException
- This is the generic Signature exception.
-