public class EcJwkGenerator
{
public static EllipticCurveJsonWebKey generateJwk(ECParameterSpec spec) throws JoseException
{
EcKeyUtil keyUtil = new EcKeyUtil();
KeyPair keyPair = keyUtil.generateKeyPair(spec);
PublicKey publicKey = keyPair.getPublic();
EllipticCurveJsonWebKey ecJwk = (EllipticCurveJsonWebKey) PublicJsonWebKey.Factory.newPublicJwk(publicKey);
ecJwk.setPrivateKey(keyPair.getPrivate());
return ecJwk;
}