public void testFullConstructorAndSerializationWithOps()
throws Exception {
URL x5u = new URL("http://example.com/jwk.json");
Base64URL x5t = new Base64URL("abc");
List<Base64> x5c = new LinkedList<>();
x5c.add(new Base64("def"));
KeyUse use = null;
Set<KeyOperation> ops = new LinkedHashSet<>(Arrays.asList(KeyOperation.SIGN, KeyOperation.VERIFY));
ECKey key = new ECKey(ExampleKeyP256.CRV, ExampleKeyP256.X, ExampleKeyP256.Y, ExampleKeyP256.D,
use, ops, JWSAlgorithm.ES256, "1", x5u, x5t, x5c);
// Test getters
assertNull(key.getKeyUse());
assertTrue(key.getKeyOperations().contains(KeyOperation.SIGN));
assertTrue(key.getKeyOperations().contains(KeyOperation.VERIFY));
assertEquals(2, key.getKeyOperations().size());
assertEquals(JWSAlgorithm.ES256, key.getAlgorithm());
assertEquals("1", key.getKeyID());
assertEquals(x5u.toString(), key.getX509CertURL().toString());
assertEquals(x5t.toString(), key.getX509CertThumbprint().toString());
assertEquals(x5c.size(), key.getX509CertChain().size());
assertEquals(ECKey.Curve.P_256, key.getCurve());
assertEquals(ExampleKeyP256.X, key.getX());
assertEquals(ExampleKeyP256.Y, key.getY());
assertEquals(ExampleKeyP256.D, key.getD());
assertTrue(key.isPrivate());
String jwkString = key.toJSONObject().toString();
key = ECKey.parse(jwkString);
// Test getters
assertNull(key.getKeyUse());
assertTrue(key.getKeyOperations().contains(KeyOperation.SIGN));
assertTrue(key.getKeyOperations().contains(KeyOperation.VERIFY));
assertEquals(2, key.getKeyOperations().size());
assertEquals(JWSAlgorithm.ES256, key.getAlgorithm());
assertEquals("1", key.getKeyID());
assertEquals(ECKey.Curve.P_256, key.getCurve());
assertEquals(ExampleKeyP256.X, key.getX());
assertEquals(ExampleKeyP256.Y, key.getY());
assertEquals(ExampleKeyP256.D, key.getD());
assertTrue(key.isPrivate());
// Test conversion to public JWK
key = key.toPublicJWK();
assertNull(key.getKeyUse());
assertTrue(key.getKeyOperations().contains(KeyOperation.SIGN));
assertTrue(key.getKeyOperations().contains(KeyOperation.VERIFY));
assertEquals(2, key.getKeyOperations().size());
assertEquals(JWSAlgorithm.ES256, key.getAlgorithm());
assertEquals("1", key.getKeyID());
assertEquals(x5u.toString(), key.getX509CertURL().toString());
assertEquals(x5t.toString(), key.getX509CertThumbprint().toString());
assertEquals(x5c.size(), key.getX509CertChain().size());
assertEquals(ECKey.Curve.P_256, key.getCurve());
assertEquals(ExampleKeyP256.X, key.getX());
assertEquals(ExampleKeyP256.Y, key.getY());