public class AWS4Signer extends AbstractAWSSigner implements ServiceAwareSigner, RegionAwareSigner, Presigner
Modifier and Type | Class and Description |
---|---|
protected static class |
AWS4Signer.HeaderSigningResult |
Modifier and Type | Field and Description |
---|---|
protected static String |
ALGORITHM |
protected boolean |
doubleUrlEncode
Whether double url-encode the resource path when constructing the
canonical request.
|
protected static org.apache.commons.logging.Log |
log |
protected Date |
overriddenDate
Date override for testing only
|
protected String |
regionName
Region name override for use when the endpoint can't be used to
determine the region name.
|
protected String |
serviceName
Service name override for use when the endpoint can't be used to
determine the service name.
|
protected static String |
TERMINATOR |
Constructor and Description |
---|
AWS4Signer()
Construct a new AWS4 signer instance.
|
AWS4Signer(boolean doubleUrlEncoding)
Construct a new AWS4 signer instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addHostHeader(Request<?> request) |
protected void |
addSessionCredentials(Request<?> request,
AWSSessionCredentials credentials)
Adds session credentials to the request given.
|
protected String |
calculateContentHash(Request<?> request)
Calculate the hash of the request's payload.
|
protected String |
calculateContentHashPresign(Request<?> request)
Calculate the hash of the request's payload.
|
protected AWS4Signer.HeaderSigningResult |
computeSignature(Request<?> request,
String dateStamp,
String timeStamp,
String algorithm,
String contentSha256,
AWSCredentials sanitizedCredentials) |
protected String |
extractRegionName(URI endpoint) |
protected String |
extractServiceName(URI endpoint) |
protected String |
getCanonicalizedHeaderString(Request<?> request) |
protected String |
getCanonicalRequest(Request<?> request,
String contentSha256) |
protected long |
getDateFromRequest(Request<?> request) |
protected String |
getDateStamp(long dateMilli) |
protected String |
getScope(Request<?> request,
String dateStamp) |
protected String |
getSignedHeadersString(Request<?> request) |
protected String |
getStringToSign(String algorithm,
String dateTime,
String scope,
String canonicalRequest) |
protected String |
getTimeStamp(long dateMilli) |
void |
presignRequest(Request<?> request,
AWSCredentials credentials,
Date expiration)
Signs the request by adding the signature to the URL rather than as a
header.
|
protected void |
processRequestPayload(Request<?> request,
AWS4Signer.HeaderSigningResult headerSigningResult)
Subclass could override this method to perform any additional procedure on the request
payload, with access to the result from signing the header.
|
void |
setRegionName(String regionName)
Sets the region name that this signer should use when calculating request
signatures.
|
void |
setServiceName(String serviceName)
Sets the service name that this signer should use when calculating
request signatures.
|
void |
sign(Request<?> request,
AWSCredentials credentials)
Sign the given request with the given set of credentials.
|
getBinaryRequestPayload, getBinaryRequestPayloadStream, getBinaryRequestPayloadStreamWithoutQueryParams, getBinaryRequestPayloadWithoutQueryParams, getCanonicalizedEndpoint, getCanonicalizedQueryString, getCanonicalizedQueryString, getCanonicalizedResourcePath, getCanonicalizedResourcePath, getRequestPayload, getRequestPayloadWithoutQueryParams, getSignatureDate, getTimeOffset, hash, hash, hash, newString, sanitizeCredentials, sign, sign, signAndBase64Encode, signAndBase64Encode
protected static final String ALGORITHM
protected static final String TERMINATOR
protected String serviceName
protected String regionName
protected Date overriddenDate
protected boolean doubleUrlEncode
protected static final org.apache.commons.logging.Log log
public AWS4Signer()
public AWS4Signer(boolean doubleUrlEncoding)
doubleUrlEncoding
- Whether double url-encode the resource path when constructing
the canonical request.public void sign(Request<?> request, AWSCredentials credentials)
Signer
public void setServiceName(String serviceName)
setServiceName
in interface ServiceAwareSigner
serviceName
- The service name to use when calculating signatures in this
signer.public void setRegionName(String regionName)
setRegionName
in interface RegionAwareSigner
regionName
- The region name to use when calculating signatures in this
signer.protected void addSessionCredentials(Request<?> request, AWSSessionCredentials credentials)
AbstractAWSSigner
addSessionCredentials
in class AbstractAWSSigner
request
- The request to add session credentials information tocredentials
- The session credentials to add to the requestprotected String getStringToSign(String algorithm, String dateTime, String scope, String canonicalRequest)
protected final AWS4Signer.HeaderSigningResult computeSignature(Request<?> request, String dateStamp, String timeStamp, String algorithm, String contentSha256, AWSCredentials sanitizedCredentials)
protected final String getTimeStamp(long dateMilli)
protected final String getDateStamp(long dateMilli)
protected final long getDateFromRequest(Request<?> request)
protected void addHostHeader(Request<?> request)
protected String calculateContentHash(Request<?> request)
protected void processRequestPayload(Request<?> request, AWS4Signer.HeaderSigningResult headerSigningResult)
public void presignRequest(Request<?> request, AWSCredentials credentials, Date expiration)
Presigner
presignRequest
in interface Presigner
request
- The request to sign.credentials
- The credentials to sign it with.expiration
- The time when this presigned URL will expire.protected String calculateContentHashPresign(Request<?> request)
Copyright © 2015. All rights reserved.