< prev index next >

src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java

Print this page
rev 48074 : 8189102: All tools should support -?, -h and --help
Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini
   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


  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.");


   1 /*
   2  * Copyright (c) 2003, 2017, 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


  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.
  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.");


< prev index next >