code: static String createAuthorizationSignatureV4(
              HttpServletRequest request, S3AuthorizationHeader authHeader,
              byte[] payload, String uri, String credential)
              throws InvalidKeyException, IOException, NoSuchAlgorithmException,
              S3Exception {
          String canonicalRequest = createCanonicalRequest(request, uri, payload,
                  authHeader.hashAlgorithm);
          String algorithm = authHeader.hmacAlgorithm;
          byte[] dateKey = signMessage(
                  authHeader.date.getBytes(StandardCharsets.UTF_8),
                  ("AWS4" + credential).getBytes(StandardCharsets.UTF_8),
                  algorithm);
          byte[] dateRegionKey = signMessage(
                  authHeader.region.getBytes(StandardCharsets.UTF_8), dateKey,
                  algorithm);
          byte[] dateRegionServiceKey = signMessage(
                  authHeader.service.getBytes(StandardCharsets.UTF_8),
                  dateRegionKey, algorithm);
          byte[] signingKey = signMessage(
                  "aws4_request".getBytes(StandardCharsets.UTF_8),
                  dateRegionServiceKey, algorithm);
          String date = request.getHeader(AwsHttpHeaders.DATE);
          if (date == null) {
              date = request.getParameter("X-Amz-Date");
          }
          String signatureString = "AWS4-HMAC-SHA256\n" +
                  date + "\n" +
                  authHeader.date + "/" + authHeader.region +
                  "/s3/aws4_request\n" +
                  canonicalRequest;
          byte[] signature = signMessage(
                  signatureString.getBytes(StandardCharsets.UTF_8),
                  signingKey, algorithm);
          return BaseEncoding.base16().lowerCase().encode(signature);
      }
docs: Create v4 signature.  Reference:
  http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html