private static String buildCanonicalHeaders(HttpServletRequest request,
            List<String> signedHeaders) {
        List<String> headers = new ArrayList<>(
                /*initialCapacity=*/ signedHeaders.size());
        for (String header : signedHeaders) {
            headers.add(header.toLowerCase());
        }
        Collections.sort(headers);

        var headersWithValues = new StringBuilder();
        boolean firstHeader = true;
        for (String header : headers) {
            if (firstHeader) {
                firstHeader = false;
            } else {
                headersWithValues.append('\n');
            }
            headersWithValues.append(header);
            headersWithValues.append(':');

            boolean firstValue = true;
            for (String value : Collections.list(request.getHeaders(header))) {
                if (firstValue) {
                    firstValue = false;
                } else {
                    headersWithValues.append(',');
                }
                value = value.trim();
                if (!value.startsWith("\"")) {
                    value = REPEATING_WHITESPACE.matcher(value).replaceAll(" ");
                }
                headersWithValues.append(value);
            }
        }

        return headersWithValues.toString();
    }
Create Amazon V2 signature.  Reference:
http://docs.aws.amazon.com/general/latest/gr/signature-version-2.html
src/main/java/org/gaul/s3proxy/AwsSignature.java