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)
AWSSignableRequestAWSV4Signer.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 AWSSignableRequestpublic void addHeader(String key, String value)
AWSSignableRequestAWSSignableRequest.getHeaders().addHeader in interface AWSSignableRequestkey - header parameter name required by AWS signaturevalue - header parameter valuepublic AWSCredentials getCredentials()
AWSSignableRequestgetCredentials in interface AWSSignableRequestAWSCredentials instance with the properties used to form the requestpublic String getMethod()
AWSSignableRequestgetMethod in interface AWSSignableRequestString representation of the HTTP methodpublic String getUrl()
AWSSignableRequestgetUrl in interface AWSSignableRequestString representation of the request URLpublic Map<String,Object> getHeaders()
AWSSignableRequestgetHeaders in interface AWSSignableRequestMap with the headers included on the request to be signedpublic long getTimeStamp()
AWSSignableRequestgetTimeStamp in interface AWSSignableRequestpublic InputStream getPayload() throws IOException
AWSSignableRequestgetPayload in interface AWSSignableRequestInputStream with the request body payloadIOException - if there's a problem while reading the payloadpublic String getSigningKey()