Class RequestSigning

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

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

  • Constructor Details

  • Method Details

    • constructSignatureForRequestParameters

      public static void constructSignatureForRequestParameters(List<org.apache.http.NameValuePair> params, 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. Uses the default hash strategy of MD5.

      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

      public static void constructSignatureForRequestParameters(List<org.apache.http.NameValuePair> params, String secretKey, HashUtil.HashType hashType)
      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
      hashType - The type of hash that is to be used in construction
    • constructSignatureForRequestParameters

      protected static void constructSignatureForRequestParameters(List<org.apache.http.NameValuePair> params, 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. Hashing strategy is MD5.

      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
    • constructSignatureForRequestParameters

      protected static void constructSignatureForRequestParameters(List<org.apache.http.NameValuePair> params, String secretKey, long currentTimeSeconds, HashUtil.HashType hashType)
      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.
      hashType - Hash type to be used to construct request parameters.
    • verifyRequestSignature

      @Deprecated public static boolean verifyRequestSignature(javax.servlet.http.HttpServletRequest request, String secretKey)
      Deprecated.
      This method will be removed in a future release due to the dependency on javax.servlet.
      Verifies the signature in an HttpServletRequest. Uses default hashing strategy of MD5.
      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

      @Deprecated public static boolean verifyRequestSignature(javax.servlet.http.HttpServletRequest request, String secretKey, HashUtil.HashType hashType)
      Deprecated.
      This method will be removed in a future release due to the dependency on javax.servlet.
      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.
      hashType - Hash type to be used to construct request parameters.
      Returns:
      true if the signature is correct for this request and secret key.
    • verifyRequestSignature

      protected static boolean verifyRequestSignature(String contentType, InputStream inputStream, Map<String,String[]> parameterMap, String secretKey, long currentTimeMillis)
      Verifies the signature in an HttpServletRequest. Hashing strategy is MD5.
      Parameters:
      contentType - The request Content-Type header.
      inputStream - The request data stream.
      parameterMap - The request parameters.
      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.
    • verifyRequestSignature

      protected static boolean verifyRequestSignature(String contentType, InputStream inputStream, Map<String,String[]> parameterMap, String secretKey, long currentTimeMillis, HashUtil.HashType hashType)
      Verifies the signature in an HttpServletRequest.
      Parameters:
      contentType - The request Content-Type header.
      inputStream - The request data stream.
      parameterMap - The request parameters.
      secretKey - The pre-shared secret key used by the sender of the request to create the signature.
      currentTimeMillis - The current time, in milliseconds.
      hashType - Hash type to be used to construct request parameters.
      Returns:
      true if the signature is correct for this request and secret key.
    • clean

      public static String clean(String str)