cat.debug(">createUser: username=" + username + ", hiddenpwd, keys=" + rsaKeys.toString());
log.debug(">createUser: username=" + username + ", hiddenpwd, keys=" + rsaKeys.toString());
    private void createUser(String username, String password, KeyPair rsaKeys, boolean createJKS, boolean createPEM)      throws Exception {        cat.debug(">createUser: username=" + username + ", hiddenpwd, keys=" + rsaKeys.toString());        // Send the certificate request to the CA        ISignSessionRemote ss = signhome.create();        X509Certificate cert = (X509Certificate)ss.createCertificate(administrator, username, password, rsaKeys.getPublic());        // Make a certificate chain from the certificate and the CA-certificate        CertificateFactory cf = CertificateFactory.getInstance("X.509");        Certificate[] cachain = getCACertChain();        // Verify CA-certificate        if (CertTools.isSelfSigned((X509Certificate)cachain[cachain.length-1])) {            try {                cachain[cachain.length-1].verify(cachain[cachain.length-1].getPublicKey());            } catch (GeneralSecurityException se) {                throw new Exception("RootCA certificate does not verify");            }        }        else            throw new Exception("RootCA certificate not self-signed");        // Verify that the user-certificate is signed by our CA        try {            cert.verify(cachain[0].getPublicKey());        } catch (GeneralSecurityException se) {            throw new Exception("Generated certificate does not verify using CA-certificate.");        }        // Use CommonName as alias in the keystore        //String alias = CertTools.getPartFromDN(cert.getSubjectDN().toString(), "CN");        // Use username as alias in the keystore        String alias = username;        // Store keys and certificates in keystore.        KeyStore ks = null;        if (createJKS)            ks = KeyTools.createJKS(alias, rsaKeys.getPrivate(), password, cert, cachain);        else            ks = KeyTools.createP12(alias, rsaKeys.getPrivate(), cert, cachain);        storeKeyStore(ks, username, password, createJKS, createPEM);        cat.info("Created Keystore for " + username+ ".");        cat.debug("<createUser: username=" + username + ", hiddenpwd, keys=" + rsaKeys.toString());    } // createUser