/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* (C) Copyright IBM Corp. 1999 All Rights Reserved.
* Copyright 1997 The Open Group Research Institute. All rights reserved.
*/
/**
* This class can execute as a command-line tool to help the user manage
* entries in the key table.
*
* @author Yanni Zhang
* @author Ram Marti
*/
public class Ktab {
// KeyTabAdmin admin;
char action;
boolean showEType;
boolean showTime;
/**
* The main program that can be invoked at command line.
* See {@link #printHelp} for usages.
*/
return;
} else {
}
} else {
}
}
" is incorrect.");
} else {
}
}
case 'l':
break;
case 'a':
break;
case 'd':
ktab.deleteEntry();
break;
default:
}
}
/**
* Parses the command line arguments.
*/
// Commands (should appear before options):
// -l
// -a <princ>
// -d <princ>
// Options:
// -e <etype> (for -d)
// -e (for -l)
// -n <kvno>
// -k <keytab>
// -t
// -f
// -append
// Optional extra arguments:
// password for -a
// [kvno|all|old] for -d
boolean argAlreadyAppeared = false;
// Commands
case "-l": // list
action = 'l';
break;
case "-a": // add a new entry to keytab.
action = 'a';
error("A principal name must be specified after -a");
}
break;
case "-d": // delete entries
action = 'd';
error("A principal name must be specified after -d");
}
break;
// Options
case "-e":
showEType = true;
error("An etype must be specified after -e");
}
try {
if (etype <= 0) {
throw new NumberFormatException();
}
} catch (NumberFormatException nfe) {
}
} else {
}
break;
case "-n": // kvno for -a
error("A KVNO must be specified after -n");
}
try {
if (vAdd < 0) {
throw new NumberFormatException();
}
} catch (NumberFormatException nfe) {
}
break;
case "-k": // specify keytab to use
error("A keytab name must be specified after -k");
}
} else {
}
break;
case "-t": // list timestamps
showTime = true;
break;
case "-f": // force delete, no prompt
forced = true;
break;
case "-append": // -a, new keys append to file
append = true;
break;
default:
break;
}
} else { // optional standalone arguments
if (argAlreadyAppeared) {
}
if (action == 'a') {
} else if (action == 'd') {
switch (args[i]) {
default: {
try {
if (vDel < 0) {
throw new NumberFormatException();
}
} catch (NumberFormatException nfe) {
}
}
}
} else {
}
argAlreadyAppeared = true;
}
}
}
/**
* Adds a service key to key table. If the specified key table does not
* exist, the program will automatically generate
* a new key table.
*/
void addEntry() {
try {
}
} catch (KrbException e) {
" to keytab.");
e.printStackTrace();
}
try {
} catch (IOException e) {
e.printStackTrace();
}
}
try {
// admin.addEntry(pname, password);
// admin.save();
} catch (KrbException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Lists key table name and entries in it.
*/
void listKt() {
int column = 0;
column = 0;
if (showEType) {
} else {
}
}
for (int j=0; j<column; j++) {
}
}
}
for (int j=0; j<column; j++) {
}
for (int j=0; j<column; j++) {
}
for (int j=0; j<column; j++) {
}
}
} else {
}
}
/**
* Deletes an entry from the key table.
*/
void deleteEntry() {
try {
}
if (!forced) {
else {
// no error, the user did not want to delete the entry
}
}
} catch (KrbException e) {
"Deletion failed.");
e.printStackTrace();
} catch (IOException e) {
" Deletion failed.");
e.printStackTrace();
}
if (count == 0) {
"Deletion fails.");
} else {
try {
} catch (IOException e) {
"Deletion fails.");
e.printStackTrace();
}
}
}
}
printHelp();
}
/**
* Prints out the help information.
*/
void printHelp() {
+ " list the keytab name and entries. -e with etype, -t with timestamp.");
+ " add new key entries to the keytab for the given principal name with\n"
+ " optional <password>. If a <kvno> is specified, new keys' Key Version\n"
+ " Numbers equal to the value, otherwise, automatically incrementing\n"
+ " the Key Version Numbers. If -append is specified, new keys are\n"
+ " appended to the keytab, otherwise, old keys for the\n"
+ " same principal are removed.");
+ " delete key entries from the keytab for the specified principal. If\n"
+ " <kvno> is specified, delete keys whose Key Version Numbers match\n"
+ " kvno. If \"all\" is specified, delete all keys. If \"old\" is specified,\n"
+ " delete all keys except those with the highest kvno. Default action\n"
+ " is \"all\". If <etype> is specified, only keys of this encryption type\n"
+ " are deleted. <etype> should be specified as the numberic value etype\n"
+ " defined in RFC 3961, section 8. A prompt to confirm the deletion is\n"
+ " displayed unless -f is specified.");
+ " specify keytab name and path with prefix FILE:");
}
}