Class Signer


  • public class Signer
    extends java.lang.Object
    It is an intentional part of the design that the same Signer instance can be reused on several HTTP Messages in a multi-threaded fashion

    The supplied Signature instance will be used as the basis for all future signatures created from this Signer.

    Each call to 'sign' will emit a Signature with the same 'keyId', 'algorithm', 'headers' but a newly calculated 'signature'

    • Constructor Summary

      Constructors 
      Constructor Description
      Signer​(java.security.Key key, Signature signature)  
      Signer​(java.security.Key key, Signature signature, java.security.Provider provider)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String createSigningString​(java.lang.String method, java.lang.String uri, java.util.Map<java.lang.String,​java.lang.String> headers)
      Create and return the string which is used as input for the cryptographic signature.
      java.lang.String createSigningString​(java.lang.String method, java.lang.String uri, java.util.Map<java.lang.String,​java.lang.String> headers, java.lang.Long created, java.lang.Long expires)
      Create and return the string which is used as input for the cryptographic signature.
      Signature sign​(java.lang.String method, java.lang.String uri, java.util.Map<java.lang.String,​java.lang.String> headers)
      Create and return a HTTP signature object.
      • Methods inherited from class java.lang.Object

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

      • Signer

        public Signer​(java.security.Key key,
                      Signature signature)
      • Signer

        public Signer​(java.security.Key key,
                      Signature signature,
                      java.security.Provider provider)
    • Method Detail

      • sign

        public Signature sign​(java.lang.String method,
                              java.lang.String uri,
                              java.util.Map<java.lang.String,​java.lang.String> headers)
                       throws java.io.IOException
        Create and return a HTTP signature object.
        Parameters:
        method - The HTTP method.
        uri - The path and query of the request target of the message. The value must already be encoded exactly as it will be sent in the request line of the HTTP message. No URL encoding is performed by this method.
        headers - The HTTP headers.
        Returns:
        a Signature object containing the signed message.
        Throws:
        java.io.IOException
      • createSigningString

        public java.lang.String createSigningString​(java.lang.String method,
                                                    java.lang.String uri,
                                                    java.util.Map<java.lang.String,​java.lang.String> headers,
                                                    java.lang.Long created,
                                                    java.lang.Long expires)
                                             throws java.io.IOException
        Create and return the string which is used as input for the cryptographic signature.
        Parameters:
        method - The HTTP method.
        uri - The path and query of the request target of the message. The value must already be encoded exactly as it will be sent in the request line of the HTTP message. No URL encoding is performed by this method.
        headers - The HTTP headers.
        created - The time when the signature is created.
        expires - The time when the signature expires.
        Returns:
        The signing string.
        Throws:
        java.io.IOException - when an exception occurs while creating the signing string.
      • createSigningString

        public java.lang.String createSigningString​(java.lang.String method,
                                                    java.lang.String uri,
                                                    java.util.Map<java.lang.String,​java.lang.String> headers)
                                             throws java.io.IOException
        Create and return the string which is used as input for the cryptographic signature.
        Parameters:
        method - The HTTP method.
        uri - The URI path and query parameters.
        headers - The HTTP headers.
        Returns:
        The signing string.
        Throws:
        java.io.IOException - when an exception occurs while creating the signing string.