508 }
509 }
510
511 /*
512 * Check modifiers
513 */
514 String modifier = null;
515 int pos = flags.indexOf(':');
516 if (pos > 0) {
517 modifier = flags.substring(pos+1);
518 flags = flags.substring(0, pos);
519 }
520
521 /*
522 * command modes
523 */
524 Command c = Command.getCommand(flags);
525
526 if (c != null) {
527 command = c;
528 } else if (collator.compare(flags, "-help") == 0 ||
529 collator.compare(flags, "-h") == 0 ||
530 collator.compare(flags, "-?") == 0) {
531 help = true;
532 } else if (collator.compare(flags, "-conf") == 0) {
533 i++;
534 } else if (collator.compare(flags, "-nowarn") == 0) {
535 nowarn = true;
536 } else if (collator.compare(flags, "-keystore") == 0) {
537 ksfname = args[++i];
538 if (new File(ksfname).getCanonicalPath().equals(
539 new File(KeyStoreUtil.getCacerts()).getCanonicalPath())) {
540 System.err.println(rb.getString("warning.cacerts.option"));
541 }
542 } else if (collator.compare(flags, "-destkeystore") == 0) {
543 ksfname = args[++i];
544 } else if (collator.compare(flags, "-cacerts") == 0) {
545 cacerts = true;
546 } else if (collator.compare(flags, "-storepass") == 0 ||
547 collator.compare(flags, "-deststorepass") == 0) {
548 storePass = getPass(modifier, args[++i]);
549 passwords.add(storePass);
550 } else if (collator.compare(flags, "-storetype") == 0 ||
4583 System.err.printf(" %-" + lenLeft + "s %s\n", s1, s2);
4584 } else {
4585 System.err.printf(" %-" + lenLeft + "s %s\n", s1, s2);
4586 }
4587 }
4588 }
4589 System.err.println();
4590 System.err.println(rb.getString(
4591 "Use.keytool.help.for.all.available.commands"));
4592 } else {
4593 System.err.println(rb.getString(
4594 "Key.and.Certificate.Management.Tool"));
4595 System.err.println();
4596 System.err.println(rb.getString("Commands."));
4597 System.err.println();
4598 for (Command c: Command.values()) {
4599 if (c == KEYCLONE) break;
4600 System.err.printf(" %-20s%s\n", c, rb.getString(c.description));
4601 }
4602 System.err.println();
4603 System.err.println(rb.getString(
4604 "Use.keytool.command.name.help.for.usage.of.command.name"));
4605 }
4606 }
4607
4608 private void tinyHelp() {
4609 usage();
4610 if (debug) {
4611 throw new RuntimeException("NO BIG ERROR, SORRY");
4612 } else {
4613 System.exit(1);
4614 }
4615 }
4616
4617 private void errorNeedArgument(String flag) {
4618 Object[] source = {flag};
4619 System.err.println(new MessageFormat(
4620 rb.getString("Command.option.flag.needs.an.argument.")).format(source));
4621 tinyHelp();
4622 }
|
508 }
509 }
510
511 /*
512 * Check modifiers
513 */
514 String modifier = null;
515 int pos = flags.indexOf(':');
516 if (pos > 0) {
517 modifier = flags.substring(pos+1);
518 flags = flags.substring(0, pos);
519 }
520
521 /*
522 * command modes
523 */
524 Command c = Command.getCommand(flags);
525
526 if (c != null) {
527 command = c;
528 } else if (collator.compare(flags, "--help") == 0 ||
529 collator.compare(flags, "-h") == 0 ||
530 collator.compare(flags, "-?") == 0 ||
531 // -help: legacy. Undocumented.
532 collator.compare(flags, "-help") == 0) {
533 help = true;
534 } else if (collator.compare(flags, "-conf") == 0) {
535 i++;
536 } else if (collator.compare(flags, "-nowarn") == 0) {
537 nowarn = true;
538 } else if (collator.compare(flags, "-keystore") == 0) {
539 ksfname = args[++i];
540 if (new File(ksfname).getCanonicalPath().equals(
541 new File(KeyStoreUtil.getCacerts()).getCanonicalPath())) {
542 System.err.println(rb.getString("warning.cacerts.option"));
543 }
544 } else if (collator.compare(flags, "-destkeystore") == 0) {
545 ksfname = args[++i];
546 } else if (collator.compare(flags, "-cacerts") == 0) {
547 cacerts = true;
548 } else if (collator.compare(flags, "-storepass") == 0 ||
549 collator.compare(flags, "-deststorepass") == 0) {
550 storePass = getPass(modifier, args[++i]);
551 passwords.add(storePass);
552 } else if (collator.compare(flags, "-storetype") == 0 ||
4585 System.err.printf(" %-" + lenLeft + "s %s\n", s1, s2);
4586 } else {
4587 System.err.printf(" %-" + lenLeft + "s %s\n", s1, s2);
4588 }
4589 }
4590 }
4591 System.err.println();
4592 System.err.println(rb.getString(
4593 "Use.keytool.help.for.all.available.commands"));
4594 } else {
4595 System.err.println(rb.getString(
4596 "Key.and.Certificate.Management.Tool"));
4597 System.err.println();
4598 System.err.println(rb.getString("Commands."));
4599 System.err.println();
4600 for (Command c: Command.values()) {
4601 if (c == KEYCLONE) break;
4602 System.err.printf(" %-20s%s\n", c, rb.getString(c.description));
4603 }
4604 System.err.println();
4605 System.err.println(rb.getString(
4606 "Use.keytool.help.for.all.available.commands"));
4607 System.err.println(rb.getString(
4608 "Use.keytool.command.name.help.for.usage.of.command.name"));
4609 }
4610 }
4611
4612 private void tinyHelp() {
4613 usage();
4614 if (debug) {
4615 throw new RuntimeException("NO BIG ERROR, SORRY");
4616 } else {
4617 System.exit(1);
4618 }
4619 }
4620
4621 private void errorNeedArgument(String flag) {
4622 Object[] source = {flag};
4623 System.err.println(new MessageFormat(
4624 rb.getString("Command.option.flag.needs.an.argument.")).format(source));
4625 tinyHelp();
4626 }
|