Package com.nexmo.client.auth
Class RequestSigning
- java.lang.Object
-
- com.nexmo.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 Nexmo.
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_ALLOWABLE_TIME_DELTAstatic java.lang.StringPARAM_SIGNATUREstatic java.lang.StringPARAM_TIMESTAMP
-
Constructor Summary
Constructors Constructor Description RequestSigning()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringclean(java.lang.String str)static voidconstructSignatureForRequestParameters(java.util.List<org.apache.http.NameValuePair> params, java.lang.String secretKey)Signs a set of request parameters.protected static voidconstructSignatureForRequestParameters(java.util.List<org.apache.http.NameValuePair> params, java.lang.String secretKey, long currentTimeSeconds)Signs a set of request parameters.static booleanverifyRequestSignature(javax.servlet.http.HttpServletRequest request, java.lang.String secretKey)Verifies the signature in an HttpServletRequest.protected static booleanverifyRequestSignature(javax.servlet.http.HttpServletRequest request, java.lang.String secretKey, long currentTimeMillis)Verifies the signature in an HttpServletRequest.
-
-
-
Field Detail
-
MAX_ALLOWABLE_TIME_DELTA
public static final int MAX_ALLOWABLE_TIME_DELTA
- See Also:
- Constant Field Values
-
PARAM_SIGNATURE
public static final java.lang.String PARAM_SIGNATURE
- See Also:
- Constant Field Values
-
PARAM_TIMESTAMP
public static final java.lang.String PARAM_TIMESTAMP
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RequestSigning
public RequestSigning()
-
-
Method Detail
-
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 signedsecretKey- 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 signedsecretKey- the pre-shared secret key held by the clientcurrentTimeSeconds- 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 verifiedsecretKey- 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 verifiedsecretKey- The pre-shared secret key used by the sender of the request to create the signaturecurrentTimeMillis- 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)
-
-