RSAPublicKey rsaPublicKey = (RSAPublicKey)keyPair.getPublic();
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)keyPair.getPrivate();
// Create signer from raw Java RSA key
JWSObject jwsObject1 = new JWSObject(new JWSHeader(JWSAlgorithm.RS256), new Payload("test123"));
JWSSigner signer = new RSASSASigner(rsaPrivateKey);
jwsObject1.sign(signer);
Base64URL sig1 = jwsObject1.getSignature();
// Create signer from JWK representation
RSAKey rsaJWK = new RSAKey.Builder(rsaPublicKey).privateKey(rsaPrivateKey).build();