h.setJWK(jwk);
h.setX509CertURL(new URL("https://example/cert.b64"));
h.setX509CertThumbprint(new Base64URL("789iop"));
List<Base64> certChain = new LinkedList<Base64>();
certChain.add(new Base64("asd"));
certChain.add(new Base64("fgh"));
certChain.add(new Base64("jkl"));
h.setX509CertChain(certChain);
h.setAgreementPartyUInfo(new Base64URL("abc"));
h.setAgreementPartyVInfo(new Base64URL("xyz"));
h.setPBES2Salt(new Base64URL("omg"));
h.setPBES2Count(1000);
String s = h.toString();
// Parse back
h = JWEHeader.parse(s);
assertEquals(JWEAlgorithm.RSA1_5, h.getAlgorithm());
assertEquals(new JOSEObjectType("JWT"), h.getType());
assertEquals(EncryptionMethod.A256GCM, h.getEncryptionMethod());
assertEquals(CompressionAlgorithm.DEF, h.getCompressionAlgorithm());
assertEquals(new URL("https://example.com/jku.json"), h.getJWKURL());
assertEquals("1234", h.getKeyID());
jwk = (RSAKey)h.getJWK();
assertNotNull(jwk);
assertEquals(new Base64URL("abc123"), jwk.getModulus());
assertEquals(new Base64URL("def456"), jwk.getPublicExponent());
assertEquals(KeyUse.ENCRYPTION, jwk.getKeyUse());
assertEquals(JWEAlgorithm.RSA1_5, jwk.getAlgorithm());
assertEquals("1234", jwk.getKeyID());
assertEquals(new URL("https://example/cert.b64"), h.getX509CertURL());
assertEquals(new Base64URL("789iop"), h.getX509CertThumbprint());
certChain = h.getX509CertChain();
assertEquals(3, certChain.size());
assertEquals(new Base64("asd"), certChain.get(0));
assertEquals(new Base64("fgh"), certChain.get(1));
assertEquals(new Base64("jkl"), certChain.get(2));
assertEquals(new Base64URL("abc"), h.getAgreementPartyUInfo());
assertEquals(new Base64URL("xyz"), h.getAgreementPartyVInfo());
assertEquals(new Base64URL("omg"), h.getPBES2Salt());