public static String generateJwk(PublicKey longKey, String longKeyId, PublicKey currKey, String currKeyId, PublicKey prevKey, String prevKeyId) {
        List<JsonWebKey> jwkList = new ArrayList<>();
        try {
            // Create a JWK object from the long live public key
            PublicJsonWebKey jwk = PublicJsonWebKey.Factory.newPublicJwk(longKey);
            jwk.setKeyId(longKeyId);
            jwkList.add(jwk);
            // Create a JWK object from the current public key
            jwk = PublicJsonWebKey.Factory.newPublicJwk(currKey);
            jwk.setKeyId(currKeyId);
            jwkList.add(jwk);
            // Create a JWK object from the previous public key
            if(prevKey != null && prevKeyId != null) {
                jwk = PublicJsonWebKey.Factory.newPublicJwk(prevKey);
                jwk.setKeyId(prevKeyId);
                jwkList.add(jwk);
            }
        } catch (JoseException e) {
            logger.error("Exception:", e);
        }
        // create a JsonWebKeySet object with the list of JWK objects
        JsonWebKeySet jwks = new JsonWebKeySet(jwkList);
        // and output the JSON of the JWKS
        return jwks.toJson(JsonWebKey.OutputControlLevel.PUBLIC_ONLY);
    }
@Test
    public void testGenerateJwk() throws Exception {
        KeyPair longKeyPair = KeyUtil.generateKeyPair("RSA", 2048);
        String longKeyId = HashUtil.generateUUID();
        System.out.println("longKeyId = " + longKeyId);
        String publicKey = KeyUtil.serializePublicKey(longKeyPair.getPublic());
        System.out.println("long public key = " + publicKey);
        String privateKey = KeyUtil.serializePrivateKey(longKeyPair.getPrivate());
        System.out.println("long private key = " + privateKey);

        KeyPair currKeyPair = KeyUtil.generateKeyPair("RSA", 2048);
        String currKeyId = HashUtil.generateUUID();
        System.out.println("currKeyId = " + currKeyId);
        publicKey = KeyUtil.serializePublicKey(currKeyPair.getPublic());
        System.out.println("curr public key = " + publicKey);
        privateKey = KeyUtil.serializePrivateKey(currKeyPair.getPrivate());
        System.out.println("curr private key = " + privateKey);

        String jwk = KeyUtil.generateJwk(longKeyPair.getPublic(), longKeyId, currKeyPair.getPublic(), currKeyId, null, null);
        System.out.println("jwk = " + jwk);
    }