public abstract class

AWS4SignerBase

extends Object
java.lang.Object
   ↳ com.modus.mule.modules.as2.filestorage.s3.AWS4SignerBase
Known Direct Subclasses

Summary

Constants
String ALGORITHM
String DateStringFormat
String EMPTY_BODY_SHA256 SHA256 hash of an empty request body
String ISO8601BasicFormat format strings for the date/time and date stamps required during signing
String SCHEME
String TERMINATOR
String UNSIGNED_PAYLOAD
Fields
protected final SimpleDateFormat dateStampFormat
protected final SimpleDateFormat dateTimeFormat
protected URL endpointUrl
protected String httpMethod
protected String regionName
protected String serviceName
Public Constructors
AWS4SignerBase(URL endpointUrl, String httpMethod, String serviceName, String regionName)
Create a new AWS V4 signer.
Public Methods
static String getCanonicalizedQueryString(Map<String, String> parameters)
Examines the specified query string parameters and returns a canonicalized form.
static byte[] hash(byte[] data)
Hashes the byte array using the SHA-256 algorithm.
static byte[] hash(String text)
Hashes the string contents (assumed to be UTF-8) using the SHA-256 algorithm.
static String toHex(byte[] data)
Protected Methods
static String getCanonicalRequest(URL endpoint, String httpMethod, String queryParameters, String canonicalizedHeaderNames, String canonicalizedHeaders, String bodyHash)
Returns the canonical request string to go into the signer process; this consists of several canonical sub-parts.
static String getCanonicalizeHeaderNames(Map<String, String> headers)
Returns the canonical collection of header names that will be included in the signature.
static String getCanonicalizedHeaderString(Map<String, String> headers)
Computes the canonical headers with values for the request.
static String getCanonicalizedResourcePath(URL endpoint)
Returns the canonicalized resource path for the service endpoint.
static String getStringToSign(String scheme, String algorithm, String dateTime, String scope, String canonicalRequest)
static byte[] sign(String stringData, byte[] key, String algorithm)
static String urlEncode(String url, boolean keepPathSlash)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ALGORITHM

Constant Value: "HMAC-SHA256"

public static final String DateStringFormat

Constant Value: "yyyyMMdd"

public static final String EMPTY_BODY_SHA256

SHA256 hash of an empty request body

Constant Value: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

public static final String ISO8601BasicFormat

format strings for the date/time and date stamps required during signing

Constant Value: "yyyyMMdd'T'HHmmss'Z'"

public static final String SCHEME

Constant Value: "AWS4"

public static final String TERMINATOR

Constant Value: "aws4_request"

public static final String UNSIGNED_PAYLOAD

Constant Value: "UNSIGNED-PAYLOAD"

Fields

protected final SimpleDateFormat dateStampFormat

protected final SimpleDateFormat dateTimeFormat

protected URL endpointUrl

protected String httpMethod

protected String regionName

protected String serviceName

Public Constructors

public AWS4SignerBase (URL endpointUrl, String httpMethod, String serviceName, String regionName)

Create a new AWS V4 signer.

Parameters
endpointUrl The service endpoint, including the path to any resource.
httpMethod The HTTP verb for the request, e.g. GET.
serviceName The signing name of the service, e.g. 's3'.
regionName The system name of the AWS region associated with the endpoint, e.g. us-east-1.

Public Methods

public static String getCanonicalizedQueryString (Map<String, String> parameters)

Examines the specified query string parameters and returns a canonicalized form.

The canonicalized query string is formed by first sorting all the query string parameters, then URI encoding both the key and value and then joining them, in order, separating key value pairs with an '&'.

Parameters
parameters The query string parameters to be canonicalized.
Returns
  • A canonicalized form for the specified query string parameters.

public static byte[] hash (byte[] data)

Hashes the byte array using the SHA-256 algorithm.

Parameters
data

public static byte[] hash (String text)

Hashes the string contents (assumed to be UTF-8) using the SHA-256 algorithm.

Parameters
text

public static String toHex (byte[] data)

Parameters
data

Protected Methods

protected static String getCanonicalRequest (URL endpoint, String httpMethod, String queryParameters, String canonicalizedHeaderNames, String canonicalizedHeaders, String bodyHash)

Returns the canonical request string to go into the signer process; this consists of several canonical sub-parts.

Parameters
endpoint
httpMethod
queryParameters
canonicalizedHeaderNames
canonicalizedHeaders
bodyHash

protected static String getCanonicalizeHeaderNames (Map<String, String> headers)

Returns the canonical collection of header names that will be included in the signature. For AWS4, all header names must be included in the process in sorted canonicalized order.

Parameters
headers

protected static String getCanonicalizedHeaderString (Map<String, String> headers)

Computes the canonical headers with values for the request. For AWS4, all headers must be included in the signing process.

Parameters
headers

protected static String getCanonicalizedResourcePath (URL endpoint)

Returns the canonicalized resource path for the service endpoint.

Parameters
endpoint

protected static String getStringToSign (String scheme, String algorithm, String dateTime, String scope, String canonicalRequest)

Parameters
scheme
algorithm
dateTime
scope
canonicalRequest

protected static byte[] sign (String stringData, byte[] key, String algorithm)

Parameters
stringData
key
algorithm

protected static String urlEncode (String url, boolean keepPathSlash)

Parameters
url
keepPathSlash