@Test public void test_allKeyType() { ObjectNode rsaKey = Json.mapper.createObjectNode() .put("kty","RSA") .put("kid","rsaKid") .put("use","enc") .put("e","AQAB") .put("n","v_UAFh4B6IFobGMzIMsE0Fuel5iEtT9a15kI1cdnAdj-ojw0O8q3AT_0dfEW-s9mJdBXsI5pWCzbYcqd2olCM0zV7fck4DmgD63bXjP8bycly4ggMlOwZM9ZH7k4zIntb9_8PKWjBQpekyVIo9rEpSfABc0U0c_emrk1arsGYD1pTGoXk-XS1NY7RS2bdVzPUPfM5iS-iwGch7TVPV3-6fE9eWDo8TpOkJDkZDzzxiY_dJTsr9A2aKbU71c0AHg26tluv3glT13NTct2YzLBG1LnVgR3i_Aoh9Jn08QrHt2NfHoNzykqEAxZqOylyzxdO__KokZS2wkqklIidvbmYw"); ObjectNode ecKey = Json.mapper.createObjectNode() .put("kty","EC") .put("kid","ecKid") .put("use","enc") .put("crv","P-256") .put("x","vBT2JhFHd62Jcf4yyBzSV9NuDBNBssR1zlmnHelgZcs") .put("y","up8E8b3TjeKS2v2GCH23UJP0bak0La77lkQ7_n4djqE"); ObjectNode okpKey = Json.mapper.createObjectNode() .put("kty","OKP") .put("kid","okpKid") .put("use","enc") .put("crv","X25519") .put("x","vBNW8f19leF79U4U6NrDDQaK_i5kL0iMKghB39AUT2I"); ObjectNode octKey = Json.mapper.createObjectNode() .put("kty","oct") .put("kid","octKid") .put("use","sig") .put("alg","HS256") .put("k","FdFYFzERwC2uCBB46pZQi4GG85LujR8obt-KWRBICVQ"); ArrayNode arrayNode = Json.mapper.createArrayNode() .add(rsaKey) .add(ecKey) .add(okpKey) .add(octKey); ObjectNode root = Json.mapper.createObjectNode(); root.set("keys",arrayNode); Optional<JWKSet> result = new JWKSetDeserializer().convert(root); assertTrue("Was expecting a result",result.isPresent()); }
@Override public Optional<JWKSet> convert(ObjectNode node) { if (node == null) { return null; } if (node.get("keys") == null || node.get("keys").isNull() || node.get("keys").equals(new TextNode("null")) || node.get("keys").equals(new TextNode("")) ) { return Optional.empty(); } return convert(node.toString()); }
JWKSetDeserializer extends StdConverter<ObjectNode, Optional<JWKSet>> { @Override public Optional<JWKSet> convert(ObjectNode node) { if (node == null) { return null; } if (node.get("keys") == null || node.get("keys").isNull() || node.get("keys").equals(new TextNode("null")) || node.get("keys").equals(new TextNode("")) ) { return Optional.empty(); } return convert(node.toString()); } }
JWKSetDeserializer extends StdConverter<ObjectNode, Optional<JWKSet>> { @Override public Optional<JWKSet> convert(ObjectNode node) { if (node == null) { return null; } if (node.get("keys") == null || node.get("keys").isNull() || node.get("keys").equals(new TextNode("null")) || node.get("keys").equals(new TextNode("")) ) { return Optional.empty(); } return convert(node.toString()); }  }
JWKSetDeserializer extends StdConverter<ObjectNode, Optional<JWKSet>> { @Override public Optional<JWKSet> convert(ObjectNode node) { if (node == null) { return null; } if (node.get("keys") == null || node.get("keys").isNull() || node.get("keys").equals(new TextNode("null")) || node.get("keys").equals(new TextNode("")) ) { return Optional.empty(); } return convert(node.toString()); }  @Override Optional<JWKSet> convert(ObjectNode node); Optional<JWKSet> convert(String jwkSetAsString); }
JWKSetDeserializer extends StdConverter<ObjectNode, Optional<JWKSet>> { @Override public Optional<JWKSet> convert(ObjectNode node) { if (node == null) { return null; } if (node.get("keys") == null || node.get("keys").isNull() || node.get("keys").equals(new TextNode("null")) || node.get("keys").equals(new TextNode("")) ) { return Optional.empty(); } return convert(node.toString()); }  @Override Optional<JWKSet> convert(ObjectNode node); Optional<JWKSet> convert(String jwkSetAsString); final static String PARSE_ERROR_MESSAGE; }