Class NeptuneApacheHttpSigV4Signer
- java.lang.Object
-
- com.amazonaws.neptune.auth.NeptuneSigV4SignerBase<org.apache.http.client.methods.HttpUriRequest>
-
- com.amazonaws.neptune.auth.NeptuneApacheHttpSigV4Signer
-
- All Implemented Interfaces:
NeptuneSigV4Signer<org.apache.http.client.methods.HttpUriRequest>
public class NeptuneApacheHttpSigV4Signer extends NeptuneSigV4SignerBase<org.apache.http.client.methods.HttpUriRequest>
Signer for HTTP requests made via Apache CommonsHttpUriRequests.Note that there are certain limitations for the usage of this class. In particular:
- The implementation adds a "Host" header. This may lead to problems if the original request has a host header with a name in different capitalization (e.g. "host"), leading to duplicate host headers and the signing process to fail. Hence, when using the API you need to make sure that there is either no host header in your original request or the host header uses the exact string "Host" as the header name.
- When using GET, the underlying HTTP request needs to encode whitespaces in query parameters using '%20'
rather than (what most APIs such as the Apache commons
URIBuilderdo) using '+'.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.amazonaws.neptune.auth.NeptuneSigV4SignerBase
NeptuneSigV4SignerBase.NeptuneSigV4Signature
-
-
Constructor Summary
Constructors Constructor Description NeptuneApacheHttpSigV4Signer(String regionName, com.amazonaws.auth.AWSCredentialsProvider v1AwsCredentialProvider)Create a V4 Signer for Apache Commons HTTP requests.NeptuneApacheHttpSigV4Signer(String regionName, com.amazonaws.auth.AWSCredentialsProvider v1AwsCredentialProvider, String serviceName)Create a V4 Signer for Apache Commons HTTP requests.NeptuneApacheHttpSigV4Signer(String regionName, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider awsCredentialsProvider)Create a V4 Signer for Apache Commons HTTP requests.NeptuneApacheHttpSigV4Signer(String regionName, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider awsCredentialsProvider, String serviceName)Create a V4 Signer for Apache Commons HTTP requests.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidattachSignature(org.apache.http.client.methods.HttpUriRequest request, NeptuneSigV4SignerBase.NeptuneSigV4Signature signature)Attach the signature provided in the signature object to the nativeRequest.protected software.amazon.awssdk.http.SdkHttpFullRequesttoSignableRequest(org.apache.http.client.methods.HttpUriRequest request)Convert the native request into an AWS SDKSignableRequestobject which can be used to perform signing.-
Methods inherited from class com.amazonaws.neptune.auth.NeptuneSigV4SignerBase
checkNotNull, convertToSignableRequest, extractParametersFromQueryString, signRequest
-
-
-
-
Constructor Detail
-
NeptuneApacheHttpSigV4Signer
public NeptuneApacheHttpSigV4Signer(String regionName, com.amazonaws.auth.AWSCredentialsProvider v1AwsCredentialProvider) throws NeptuneSigV4SignerException
Create a V4 Signer for Apache Commons HTTP requests.- Parameters:
regionName- name of the region for which the request is signedv1AwsCredentialProvider- the provider offering access to the credentials used for signing the request- Throws:
NeptuneSigV4SignerException- in case initialization fails
-
NeptuneApacheHttpSigV4Signer
public NeptuneApacheHttpSigV4Signer(String regionName, com.amazonaws.auth.AWSCredentialsProvider v1AwsCredentialProvider, String serviceName) throws NeptuneSigV4SignerException
Create a V4 Signer for Apache Commons HTTP requests.- Parameters:
regionName- name of the region for which the request is signedv1AwsCredentialProvider- the provider offering access to the credentials used for signing the requestserviceName- name of the service name used to sign the requests. Defaults to neptune-db- Throws:
NeptuneSigV4SignerException- in case initialization fails
-
NeptuneApacheHttpSigV4Signer
public NeptuneApacheHttpSigV4Signer(String regionName, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider awsCredentialsProvider) throws NeptuneSigV4SignerException
Create a V4 Signer for Apache Commons HTTP requests.- Parameters:
regionName- name of the region for which the request is signedawsCredentialsProvider- the provider offering access to the credentials used for signing the request- Throws:
NeptuneSigV4SignerException- in case initialization fails
-
NeptuneApacheHttpSigV4Signer
public NeptuneApacheHttpSigV4Signer(String regionName, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider awsCredentialsProvider, String serviceName) throws NeptuneSigV4SignerException
Create a V4 Signer for Apache Commons HTTP requests.- Parameters:
regionName- name of the region for which the request is signedawsCredentialsProvider- the provider offering access to the credentials used for signing the requestserviceName- name of the service name used to sign the requests. Defaults to neptune-db- Throws:
NeptuneSigV4SignerException- in case initialization fails
-
-
Method Detail
-
toSignableRequest
protected software.amazon.awssdk.http.SdkHttpFullRequest toSignableRequest(org.apache.http.client.methods.HttpUriRequest request) throws NeptuneSigV4SignerExceptionDescription copied from class:NeptuneSigV4SignerBaseConvert the native request into an AWS SDKSignableRequestobject which can be used to perform signing. This means that the information from the request relevant for signing (such as request URI, query string, headers, etc.) need to be extracted from the native request and mapped to aSignableRequestobject, which is used internally for the signing process.Note that the signable request internally, during the signing process, adds a "Host" header. This may lead to problems if the original request has a host header with a name in different capitalization (e.g. "host"), leading to duplicate host headers and the signing process to fail. Hence, when using the API you need to make sure that there is either no host header in your original request or the host header uses the exact string "Host" as the header name. The easiest solution, if you have control over the native HTTP request, is to just leave out the host header when translating and create one when signing (the host header value will be part of the struct returned from the signing process).
- Specified by:
toSignableRequestin classNeptuneSigV4SignerBase<org.apache.http.client.methods.HttpUriRequest>- Parameters:
request- the native HTTP request- Returns:
- the
SdkHttpFullRequest - Throws:
NeptuneSigV4SignerException- in case something goes wrong during translation
-
attachSignature
protected void attachSignature(org.apache.http.client.methods.HttpUriRequest request, NeptuneSigV4SignerBase.NeptuneSigV4Signature signature) throws NeptuneSigV4SignerExceptionDescription copied from class:NeptuneSigV4SignerBaseAttach the signature provided in the signature object to the nativeRequest. More precisely, the signature contains two headers, X-AMZ-DATE and an Authorization header, which need to be attached to the native HTTP request as HTTP headers or query string depending on the type of signature requested - header/pre-signed url.- Specified by:
attachSignaturein classNeptuneSigV4SignerBase<org.apache.http.client.methods.HttpUriRequest>- Parameters:
request- the native HTTP requestsignature- the signature information to attach- Throws:
NeptuneSigV4SignerException- in case something goes wrong during signing of the native request
-
-