*/
private String generateKeyPair() throws Exception {
String domainName = SAMLSSOUtil.getRealmService().getTenantManager().getDomain(registry.getTenantId());
//load keystore
X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
KeyStoreManager keyMan = KeyStoreManager.getInstance(null);
KeyStore keyStore = keyMan.getKeyStore("userSSO.jks");
//generate keypair
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(1024);
KeyPair keyPair = keyPairGenerator.generateKeyPair();
v3CertGen.setSerialNumber(BigInteger.valueOf(new SecureRandom().nextInt()));
v3CertGen.setIssuerDN(new X509Principal("CN=" + domainName + ", OU=None, O=None L=None, C=None"));
v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365 * 10)));
v3CertGen.setSubjectDN(new X509Principal("CN=" + domainName + ", OU=None, O=None L=None, C=None"));
v3CertGen.setPublicKey(keyPair.getPublic());
v3CertGen.setSignatureAlgorithm("MD5WithRSAEncryption");
X509Certificate PKCertificate = v3CertGen.generateX509Certificate(keyPair.getPrivate());
//Generate the password
SecureRandom random = new SecureRandom();
String randString = new BigInteger(130, random).toString(12);
String password = randString.substring(randString.length() - 10, randString.length());