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

      @Deprecated 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

      @Deprecated 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

      @Deprecated public static void constructSignatureForRequestParameters(Map<String,String> 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. This method modifies the input params.

      Parameters:
      params - 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.
    • getSignatureForRequestParameters

      public static Map<String,String> getSignatureForRequestParameters(Map<String,String> 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. This method does not modify the input parameters.

      Parameters:
      params - 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.
      Returns:
      A new Map with the signature query parameters.
    • verifyRequestSignature

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