alias = (String)aliases.nextElement();
getLogger().info("Keystore contains alias: "+alias);
length++;
}
if (length > 1) {
throw new ErrorAdminCommandException("Keystore contains more than one alias, alias must be provided as argument.");
} else if (length < 1) {
throw new ErrorAdminCommandException("Keystore does not contains any aliases. It can not be used for a CA.");
}
// else alias already contains the only alias, so we can use that
}
ejb.getCAAdminSession().importCAFromKeyStore(getAdmin(), caName, keystorebytes, kspwd, kspwd, alias, encryptionAlias);
} else {
// Import HSM keystore
// "Usage2: CA importca <CA name> <catokenclasspath> <catokenpassword> <catokenproperties> <ca-certificate-file>\n" +
String tokenclasspath = args[2];
String tokenpwd = args[3];
String catokenproperties = new String(FileTools.readFiletoBuffer(args[4]));
Collection<Certificate> cacerts = CertTools.getCertsFromPEM(args[5]);
Certificate[] cacertarray = cacerts.toArray(new Certificate[0]);
ejb.getCAAdminSession().importCAFromHSM(getAdmin(), caName, cacertarray, tokenpwd, tokenclasspath, catokenproperties);
}
} catch (ErrorAdminCommandException e) {
throw e;
} catch (Exception e) {
throw new ErrorAdminCommandException(e);
}
}