* @throws NoSuchProviderException provider not found
*/
public static Credential generateKeyPairAndCredential(String algorithmURI, int keyLength, boolean includePrivate)
throws NoSuchAlgorithmException, NoSuchProviderException {
KeyPair keyPair = generateKeyPairFromURI(algorithmURI, keyLength);
BasicCredential credential = new BasicCredential();
credential.setPublicKey(keyPair.getPublic());
if (includePrivate) {
credential.setPrivateKey(keyPair.getPrivate());
}
return credential;
}