1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
116 System.exit(-1);
117 } else {
118 klist.target = CredentialsCache.getInstance();
119 klist.name = CredentialsCache.cacheName();
120 if (klist.target != null) {
121 klist.displayCache();
122 } else {
123 klist.displayMessage("Credentials cache");
124 System.exit(-1);
125 }
126 }
127 }
128 }
129
130 /**
131 * Parses the command line arguments.
132 */
133 void processArgs(String[] args) {
134 Character arg;
135 for (int i = 0; i < args.length; i++) {
136 if ((args[i].length() >= 2) && (args[i].startsWith("-"))) {
137 arg = Character.valueOf(args[i].charAt(1));
138 switch (arg.charValue()) {
139 case 'c':
140 action = 'c';
141 break;
142 case 'k':
143 action = 'k';
144 break;
145 case 'a':
146 options[2] = 'a';
147 break;
148 case 'n':
149 options[3] = 'n';
150 break;
151 case 'f':
152 options[1] = 'f';
153 break;
154 case 'e':
155 options[0] = 'e';
333 * Prints out the help information.
334 */
335 void printHelp() {
336 System.out.println("\nUsage: klist " +
337 "[[-c] [-f] [-e] [-a [-n]]] [-k [-t] [-K]] [name]");
338 System.out.println(" name\t name of credentials cache or " +
339 " keytab with the prefix. File-based cache or "
340 + "keytab's prefix is FILE:.");
341 System.out.println(" -c specifies that credential cache is to be " +
342 "listed");
343 System.out.println(" -k specifies that key tab is to be listed");
344 System.out.println(" options for credentials caches:");
345 System.out.println("\t-f \t shows credentials flags");
346 System.out.println("\t-e \t shows the encryption type");
347 System.out.println("\t-a \t shows addresses");
348 System.out.println("\t -n \t do not reverse-resolve addresses");
349 System.out.println(" options for keytabs:");
350 System.out.println("\t-t \t shows keytab entry timestamps");
351 System.out.println("\t-K \t shows keytab entry key value");
352 System.out.println("\t-e \t shows keytab entry key type");
353 System.out.println("\nUsage: java sun.security.krb5.tools.Klist " +
354 "-help for help.");
355 }
356 }
|
1 /*
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
116 System.exit(-1);
117 } else {
118 klist.target = CredentialsCache.getInstance();
119 klist.name = CredentialsCache.cacheName();
120 if (klist.target != null) {
121 klist.displayCache();
122 } else {
123 klist.displayMessage("Credentials cache");
124 System.exit(-1);
125 }
126 }
127 }
128 }
129
130 /**
131 * Parses the command line arguments.
132 */
133 void processArgs(String[] args) {
134 Character arg;
135 for (int i = 0; i < args.length; i++) {
136 if (args[i].equals("-?") ||
137 args[i].equals("-h") ||
138 args[i].equals("--help")) {
139 printHelp();
140 System.exit(0);
141 }
142 if ((args[i].length() >= 2) && (args[i].startsWith("-"))) {
143 arg = Character.valueOf(args[i].charAt(1));
144 switch (arg.charValue()) {
145 case 'c':
146 action = 'c';
147 break;
148 case 'k':
149 action = 'k';
150 break;
151 case 'a':
152 options[2] = 'a';
153 break;
154 case 'n':
155 options[3] = 'n';
156 break;
157 case 'f':
158 options[1] = 'f';
159 break;
160 case 'e':
161 options[0] = 'e';
339 * Prints out the help information.
340 */
341 void printHelp() {
342 System.out.println("\nUsage: klist " +
343 "[[-c] [-f] [-e] [-a [-n]]] [-k [-t] [-K]] [name]");
344 System.out.println(" name\t name of credentials cache or " +
345 " keytab with the prefix. File-based cache or "
346 + "keytab's prefix is FILE:.");
347 System.out.println(" -c specifies that credential cache is to be " +
348 "listed");
349 System.out.println(" -k specifies that key tab is to be listed");
350 System.out.println(" options for credentials caches:");
351 System.out.println("\t-f \t shows credentials flags");
352 System.out.println("\t-e \t shows the encryption type");
353 System.out.println("\t-a \t shows addresses");
354 System.out.println("\t -n \t do not reverse-resolve addresses");
355 System.out.println(" options for keytabs:");
356 System.out.println("\t-t \t shows keytab entry timestamps");
357 System.out.println("\t-K \t shows keytab entry key value");
358 System.out.println("\t-e \t shows keytab entry key type");
359 }
360 }
|