Class HMACAlgorithm

    • Field Detail

      • secret

        private final byte[] secret
    • Constructor Detail

      • HMACAlgorithm

        HMACAlgorithm​(CryptoHelper crypto,
                      java.lang.String id,
                      java.lang.String algorithm,
                      byte[] secretBytes)
               throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • HMACAlgorithm

        HMACAlgorithm​(java.lang.String id,
                      java.lang.String algorithm,
                      byte[] secretBytes)
               throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • HMACAlgorithm

        HMACAlgorithm​(java.lang.String id,
                      java.lang.String algorithm,
                      java.lang.String secret)
               throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
    • Method Detail

      • getSecretBytes

        static byte[] getSecretBytes​(java.lang.String secret)
                              throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • sign

        public byte[] sign​(byte[] headerBytes,
                           byte[] payloadBytes)
                    throws SignatureGenerationException
        Description copied from class: Algorithm
        Sign the given content using this Algorithm instance.
        Overrides:
        sign in class Algorithm
        Parameters:
        headerBytes - an array of bytes representing the base64 encoded header content to be verified against the signature.
        payloadBytes - an array of bytes representing the base64 encoded payload content to be verified against the signature.
        Returns:
        the signature in a base64 encoded array of bytes
        Throws:
        SignatureGenerationException - if the Key is invalid.
      • sign

        @Deprecated
        public byte[] sign​(byte[] contentBytes)
                    throws SignatureGenerationException
        Deprecated.
        Description copied from class: Algorithm
        Sign the given content using this Algorithm instance.
        Specified by:
        sign in class Algorithm
        Parameters:
        contentBytes - an array of bytes representing the base64 encoded content to be verified against the signature.
        Returns:
        the signature in a base64 encoded array of bytes
        Throws:
        SignatureGenerationException - if the Key is invalid.