Class AwsRequestSignerV4

    • Method Detail

      • sign

        public static void sign​(HttpURLConnection httpURLConnection,
                                Map<String,​String> queryParameters,
                                long contentLength,
                                String bodyHash,
                                String serviceName,
                                String regionName,
                                String awsAccessKey,
                                char[] awsSecretKey)
        Sign the provided request with an AWS4 signature as the 'Authorization' header.
        httpURLConnection - The request to sign.
        queryParameters - The query parameters being sent in the request.
        contentLength - The content length of the data being sent in the request
        bodyHash - Hex-encoded SHA-256 hash of the data being sent in the request
        serviceName - The signing name of the AWS service (e.g. "s3").
        regionName - The name of the AWS region that will handle the request (e.g. "us-east-1").
        awsAccessKey - The user's AWS Access Key.
        awsSecretKey - The user's AWS Secret Key.
      • calculateBodyHash

        public static String calculateBodyHash​(byte[] data)
        Calculates the hex-encoded SHA-256 hash of the provided byte array.
        data - Byte array to hash
        Hex-encoded SHA-256 hash of the provided byte array.
      • getCanonicalizedQueryString

        public static String getCanonicalizedQueryString​(Map<String,​String> queryParameters)
        Constructs the canonicalized query string for a request.
        queryParameters - The query parameters in the request.
        The canonicalized query string for the request.
      • hash

        public static byte[] hash​(byte[] data)
        Hashes the provided byte array using the SHA-256 algorithm.
        data - The byte array to hash.
        Hashed string contents of the provided byte array.