@Test public void testExplicitCertificateChainOnlyOnSingleEntry() throws Exception { try { cli.execute("--keystore=target/test-classes/keystores/keystore.jks", "--alias=test", "--keypass=password", "--certfile=target/test-classes/keystores/jsign-test-certificate-full-chain.spc", "" + targetFile); fail("No exception thrown"); } catch (SignerException e) { assertEquals("exception message", "certfile option can only be specified if the certificate from the keystore contains only one entry", e.getMessage()); } }
void execute(String... args) throws SignerException, ParseException { DefaultParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help") || args.length == 0) { printHelp(); return; } SignerHelper helper = new SignerHelper(new StdOutConsole(1), "option"); setOption(PARAM_KEYSTORE, helper, cmd); setOption(PARAM_STOREPASS, helper, cmd); setOption(PARAM_STORETYPE, helper, cmd); setOption(PARAM_ALIAS, helper, cmd); setOption(PARAM_KEYPASS, helper, cmd); setOption(PARAM_KEYFILE, helper, cmd); setOption(PARAM_CERTFILE, helper, cmd); setOption(PARAM_ALG, helper, cmd); setOption(PARAM_TSAURL, helper, cmd); setOption(PARAM_TSMODE, helper, cmd); setOption(PARAM_TSRETRIES, helper, cmd); setOption(PARAM_TSRETRY_WAIT, helper, cmd); setOption(PARAM_NAME, helper, cmd); setOption(PARAM_URL, helper, cmd); setOption(PARAM_PROXY_URL, helper, cmd); setOption(PARAM_PROXY_USER, helper, cmd); setOption(PARAM_PROXY_PASS, helper, cmd); helper.replace(cmd.hasOption(PARAM_REPLACE)); setOption(PARAM_ENCODING, helper, cmd); File file = cmd.getArgList().isEmpty() ? null : new File(cmd.getArgList().get(0)); helper.sign(file); }
JsignCLI { void execute(String... args) throws SignerException, ParseException { DefaultParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help") || args.length == 0) { printHelp(); return; } SignerHelper helper = new SignerHelper(new StdOutConsole(1), "option"); setOption(PARAM_KEYSTORE, helper, cmd); setOption(PARAM_STOREPASS, helper, cmd); setOption(PARAM_STORETYPE, helper, cmd); setOption(PARAM_ALIAS, helper, cmd); setOption(PARAM_KEYPASS, helper, cmd); setOption(PARAM_KEYFILE, helper, cmd); setOption(PARAM_CERTFILE, helper, cmd); setOption(PARAM_ALG, helper, cmd); setOption(PARAM_TSAURL, helper, cmd); setOption(PARAM_TSMODE, helper, cmd); setOption(PARAM_TSRETRIES, helper, cmd); setOption(PARAM_TSRETRY_WAIT, helper, cmd); setOption(PARAM_NAME, helper, cmd); setOption(PARAM_URL, helper, cmd); setOption(PARAM_PROXY_URL, helper, cmd); setOption(PARAM_PROXY_USER, helper, cmd); setOption(PARAM_PROXY_PASS, helper, cmd); helper.replace(cmd.hasOption(PARAM_REPLACE)); setOption(PARAM_ENCODING, helper, cmd); File file = cmd.getArgList().isEmpty() ? null : new File(cmd.getArgList().get(0)); helper.sign(file); } }
JsignCLI { void execute(String... args) throws SignerException, ParseException { DefaultParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help") || args.length == 0) { printHelp(); return; } SignerHelper helper = new SignerHelper(new StdOutConsole(1), "option"); setOption(PARAM_KEYSTORE, helper, cmd); setOption(PARAM_STOREPASS, helper, cmd); setOption(PARAM_STORETYPE, helper, cmd); setOption(PARAM_ALIAS, helper, cmd); setOption(PARAM_KEYPASS, helper, cmd); setOption(PARAM_KEYFILE, helper, cmd); setOption(PARAM_CERTFILE, helper, cmd); setOption(PARAM_ALG, helper, cmd); setOption(PARAM_TSAURL, helper, cmd); setOption(PARAM_TSMODE, helper, cmd); setOption(PARAM_TSRETRIES, helper, cmd); setOption(PARAM_TSRETRY_WAIT, helper, cmd); setOption(PARAM_NAME, helper, cmd); setOption(PARAM_URL, helper, cmd); setOption(PARAM_PROXY_URL, helper, cmd); setOption(PARAM_PROXY_USER, helper, cmd); setOption(PARAM_PROXY_PASS, helper, cmd); helper.replace(cmd.hasOption(PARAM_REPLACE)); setOption(PARAM_ENCODING, helper, cmd); File file = cmd.getArgList().isEmpty() ? null : new File(cmd.getArgList().get(0)); helper.sign(file); } JsignCLI(); }
JsignCLI { void execute(String... args) throws SignerException, ParseException { DefaultParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help") || args.length == 0) { printHelp(); return; } SignerHelper helper = new SignerHelper(new StdOutConsole(1), "option"); setOption(PARAM_KEYSTORE, helper, cmd); setOption(PARAM_STOREPASS, helper, cmd); setOption(PARAM_STORETYPE, helper, cmd); setOption(PARAM_ALIAS, helper, cmd); setOption(PARAM_KEYPASS, helper, cmd); setOption(PARAM_KEYFILE, helper, cmd); setOption(PARAM_CERTFILE, helper, cmd); setOption(PARAM_ALG, helper, cmd); setOption(PARAM_TSAURL, helper, cmd); setOption(PARAM_TSMODE, helper, cmd); setOption(PARAM_TSRETRIES, helper, cmd); setOption(PARAM_TSRETRY_WAIT, helper, cmd); setOption(PARAM_NAME, helper, cmd); setOption(PARAM_URL, helper, cmd); setOption(PARAM_PROXY_URL, helper, cmd); setOption(PARAM_PROXY_USER, helper, cmd); setOption(PARAM_PROXY_PASS, helper, cmd); helper.replace(cmd.hasOption(PARAM_REPLACE)); setOption(PARAM_ENCODING, helper, cmd); File file = cmd.getArgList().isEmpty() ? null : new File(cmd.getArgList().get(0)); helper.sign(file); } JsignCLI(); static void main(String... args); }
JsignCLI { void execute(String... args) throws SignerException, ParseException { DefaultParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help") || args.length == 0) { printHelp(); return; } SignerHelper helper = new SignerHelper(new StdOutConsole(1), "option"); setOption(PARAM_KEYSTORE, helper, cmd); setOption(PARAM_STOREPASS, helper, cmd); setOption(PARAM_STORETYPE, helper, cmd); setOption(PARAM_ALIAS, helper, cmd); setOption(PARAM_KEYPASS, helper, cmd); setOption(PARAM_KEYFILE, helper, cmd); setOption(PARAM_CERTFILE, helper, cmd); setOption(PARAM_ALG, helper, cmd); setOption(PARAM_TSAURL, helper, cmd); setOption(PARAM_TSMODE, helper, cmd); setOption(PARAM_TSRETRIES, helper, cmd); setOption(PARAM_TSRETRY_WAIT, helper, cmd); setOption(PARAM_NAME, helper, cmd); setOption(PARAM_URL, helper, cmd); setOption(PARAM_PROXY_URL, helper, cmd); setOption(PARAM_PROXY_USER, helper, cmd); setOption(PARAM_PROXY_PASS, helper, cmd); helper.replace(cmd.hasOption(PARAM_REPLACE)); setOption(PARAM_ENCODING, helper, cmd); File file = cmd.getArgList().isEmpty() ? null : new File(cmd.getArgList().get(0)); helper.sign(file); } JsignCLI(); static void main(String... args);  }