Class V4CanonicalRequest

java.lang.Object
software.amazon.awssdk.http.auth.aws.internal.signer.V4CanonicalRequest

@Immutable public final class V4CanonicalRequest extends Object
A class that represents a canonical request in AWS, as documented:

https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html#create-canonical-request

  • Constructor Details

    • V4CanonicalRequest

      public V4CanonicalRequest(SdkHttpRequest request, String contentHash, V4CanonicalRequest.Options options)
      Create a canonical request.

      Each parameter of a canonical request is set upon creation of this object.

      To get such a parameter (i.e. the canonical request string), simply call the getter for that parameter (i.e. getCanonicalRequestString())

  • Method Details

    • getSignedHeadersString

      public String getSignedHeadersString()
      Get the string representing which headers are part of the signing process. Header names are separated by a semicolon.
    • getCanonicalRequestString

      public String getCanonicalRequestString()
      Get the canonical request string.
    • getCanonicalHeaders

      public static List<Pair<String,List<String>>> getCanonicalHeaders(SdkHttpRequest request)
      Get the list of headers that are to be signed.

      If calling from a site with the request object handy, this method should be used instead of passing the headers themselves, as doing so creates a redundant copy.

    • getCanonicalHeaders

      public static List<Pair<String,List<String>>> getCanonicalHeaders(Map<String,List<String>> headers)
      Get the list of headers that are to be signed. The supplied map of headers is expected to be sorted case-insensitively.
    • getCanonicalHeadersString

      public static String getCanonicalHeadersString(List<Pair<String,List<String>>> canonicalHeaders)
      Get the string representing the headers that will be signed and their values. The input list is expected to be sorted case-insensitively.

      The output string will have header names as lower-case, sorted in alphabetical order, and followed by a colon.

      Values are trimmed of any leading/trailing spaces, sequential spaces are converted to single space, and multiple values are comma separated.

      Each header-value pair is separated by a newline.

    • getSignedHeadersString

      public static String getSignedHeadersString(List<Pair<String,List<String>>> canonicalHeaders)
      Get the string representing which headers are part of the signing process. Header names are separated by a semicolon.