Class AwsUtils


  • public class AwsUtils
    extends java.lang.Object
    Provides utility functions for implementing the Amazon S3 Authentication scheme.
    See Also:
    Authenticating REST Requests
    • Constructor Summary

      Constructors 
      Constructor Description
      AwsUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getCanonicalizedAmzHeaders​(Series<Header> requestHeaders)
      Returns the canonicalized AMZ headers.
      static java.lang.String getCanonicalizedResourceName​(Reference reference)
      Returns the canonicalized resource name.
      static java.lang.String getHmacSha1Signature​(java.lang.String stringToSign, char[] secret)
      Returns the AWS authentication compatible signature for the given string to sign and secret.
      static java.lang.String getHmacSha256Signature​(java.lang.String stringToSign, char[] secret)
      Returns the AWS authentication compatible signature for the given string to sign and secret.
      static java.lang.String getQuerySignature​(Method method, Reference resourceRef, java.util.List<Parameter> params, char[] secret)
      Returns the AWS SimpleDB authentication compatible signature for the given request and secret.
      static java.lang.String getQueryStringToSign​(Method method, Reference resourceRef, java.util.List<Parameter> params)
      Returns the SimpleDB string to sign.
      static java.lang.String getS3Signature​(Request request, char[] secret)
      Returns the AWS S3 authentication compatible signature for the given request and secret.
      static java.lang.String getS3Signature​(Request request, Series<Header> headers, char[] secret)
      Returns the AWS S3 authentication compatible signature for the given request and secret.
      static java.lang.String getS3StringToSign​(Request request)
      Returns the string to sign.
      static java.lang.String getS3StringToSign​(Request request, Series<Header> headers)
      Returns the S3 string to sign.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AwsUtils

        public AwsUtils()
    • Method Detail

      • getCanonicalizedAmzHeaders

        public static java.lang.String getCanonicalizedAmzHeaders​(Series<Header> requestHeaders)
        Returns the canonicalized AMZ headers.
        Parameters:
        requestHeaders - The list of request headers.
        Returns:
        The canonicalized AMZ headers.
      • getCanonicalizedResourceName

        public static java.lang.String getCanonicalizedResourceName​(Reference reference)
        Returns the canonicalized resource name.
        Parameters:
        reference - The resource reference
        Returns:
        The canonicalized resource name.
      • getHmacSha1Signature

        public static java.lang.String getHmacSha1Signature​(java.lang.String stringToSign,
                                                            char[] secret)
        Returns the AWS authentication compatible signature for the given string to sign and secret.
        Parameters:
        stringToSign - The string to sign.
        secret - The user secret to sign with
        Returns:
        The AWS compatible signature
      • getHmacSha256Signature

        public static java.lang.String getHmacSha256Signature​(java.lang.String stringToSign,
                                                              char[] secret)
        Returns the AWS authentication compatible signature for the given string to sign and secret.
        Parameters:
        stringToSign - The string to sign.
        secret - The user secret to sign with
        Returns:
        The AWS compatible signature
      • getQuerySignature

        public static java.lang.String getQuerySignature​(Method method,
                                                         Reference resourceRef,
                                                         java.util.List<Parameter> params,
                                                         char[] secret)
        Returns the AWS SimpleDB authentication compatible signature for the given request and secret.
        Parameters:
        method - The request method.
        resourceRef - The target resource reference.
        params - The request parameters.
        secret - The user secret to sign with
        Returns:
        The AWS SimpleDB compatible signature
      • getQueryStringToSign

        public static java.lang.String getQueryStringToSign​(Method method,
                                                            Reference resourceRef,
                                                            java.util.List<Parameter> params)
        Returns the SimpleDB string to sign.
        Parameters:
        resourceRef - The target resource reference.
        Returns:
        The string to sign.
      • getS3Signature

        public static java.lang.String getS3Signature​(Request request,
                                                      char[] secret)
        Returns the AWS S3 authentication compatible signature for the given request and secret.
        Parameters:
        request - The request to create the signature for
        secret - The user secret to sign with
        Returns:
        The AWS S3 compatible signature
      • getS3Signature

        public static java.lang.String getS3Signature​(Request request,
                                                      Series<Header> headers,
                                                      char[] secret)
        Returns the AWS S3 authentication compatible signature for the given request and secret.
        Parameters:
        request - The request to create the signature for
        headers - The HTTP headers associated with the request
        secret - The user secret to sign with
        Returns:
        The AWS S3 compatible signature
      • getS3StringToSign

        public static java.lang.String getS3StringToSign​(Request request)
        Returns the string to sign.
        Parameters:
        request - The request to generate the signature string from
        Returns:
        The string to sign
      • getS3StringToSign

        public static java.lang.String getS3StringToSign​(Request request,
                                                         Series<Header> headers)
        Returns the S3 string to sign.
        Parameters:
        request - The request to generate the signature string from
        headers - The HTTP headers associated with the request
        Returns:
        The string to sign