public class SignatureCalculator extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ELLIPTIC_CURVE_ALGORITHM
This is the constant for Elliptic Curve algorithm
|
| Constructor and Description |
|---|
SignatureCalculator(String consumerKey,
String consumerSecret) |
| Modifier and Type | Method and Description |
|---|---|
String |
calculateSignature(String method,
String baseURL,
long oauthTimestamp,
String nonce,
SignatureMethod signatureMethod,
Map<String,List<String>> formParams,
Map<String,List<String>> queryParams)
Calculate the OAuth 1.0 signature based on the given parameters.
|
String |
calculateSignature(String method,
String baseURL,
long oauthTimestamp,
String nonce,
SignatureMethod signatureMethod,
String oauthVersion,
Map<String,List<String>> formParams,
Map<String,List<String>> queryParams)
Calculate the OAuth 1.0 signature based on the given parameters
|
String |
constructAuthHeader(String signature,
String nonce,
long oauthTimestamp,
SignatureMethod signatureMethod)
Construct the OAuth 1.0 authorization header with the given parameters.
|
protected static boolean |
verifySignature(String signedText,
SignatureMethod signatureMethod,
String signatureToVerify,
String verificationKey)
Verify the signature.
|
static boolean |
verifySignature(String consumerKey,
String method,
String baseURL,
long oauthTimestamp,
String nonce,
SignatureMethod signatureMethod,
Map<String,List<String>> formParams,
Map<String,List<String>> queryParams,
String signatureToVerify,
String verificationKey)
Verify the signature.
|
public static final String ELLIPTIC_CURVE_ALGORITHM
public String calculateSignature(String method, String baseURL, long oauthTimestamp, String nonce, SignatureMethod signatureMethod, Map<String,List<String>> formParams, Map<String,List<String>> queryParams)
calculateSignature(String, String, long, String, SignatureMethod, String, Map, Map)
but with oauthVersion hard-coded to "1.0".method - the HTTP methodbaseURL - The base url including the protocol, host, port, and path.
The query portion of the request URL must be assembled in the 'queryParams' input.oauthTimestamp - the time stampnonce - noncesignatureMethod - signature method to be used - supported are HMAC-SHA1, HMAC-SHA256, ES512formParams - the list of form parametersqueryParams - list of query parameterspublic String calculateSignature(String method, String baseURL, long oauthTimestamp, String nonce, SignatureMethod signatureMethod, String oauthVersion, Map<String,List<String>> formParams, Map<String,List<String>> queryParams)
method - the HTTP methodbaseURL - The base url including the protocol, host, port, and path.
The query portion of the request URL must be assembled in the 'queryParams' input.oauthTimestamp - the time stampnonce - noncesignatureMethod - signature method to be used - supported are HMAC-SHA1, HMAC-SHA256, ES512oauthVersion - the oauth_version value;
OPTIONAL. If present, MUST be set to "1.0". Provides the
version of the authentication process as defined in RFC5849.formParams - the list of form parametersqueryParams - list of query parameterspublic String constructAuthHeader(String signature, String nonce, long oauthTimestamp, SignatureMethod signatureMethod)
signature - the computed signaturenonce - nonce parameteroauthTimestamp - timestamp parametersignatureMethod - signature method used to compute this header.public static boolean verifySignature(String consumerKey, String method, String baseURL, long oauthTimestamp, String nonce, SignatureMethod signatureMethod, Map<String,List<String>> formParams, Map<String,List<String>> queryParams, String signatureToVerify, String verificationKey)
consumerKey - the consumer keymethod - the HTTP methodbaseURL - The base url including the protocol, host, port, and path.
The query portion of the request URL must be assembled in the 'queryParams' input.oauthTimestamp - the time stampnonce - noncesignatureMethod - signature method to be used - supported are HMAC-SHA1, HMAC-SHA256, ES512formParams - the list of form parametersqueryParams - list of query parameterssignatureToVerify - the signature bytes to be verified.verificationKey - the key used to verify the signature. This will be the shared secret key for HMAC-SHAn signature
method and is the public key for ES512 signature method.protected static boolean verifySignature(String signedText, SignatureMethod signatureMethod, String signatureToVerify, String verificationKey)
signedText - the original text that was signed.signatureMethod - signature method to be used - supported are HMAC-SHA1, HMAC-SHA256, ES512signatureToVerify - the signature bytes to be verified.verificationKey - the key used to verify the signature. This will be the consumer key for HMAC-SHAn signature
method and is the public key for ES512 signature method.Copyright © 2022 HERE Europe B.V. All Rights Reserved.