File keystoreFile = new File(directory.getAbsoluteFile() + File.separator + Filename.encode(username) + ".jks");
SimpleKeystore keystore = new SimpleKeystore(keystoreFile, password);
KeyPair keypair = RsaUtil.generateRsaKeyPair(RsaUtil.MINIMUM_RSA_KEY_SIZE);
X509Certificate certificate = RsaUtil.generateX509Certificate(subject, keypair, RsaUtil.DEFAULT_RSA_KEY_EXPIRES_DAYS);
keystore.addKeyPairX509(keypair.getPrivate(), certificate, username, password);
keystore.save();
System.out.println("Created keystore: "+keystoreFile.getName());
}
}