Class RequestSigning

java.lang.Object
com.vonage.client.auth.RequestSigning

public class RequestSigning
extends java.lang.Object
A helper class for generating or verifying MD5 signatures when signing REST requests for submission to Vonage.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int MAX_ALLOWABLE_TIME_DELTA  
    static java.lang.String PARAM_SIGNATURE  
    static java.lang.String PARAM_TIMESTAMP  
  • Constructor Summary

    Constructors 
    Constructor Description
    RequestSigning()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String clean​(java.lang.String str)  
    static void constructSignatureForRequestParameters​(java.util.List<org.apache.http.NameValuePair> params, java.lang.String secretKey)
    Signs a set of request parameters.
    protected static void constructSignatureForRequestParameters​(java.util.List<org.apache.http.NameValuePair> params, java.lang.String secretKey, long currentTimeSeconds)
    Signs a set of request parameters.
    static boolean verifyRequestSignature​(javax.servlet.http.HttpServletRequest request, java.lang.String secretKey)
    Verifies the signature in an HttpServletRequest.
    protected static boolean verifyRequestSignature​(javax.servlet.http.HttpServletRequest request, java.lang.String secretKey, long currentTimeMillis)
    Verifies the signature in an HttpServletRequest.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • constructSignatureForRequestParameters

      public static void constructSignatureForRequestParameters​(java.util.List<org.apache.http.NameValuePair> params, java.lang.String secretKey)
      Signs a set of request parameters.

      Generates additional parameters to represent the timestamp and generated signature. Uses the supplied pre-shared secret key to generate the signature.

      Parameters:
      params - List of NameValuePair instances containing the query parameters for the request that is to be signed
      secretKey - the pre-shared secret key held by the client
    • constructSignatureForRequestParameters

      protected static void constructSignatureForRequestParameters​(java.util.List<org.apache.http.NameValuePair> params, java.lang.String secretKey, long currentTimeSeconds)
      Signs a set of request parameters.

      Generates additional parameters to represent the timestamp and generated signature. Uses the supplied pre-shared secret key to generate the signature.

      Parameters:
      params - List of NameValuePair instances containing the query parameters for the request that is to be signed
      secretKey - the pre-shared secret key held by the client
      currentTimeSeconds - the current time in seconds since 1970-01-01
    • verifyRequestSignature

      public static boolean verifyRequestSignature​(javax.servlet.http.HttpServletRequest request, java.lang.String secretKey)
      Verifies the signature in an HttpServletRequest.
      Parameters:
      request - The HttpServletRequest to be verified
      secretKey - The pre-shared secret key used by the sender of the request to create the signature
      Returns:
      true if the signature is correct for this request and secret key.
    • verifyRequestSignature

      protected static boolean verifyRequestSignature​(javax.servlet.http.HttpServletRequest request, java.lang.String secretKey, long currentTimeMillis)
      Verifies the signature in an HttpServletRequest.
      Parameters:
      request - The HttpServletRequest to be verified
      secretKey - The pre-shared secret key used by the sender of the request to create the signature
      currentTimeMillis - The current time, in milliseconds.
      Returns:
      true if the signature is correct for this request and secret key.
    • clean

      public static java.lang.String clean​(java.lang.String str)