Class NeptuneNettyHttpSigV4Signer

  • All Implemented Interfaces:
    NeptuneSigV4Signer<io.netty.handler.codec.http.FullHttpRequest>

    public class NeptuneNettyHttpSigV4Signer
    extends NeptuneSigV4SignerBase<io.netty.handler.codec.http.FullHttpRequest>
    Signer for HTTP requests made via Netty clients FullHttpRequests.
    • Constructor Detail

      • NeptuneNettyHttpSigV4Signer

        public NeptuneNettyHttpSigV4Signer​(String regionName,
                                           com.amazonaws.auth.AWSCredentialsProvider v1AwsCredentialProvider)
                                    throws NeptuneSigV4SignerException
        Create a V4 Signer for Netty HTTP requests.
        Parameters:
        regionName - name of the region for which the request is signed
        v1AwsCredentialProvider - the provider offering access to the credentials used for signing the request
        Throws:
        NeptuneSigV4SignerException - in case initialization fails
      • NeptuneNettyHttpSigV4Signer

        public NeptuneNettyHttpSigV4Signer​(String regionName,
                                           com.amazonaws.auth.AWSCredentialsProvider v1AwsCredentialProvider,
                                           String serviceName)
                                    throws NeptuneSigV4SignerException
        Create a V4 Signer for Netty HTTP requests.
        Parameters:
        regionName - name of the region for which the request is signed
        v1AwsCredentialProvider - the provider offering access to the credentials used for signing the request
        serviceName - name of the service name used to sign the requests. Defaults to neptune-db
        Throws:
        NeptuneSigV4SignerException - in case initialization fails
      • NeptuneNettyHttpSigV4Signer

        public NeptuneNettyHttpSigV4Signer​(String regionName,
                                           software.amazon.awssdk.auth.credentials.AwsCredentialsProvider awsCredentialsProvider)
                                    throws NeptuneSigV4SignerException
        Create a V4 Signer for Netty HTTP requests.
        Parameters:
        regionName - name of the region for which the request is signed
        awsCredentialsProvider - the provider offering access to the credentials used for signing the request
        Throws:
        NeptuneSigV4SignerException - in case initialization fails
      • NeptuneNettyHttpSigV4Signer

        public NeptuneNettyHttpSigV4Signer​(String regionName,
                                           software.amazon.awssdk.auth.credentials.AwsCredentialsProvider awsCredentialsProvider,
                                           String serviceName)
                                    throws NeptuneSigV4SignerException
        Create a V4 Signer for Netty HTTP requests.
        Parameters:
        regionName - name of the region for which the request is signed
        awsCredentialsProvider - the provider offering access to the credentials used for signing the request
        serviceName - 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​(io.netty.handler.codec.http.FullHttpRequest request)
                                                                            throws NeptuneSigV4SignerException
        Description copied from class: NeptuneSigV4SignerBase
        Convert the native request into an AWS SDK SignableRequest object 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 a SignableRequest object, 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:
        toSignableRequest in class NeptuneSigV4SignerBase<io.netty.handler.codec.http.FullHttpRequest>
        Parameters:
        request - the native HTTP request
        Returns:
        the SdkHttpFullRequest
        Throws:
        NeptuneSigV4SignerException - in case something goes wrong during translation
      • attachSignature

        protected void attachSignature​(io.netty.handler.codec.http.FullHttpRequest request,
                                       NeptuneSigV4SignerBase.NeptuneSigV4Signature signature)
                                throws NeptuneSigV4SignerException
        Description copied from class: NeptuneSigV4SignerBase
        Attach 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:
        attachSignature in class NeptuneSigV4SignerBase<io.netty.handler.codec.http.FullHttpRequest>
        Parameters:
        request - the native HTTP request
        signature - the signature information to attach
        Throws:
        NeptuneSigV4SignerException - in case something goes wrong during signing of the native request