JoseUtils { public static Map<String, Object> publicKeyToJWK(PublicKey key) { try { return PublicJsonWebKey.Factory.newPublicJwk(key) .toParams(JsonWebKey.OutputControlLevel.PUBLIC_ONLY); } catch (JoseException ex) { throw new IllegalArgumentException("Bad public key", ex); } } private  JoseUtils(); static JSONBuilder createJoseRequest(URL url, KeyPair keypair,
                @Nullable JSONBuilder payload, @Nullable String nonce, @Nullable String kid); static Map<String, Object> createExternalAccountBinding(String kid,
            PublicKey accountKey, SecretKey macKey, URL resource); static Map<String, Object> publicKeyToJWK(PublicKey key); static PublicKey jwkToPublicKey(Map<String, Object> jwk); static byte[] thumbprint(PublicKey key); static String keyAlgorithm(JsonWebKey jwk); static String macKeyAlgorithm(SecretKey macKey);  }
@Test public void testPublicKeyToJWK() throws Exception { Map<String, Object> json = JoseUtils.publicKeyToJWK(TestUtils.createKeyPair().getPublic()); assertThat(json.size(), is(3)); assertThat(json.get("kty"), is(TestUtils.KTY)); assertThat(json.get("n"), is(TestUtils.N)); assertThat(json.get("e"), is(TestUtils.E)); }