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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • ConvertPublicKeyToECDSA

      public java.security.interfaces.ECPublicKey ConvertPublicKeyToECDSA​(java.lang.String publicKey) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.spec.InvalidKeySpecException
      Convert 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.SignatureException
      Verify signed event webhook requests.
      Parameters:
      publicKey - : elliptic curve public key
      payload - : event payload in the request body
      signature - : value obtained from the 'X-Twilio-Email-Event-Webhook-Signature' header
      timestamp - : 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.