public static JsonWebKey generateJsonWebKey ( ) { try { final KeyPairGenerator generator = KeyPairGenerator . getInstance ( "RSA" ) ; generator . initialize ( 2048 ) ; KeyPair clientRsaKeyPair = generator . generateKeyPair ( ) ; JsonWebKey result = JsonWebKey . fromRSA ( clientRsaKeyPair ) ; result . withKid ( UUID . randomUUID ( ) . toString ( ) ) ; return result ; } catch ( NoSuchAlgorithmException e ) { // Unexpected. Should never be thrown. throw new RuntimeException ( e ) ; } }
Generates new JsonWebKey with random KeyID .