Class AWS4SignerBase

    • Constructor Detail

      • AWS4SignerBase

        public AWS4SignerBase​(URL endpointUrl,
                              String httpMethod,
                              String serviceName,
                              String regionName)
        Create a new AWS V4 signer.
        Parameters:
        endpointUrl - The service endpoint, including the path to any resource.
        httpMethod - The HTTP verb for the request, e.g. GET.
        serviceName - The signing name of the service, e.g. 's3'.
        regionName - The system name of the AWS region associated with the endpoint, e.g. us-east-1.
    • Method Detail

      • getCanonicalizeHeaderNames

        protected static String getCanonicalizeHeaderNames​(Map<String,​String> headers)
        Returns the canonical collection of header names that will be included in the signature. For AWS4, all header names must be included in the process in sorted canonicalized order.
      • getCanonicalizedHeaderString

        protected static String getCanonicalizedHeaderString​(Map<String,​String> headers)
        Computes the canonical headers with values for the request. For AWS4, all headers must be included in the signing process.
      • getCanonicalRequest

        protected static String getCanonicalRequest​(URL endpoint,
                                                    String httpMethod,
                                                    String queryParameters,
                                                    String canonicalizedHeaderNames,
                                                    String canonicalizedHeaders,
                                                    String bodyHash)
        Returns the canonical request string to go into the signer process; this consists of several canonical sub-parts.
        Returns:
      • getCanonicalizedResourcePath

        protected static String getCanonicalizedResourcePath​(URL endpoint)
        Returns the canonicalized resource path for the service endpoint.
      • getCanonicalizedQueryString

        public static String getCanonicalizedQueryString​(Map<String,​String> parameters)
        Examines the specified query string parameters and returns a canonicalized form.

        The canonicalized query string is formed by first sorting all the query string parameters, then URI encoding both the key and value and then joining them, in order, separating key value pairs with an '&'.

        Parameters:
        parameters - The query string parameters to be canonicalized.
        Returns:
        A canonicalized form for the specified query string parameters.
      • hash

        public static byte[] hash​(String text)
        Hashes the string contents (assumed to be UTF-8) using the SHA-256 algorithm.
      • hash

        public static byte[] hash​(byte[] data)
        Hashes the byte array using the SHA-256 algorithm.
      • sign

        protected static byte[] sign​(String stringData,
                                     byte[] key,
                                     String algorithm)
      • urlEncode

        public static String urlEncode​(String url,
                                       boolean keepPathSlash)