< prev index next >

test/sun/security/tools/jarsigner/Warning.java

Print this page
rev 16540 : 8171319: keytool should print out warnings when reading or generating cert/cert req using weak algorithms


 182 
 183     // Creates a self-signed cert for alias with zero or more -genkey options
 184     static void newCert(String alias, String... more) throws Exception {
 185         String args = "-genkeypair -alias " + alias + " -dname CN=" + alias;
 186         for (String s: more) {
 187             args += " " + s;
 188         }
 189         run("keytool", args).shouldHaveExitValue(0);
 190     }
 191 
 192     // Asks ca to issue a cert to alias with zero or more -gencert options
 193     static void issueCert(String alias, String...more) throws Exception {
 194         String req = run("keytool", "-certreq -alias " + alias)
 195                 .shouldHaveExitValue(0).getStdout();
 196         String args = "-gencert -alias ca -rfc";
 197         for (String s: more) {
 198             args += " " + s;
 199         }
 200         String cert = run("keytool", args, req)
 201                 .shouldHaveExitValue(0).getStdout();
 202         run("keytool", "-import -alias " + alias, cert).shouldHaveExitValue(0);
 203     }
 204 
 205     // Runs a java tool with command line arguments
 206     static OutputAnalyzer run(String command, String args)
 207             throws Exception {
 208         return run(command, args, null);
 209     }
 210 
 211     // Runs a java tool with command line arguments and an optional input block
 212     static OutputAnalyzer run(String command, String args, String input)
 213             throws Exception {
 214         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(command);
 215         launcher.addVMArg("-Duser.language=en").addVMArg("-Duser.country=US");
 216         switch (command) {
 217             case "keytool":
 218                 for (String s: new String[] {
 219                         "-keystore", "ks", "-storepass", "changeit",
 220                         "-storetype", "jks",
 221                         "-keypass", "changeit", "-keyalg", "rsa", "-debug"}) {
 222                     launcher.addToolArg(s);




 182 
 183     // Creates a self-signed cert for alias with zero or more -genkey options
 184     static void newCert(String alias, String... more) throws Exception {
 185         String args = "-genkeypair -alias " + alias + " -dname CN=" + alias;
 186         for (String s: more) {
 187             args += " " + s;
 188         }
 189         run("keytool", args).shouldHaveExitValue(0);
 190     }
 191 
 192     // Asks ca to issue a cert to alias with zero or more -gencert options
 193     static void issueCert(String alias, String...more) throws Exception {
 194         String req = run("keytool", "-certreq -alias " + alias)
 195                 .shouldHaveExitValue(0).getStdout();
 196         String args = "-gencert -alias ca -rfc";
 197         for (String s: more) {
 198             args += " " + s;
 199         }
 200         String cert = run("keytool", args, req)
 201                 .shouldHaveExitValue(0).getStdout();
 202         run("keytool", "-import -noprompt -alias " + alias, cert).shouldHaveExitValue(0);
 203     }
 204 
 205     // Runs a java tool with command line arguments
 206     static OutputAnalyzer run(String command, String args)
 207             throws Exception {
 208         return run(command, args, null);
 209     }
 210 
 211     // Runs a java tool with command line arguments and an optional input block
 212     static OutputAnalyzer run(String command, String args, String input)
 213             throws Exception {
 214         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(command);
 215         launcher.addVMArg("-Duser.language=en").addVMArg("-Duser.country=US");
 216         switch (command) {
 217             case "keytool":
 218                 for (String s: new String[] {
 219                         "-keystore", "ks", "-storepass", "changeit",
 220                         "-storetype", "jks",
 221                         "-keypass", "changeit", "-keyalg", "rsa", "-debug"}) {
 222                     launcher.addToolArg(s);


< prev index next >