55 KeyTab table;
56 char action;
57 String name; // name and directory of key table
58 String principal;
59 boolean showEType;
60 boolean showTime;
61 int etype = -1;
62 char[] password = null;
63
64 boolean forced = false; // true if delete without prompt. Default false
65 boolean append = false; // true if new keys are appended. Default false
66 int vDel = -1; // kvno to delete, -1 all, -2 old. Default -1
67 int vAdd = -1; // kvno to add. Default -1, means auto incremented
68
69 /**
70 * The main program that can be invoked at command line.
71 * See {@link #printHelp} for usages.
72 */
73 public static void main(String[] args) {
74 Ktab ktab = new Ktab();
75 if ((args.length == 1) && (args[0].equalsIgnoreCase("-help"))) {
76 ktab.printHelp();
77 return;
78 } else if ((args == null) || (args.length == 0)) {
79 ktab.action = 'l';
80 } else {
81 ktab.processArgs(args);
82 }
83 ktab.table = KeyTab.getInstance(ktab.name);
84 if (ktab.table.isMissing() && ktab.action != 'a') {
85 if (ktab.name == null) {
86 System.out.println("No default key table exists.");
87 } else {
88 System.out.println("Key table " +
89 ktab.name + " does not exist.");
90 }
91 System.exit(-1);
92 }
93 if (!ktab.table.isValid()) {
94 if (ktab.name == null) {
95 System.out.println("The format of the default key table " +
96 " is incorrect.");
430 + " list the keytab name and entries. -e with etype, -t with timestamp.");
431 System.out.println("-a <principal name> [<password>] [-n <kvno>] [-append]\n"
432 + " add new key entries to the keytab for the given principal name with\n"
433 + " optional <password>. If a <kvno> is specified, new keys' Key Version\n"
434 + " Numbers equal to the value, otherwise, automatically incrementing\n"
435 + " the Key Version Numbers. If -append is specified, new keys are\n"
436 + " appended to the keytab, otherwise, old keys for the\n"
437 + " same principal are removed.");
438 System.out.println("-d <principal name> [-f] [-e <etype>] [<kvno> | all | old]\n"
439 + " delete key entries from the keytab for the specified principal. If\n"
440 + " <kvno> is specified, delete keys whose Key Version Numbers match\n"
441 + " kvno. If \"all\" is specified, delete all keys. If \"old\" is specified,\n"
442 + " delete all keys except those with the highest kvno. Default action\n"
443 + " is \"all\". If <etype> is specified, only keys of this encryption type\n"
444 + " are deleted. <etype> should be specified as the numberic value etype\n"
445 + " defined in RFC 3961, section 8. A prompt to confirm the deletion is\n"
446 + " displayed unless -f is specified.");
447 System.out.println();
448 System.out.println("Common option(s):");
449 System.out.println();
450 System.out.println("-k <keytab name>\n"
451 + " specify keytab name and path with prefix FILE:");
452 }
453 }
|
55 KeyTab table;
56 char action;
57 String name; // name and directory of key table
58 String principal;
59 boolean showEType;
60 boolean showTime;
61 int etype = -1;
62 char[] password = null;
63
64 boolean forced = false; // true if delete without prompt. Default false
65 boolean append = false; // true if new keys are appended. Default false
66 int vDel = -1; // kvno to delete, -1 all, -2 old. Default -1
67 int vAdd = -1; // kvno to add. Default -1, means auto incremented
68
69 /**
70 * The main program that can be invoked at command line.
71 * See {@link #printHelp} for usages.
72 */
73 public static void main(String[] args) {
74 Ktab ktab = new Ktab();
75 if ((args.length == 1) &&
76 ((args[0].equalsIgnoreCase("-?")) ||
77 (args[0].equalsIgnoreCase("-h")) ||
78 (args[0].equalsIgnoreCase("--help")) ||
79 // -help: legacy. Undocumented.
80 (args[0].equalsIgnoreCase("-help")))) {
81 ktab.printHelp();
82 System.exit(0);
83 return;
84 } else if ((args == null) || (args.length == 0)) {
85 ktab.action = 'l';
86 } else {
87 ktab.processArgs(args);
88 }
89 ktab.table = KeyTab.getInstance(ktab.name);
90 if (ktab.table.isMissing() && ktab.action != 'a') {
91 if (ktab.name == null) {
92 System.out.println("No default key table exists.");
93 } else {
94 System.out.println("Key table " +
95 ktab.name + " does not exist.");
96 }
97 System.exit(-1);
98 }
99 if (!ktab.table.isValid()) {
100 if (ktab.name == null) {
101 System.out.println("The format of the default key table " +
102 " is incorrect.");
436 + " list the keytab name and entries. -e with etype, -t with timestamp.");
437 System.out.println("-a <principal name> [<password>] [-n <kvno>] [-append]\n"
438 + " add new key entries to the keytab for the given principal name with\n"
439 + " optional <password>. If a <kvno> is specified, new keys' Key Version\n"
440 + " Numbers equal to the value, otherwise, automatically incrementing\n"
441 + " the Key Version Numbers. If -append is specified, new keys are\n"
442 + " appended to the keytab, otherwise, old keys for the\n"
443 + " same principal are removed.");
444 System.out.println("-d <principal name> [-f] [-e <etype>] [<kvno> | all | old]\n"
445 + " delete key entries from the keytab for the specified principal. If\n"
446 + " <kvno> is specified, delete keys whose Key Version Numbers match\n"
447 + " kvno. If \"all\" is specified, delete all keys. If \"old\" is specified,\n"
448 + " delete all keys except those with the highest kvno. Default action\n"
449 + " is \"all\". If <etype> is specified, only keys of this encryption type\n"
450 + " are deleted. <etype> should be specified as the numberic value etype\n"
451 + " defined in RFC 3961, section 8. A prompt to confirm the deletion is\n"
452 + " displayed unless -f is specified.");
453 System.out.println();
454 System.out.println("Common option(s):");
455 System.out.println();
456 System.out.println("-?, -h, --help print this help message and exit.");
457 System.out.println("-k <keytab name>\n"
458 + " specify keytab name and path with prefix FILE:");
459 }
460 }
|