Class JWSAssemblyUtilsTest


  • public class JWSAssemblyUtilsTest
    extends Object
    Test for JWSAssemblyUtils.
    • Field Detail

      • SIMPLE_CLAIMS_PAYLOAD

        private static final String SIMPLE_CLAIMS_PAYLOAD
        A Simple JSON claims payload from RFC7515.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JWSAssemblyUtilsTest

        public JWSAssemblyUtilsTest()
    • Method Detail

      • testAssembleMacJws

        public final void testAssembleMacJws()
                                      throws Exception
        Test JWS generation and compare the generated HMAC against a newly generated HMAC from the same set of payload and content bytes.

        Note, as there is no process of 'canonicalization' we can not reliably compare a newly generated version of this JWS using a different JWT generation method - there is no invariant form e.g. they order the claims differently. As a result, we check the HMAC(Header.Payload) by taking the header and payload bytes from the generated JWS and compare to the generated signature component from the same JWS.

        Use HMAC-SHA-256 for compatibility with the RFC.

        Throws:
        Exception - on error
      • testAssembleMacJwsCheckWithDifferentKey

        public final void testAssembleMacJwsCheckWithDifferentKey()
                                                           throws Exception
        Test verify the computed JWS HMAC using a HMAC generated with a different key. Probably little worth in this test, other than to check generation is happening using the stated key.
        Throws:
        Exception - on error
      • testAssembleMacJwsCheckWithDifferentAlgorithm

        public final void testAssembleMacJwsCheckWithDifferentAlgorithm()
                                                                 throws Exception
        Test verify the computed JWS HMAC using a HMAC generated with a different key. Probably little worth in this test, other than to check generation is happening using the stated algorithm.
        Throws:
        Exception - on error