public class HttpAWSSignableRequest extends Object implements AWSSignableRequest
AWSSignableRequest
meant to be used for
signing http requests made with the apache http client library
The request can be signed by passing an instance of this class to
AWSV4Signer.sign(AWSSignableRequest)
Constructor and Description |
---|
HttpAWSSignableRequest(org.apache.http.HttpRequest request,
AWSCredentials creds,
org.apache.http.client.protocol.HttpClientContext context) |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(String key,
String value)
Add a new header parameter required by the AWS Signature to the request to be sent.
|
AWSCredentials |
getCredentials()
Getter method to access the AWSCredential instance when the requet is being signed
|
Map<String,Object> |
getHeaders()
Getter method to access the request headers that needs to be included on the signature.
|
String |
getMethod()
Getter method to access the request http method
|
InputStream |
getPayload()
Getter method to access the request payload on signature generation time
|
String |
getSigningKey() |
long |
getTimeStamp()
Getter method to access the request timestamp to generate the signature
|
String |
getUrl()
Getter method to access the full request URL
|
void |
sign(String signingKey)
This method will be invoked from
AWSV4Signer.sign(AWSSignableRequest) to pass back the signing key that
needs to be included as the "Authorization" header into the original request. |
public HttpAWSSignableRequest(org.apache.http.HttpRequest request, AWSCredentials creds, org.apache.http.client.protocol.HttpClientContext context)
public void sign(String signingKey)
AWSSignableRequest
AWSV4Signer.sign(AWSSignableRequest)
to pass back the signing key that
needs to be included as the "Authorization" header into the original request.
While calling addHeader("Authorization", signingKey); should be enough to implement this method for most of
http clients, it had to be isolated because some implementations like Restlet requires to use a different
mechanism to add these particular headers.sign
in interface AWSSignableRequest
public void addHeader(String key, String value)
AWSSignableRequest
AWSSignableRequest.getHeaders()
.addHeader
in interface AWSSignableRequest
key
- header parameter name required by AWS signaturevalue
- header parameter valuepublic AWSCredentials getCredentials()
AWSSignableRequest
getCredentials
in interface AWSSignableRequest
AWSCredentials
instance with the properties used to form the requestpublic String getMethod()
AWSSignableRequest
getMethod
in interface AWSSignableRequest
String
representation of the HTTP methodpublic String getUrl()
AWSSignableRequest
getUrl
in interface AWSSignableRequest
String
representation of the request URLpublic Map<String,Object> getHeaders()
AWSSignableRequest
getHeaders
in interface AWSSignableRequest
Map
with the headers included on the request to be signedpublic long getTimeStamp()
AWSSignableRequest
getTimeStamp
in interface AWSSignableRequest
public InputStream getPayload() throws IOException
AWSSignableRequest
getPayload
in interface AWSSignableRequest
InputStream
with the request body payloadIOException
- if there's a problem while reading the payloadpublic String getSigningKey()