public static Jose4jRsaJWK getInstance(int size, String alg, String use, String type) {

        String kid = RandomUtils.getRandomAlphaNumeric(KID_LENGTH);
        KeyPairGenerator keyGenerator = null;
        try {
            keyGenerator = KeyPairGenerator.getInstance("RSA");
        } catch (NoSuchAlgorithmException e) {
            // This should not happen, since we hardcoded as "RSA"
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "Caught unexpected exception: " + e.getLocalizedMessage(), e);
            }
            return null;
        }

        keyGenerator.initialize(size);
        KeyPair keypair = keyGenerator.generateKeyPair();

        RSAPublicKey pubKey = (RSAPublicKey) keypair.getPublic();
        RSAPrivateKey priKey = (RSAPrivateKey) keypair.getPrivate();
        Jose4jRsaJWK jwk = new Jose4jRsaJWK(pubKey);

        jwk.setPrivateKey(priKey);
        jwk.setAlgorithm(alg);
        jwk.setKeyId(kid);
        jwk.setUse((use == null) ? JwkConstants.sig : use);

        return jwk;
    }
public static Jose4jRsaJWK getInstance ( int size , String alg , String use , String type ) { String kid = RandomUtils . getRandomAlphaNumeric ( KID_LENGTH ) ; KeyPairGenerator keyGenerator = null ; try { keyGenerator = KeyPairGenerator . getInstance ( "RSA" ) ; } catch ( NoSuchAlgorithmException e ) { if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Caught unexpected exception: " + e . getLocalizedMessage ( ) , e ) ; } return null ; } keyGenerator . initialize ( size ) ; KeyPair keypair = keyGenerator . generateKeyPair ( ) ; RSAPublicKey pubKey = ( RSAPublicKey ) keypair . getPublic ( ) ; RSAPrivateKey priKey = ( RSAPrivateKey ) keypair . getPrivate ( ) ; Jose4jRsaJWK jwk = new Jose4jRsaJWK ( pubKey ) ; jwk . setPrivateKey ( priKey ) ; jwk . setAlgorithm ( alg ) ; jwk . setKeyId ( kid ) ; jwk . setUse ( ( use == null ) ? JwkConstants . sig : use ) ; return jwk ; }
generate a new JWK with the specified parameters

@param size
@param alg
@param use
@param type
@return