try {
final String caname = args[5];
final String dn = CertTools.stringToBCDNString(StringTools.strip(args[6]));
final int validity = Integer.parseInt(args[7]);
HardCATokenInfo catokeninfo = new HardCATokenInfo();
byte keyStoreID[];{
KeyStoreContainer ksc = KeyStoreContainerFactory.getInstance(args[4],args[2], args[3], args.length>8 ? args[8] : null, null, null);
ksc.generate("2048", DEFAULT_KEY);
ksc.generate("2048", SIGN_KEY);
keyStoreID = ksc.storeKeyStore();
catokeninfo.setAuthenticationCode(new String(ksc.getPassPhraseGetSetEntry()));
}
getLogger().info("Initializing CA");
getLogger().info("Generating rootCA keystore:");
getLogger().info("CA name: "+caname);
getLogger().info("DN: "+dn);
getLogger().info("Validity (days): "+validity);
catokeninfo.setSignatureAlgorithm(AlgorithmConstants.SIGALG_SHA1_WITH_RSA);
catokeninfo.setEncryptionAlgorithm(AlgorithmConstants.SIGALG_SHA1_WITH_RSA);
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
pw.println(KeyStrings.CAKEYPURPOSE_DEFAULT_STRING+" "+DEFAULT_KEY);
pw.println(KeyStrings.CAKEYPURPOSE_CERTSIGN_STRING+" "+SIGN_KEY);
pw.println(NFastCAToken.SLOT_LABEL_KEY+" "+new String(keyStoreID));
pw.close();
catokeninfo.setProperties(sw.toString());
}
catokeninfo.setClassPath(org.ejbca.core.model.ca.catoken.NFastCAToken.class.getName());
X509CAInfo cainfo = new X509CAInfo(dn,
caname, SecConst.CA_ACTIVE, new Date(),
"", SecConst.CERTPROFILE_FIXED_ROOTCA,
validity,
null, // Expiretime