@Test public void testSigningEncryptedPEM() throws Exception { cli.execute("--certfile=target/test-classes/keystores/jsign-test-certificate.pem", "--keyfile=target/test-classes/keystores/privatekey-encrypted.pkcs1.pem", "--keypass=password", "" + targetFile); assertTrue("The file " + targetFile + " wasn't changed", SOURCE_FILE_CRC32 != FileUtils.checksumCRC32(targetFile)); try (PEFile peFile = new PEFile(targetFile)) { List<CMSSignedData> signatures = peFile.getSignatures(); assertNotNull(signatures); assertEquals(1, signatures.size()); CMSSignedData signature = signatures.get(0); assertNotNull(signature); } }
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);  }