System.out.println("Usage: CA makereq <DN> <keysize> <rootca-certificate> <request-file> <keystore-file> <storepassword>"); System.out.println("Generates a certification request for a subCA for sending to a RootCA."); return;
String msg = "Usage: CA makereq <DN> <keysize> <rootca-certificate> <request-file> <keystore-file> <storepassword>"; msg += "Generates a certification request for a subCA for sending to a RootCA."; throw new IllegalAdminCommandException(msg);
    public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException {        try {            if (args.length < 7) {                System.out.println("Usage: CA makereq <DN> <keysize> <rootca-certificate> <request-file> <keystore-file> <storepassword>");                System.out.println("Generates a certification request for a subCA for sending to a RootCA.");                return;            }            String dn = args[1];            int keysize = Integer.parseInt(args[2]);            String rootfile = args[3];            String reqfile = args[4];            String ksfile = args[5];            String storepwd = args[6];                        System.out.println("Generating cert request (and keystore):");            System.out.println("DN: "+dn);            System.out.println("Keysize: "+keysize);            System.out.println("RootCA cert file: "+rootfile);            System.out.println("Storing CertificationRequest in: "+reqfile);            System.out.println("Storing KeyStore in: "+ksfile);            System.out.println("Protected with storepassword: "+storepwd);                        // Read in RootCA certificate            X509Certificate rootcert = CertTools.getCertfromByteArray(FileTools.readFiletoBuffer(rootfile));                        // Generate keys            System.out.println("Generating keys, please wait...");            KeyPair rsaKeys = KeyTools.genKeys(keysize);            // Create selfsigned cert...            X509Certificate selfcert = CertTools.genSelfCert(dn, 365, rsaKeys.getPrivate(), rsaKeys.getPublic(), true);                        // Create certificate request            makeCertRequest(dn, rsaKeys, reqfile);                        // Create keyStore            KeyStore ks = KeyTools.createP12("privateKey", rsaKeys.getPrivate(), selfcert, rootcert);                        FileOutputStream os = new FileOutputStream(ksfile);            ks.store(os, storepwd.toCharArray());            System.out.println("Keystore '"+ksfile+"' generated succefully.");        } catch (Exception e) {            throw new ErrorAdminCommandException(e);        }    } // execute