Hi Matteo,

You could use the standard way of generating Random keys in Java and
combine it with the CXF API to write out the json equivalent. For example:

KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
KeyPair keyPair = kpg.generateKeyPair();

JsonWebKey jsonWebKey =
JwkUtils.fromRSAPublicKey(((RSAPublicKey)keyPair.getPublic()),
(String)null);
JwkReaderWriter writer = new JwkReaderWriter();
String json = writer.jwkToJson(jsonWebKey);
System.out.println("JSON: " + json);

Colm.


On Tue, Apr 21, 2020 at 9:02 AM Matteo Alessandroni <[email protected]>
wrote:

> Hi,
>
> is it possible to have a snippet on how to generate random JWK keys
> (e.g. the JSON on [1])?
>
> I was checking the official reference on [2], but could not figure out
> how to do that.
>
> Thanks
>
> [1]
>
> https://raw.githubusercontent.com/apache/cxf/master/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/certs/jwkPublicSet.txt
> [2] https://cxf.apache.org/docs/jax-rs-jose.html#JAX-RSJOSE-JWKKeys
>

Reply via email to