public class SignatureHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
TRAILER_FIELD |
| Constructor and Description |
|---|
SignatureHelper(PayConfiguration payConfiguration) |
| Modifier and Type | Method and Description |
|---|---|
String |
createCanonicalRequest(URI uri,
String httpMethodName,
Map<String,List<String>> parameters,
String requestPayload,
Map<String,List<String>> preSignedHeaders)
Creates a string that includes the information from the request in a standardized(canonical) format.
|
Map<String,List<String>> |
createPreSignedHeaders(URI uri,
Map<String,String> header)
Creates the mandatory headers required in the request
|
String |
createStringToSign(String canonicalRequest,
String algorithm)
Creates the string that is going to be signe
|
String |
generateSignature(String stringToSign,
PrivateKey privateKey,
AmazonSignatureAlgorithm algorithm)
Generates a signature for the string passed in
|
String |
getCanonicalizedHeaderString(Map<String,List<String>> preSignedHeaders)
Generates a canonical headers string that consists of a list of all HTTP headers
that are included with the request.
|
String |
getCanonicalizedQueryString(Map<String,List<String>> parameters)
Generates a canonical string that consists of all the query parameters
|
String |
getSignedHeadersString(Map<String,List<String>> preSignedHeaders)
Generates a string that is a list of headers names that are included in the canonical headers.
|
public static final int TRAILER_FIELD
public SignatureHelper(PayConfiguration payConfiguration)
public String createCanonicalRequest(URI uri, String httpMethodName, Map<String,List<String>> parameters, String requestPayload, Map<String,List<String>> preSignedHeaders) throws AmazonPayClientException
uri - The uri that needs to be executedhttpMethodName - the HTTP request method(GET,PUT,POST etc) to be usedparameters - the query parameters maprequestPayload - the payload to be sent with the requestpreSignedHeaders - the mandatory headers requiredAmazonPayClientException - algorithm requested is not available in the environmentpublic String createStringToSign(String canonicalRequest, String algorithm) throws NoSuchAlgorithmException
canonicalRequest - The canonical request generated using the createCanonicalRequest() methodalgorithm - The Amazon Signature Algorithm from payConfigurationNoSuchAlgorithmException - exception thrown when the cryptographic
algorithm requested is not available in the environmentpublic String generateSignature(String stringToSign, PrivateKey privateKey, AmazonSignatureAlgorithm algorithm) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeyException, SignatureException
stringToSign - the string to be signedprivateKey - the private key to use for signingalgorithm - the Amazon Signature Algorithm from payConfigurationNoSuchAlgorithmException - exception thrown when the cryptographic
algorithm requested is not available in the environmentNoSuchProviderException - exception thrown when the security
provider requested is not available in the environmentInvalidAlgorithmParameterException - exception for invalid algorithm parametersInvalidKeyException - exception for invalid keysSignatureException - signature exceptionpublic Map<String,List<String>> createPreSignedHeaders(URI uri, Map<String,String> header) throws AmazonPayClientException
uri - the uri to be executedheader - Map<String, String> containining key-value pair of required headers (e.g., keys such as x-amz-pay-idempotency-key, x-amz-pay-authtoken)AmazonPayClientException - When an error response is returned by Amazon Pay due to bad request or other issuepublic String getSignedHeadersString(Map<String,List<String>> preSignedHeaders)
preSignedHeaders - the mandatory headerpublic String getCanonicalizedHeaderString(Map<String,List<String>> preSignedHeaders)
preSignedHeaders - the mandatory headerspublic String getCanonicalizedQueryString(Map<String,List<String>> parameters) throws AmazonPayClientException
parameters - the query parameters of the requestAmazonPayClientException - When an error response is returned by Amazon Pay due to bad request or other issueCopyright © 2024. All rights reserved.