< prev index next >

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

Print this page
rev 47855 : 8189102: All tools should support -?, -h and --help
   1 /*
   2  * Copyright (c) 2000, 2012, 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


 120             } else if (args[i].equals("-k")) {
 121                 useKeytab = true;
 122             } else if (args[i].equals("-t")) {
 123                 if (ktabName != null) {
 124                     throw new IllegalArgumentException
 125                         ("-t option/keytab file name repeated");
 126                 } else if (i + 1 < args.length) {
 127                     ktabName = args[++i];
 128                 } else {
 129                     throw new IllegalArgumentException
 130                         ("-t option requires keytab file name");
 131                 }
 132 
 133                 useKeytab = true;
 134             } else if (args[i].equals("-R")) {
 135                 action = 2;
 136             } else if (args[i].equals("-l")) {
 137                 lifetime = getTime(Config.duration(args[++i]));
 138             } else if (args[i].equals("-r")) {
 139                 renewable_lifetime = getTime(Config.duration(args[++i]));
 140             } else if (args[i].equalsIgnoreCase("-help")) {




 141                 printHelp();
 142                 System.exit(0);
 143             } else if (p == null) { // Haven't yet processed a "principal"
 144                 p = args[i];
 145                 try {
 146                     principal = new PrincipalName(p);
 147                 } catch (Exception e) {
 148                     throw new IllegalArgumentException("invalid " +
 149                                                        "Principal name: " + p +
 150                                                        e.getMessage());
 151                 }
 152             } else if (this.password == null) {
 153                 // Have already processed a Principal, this must be a password
 154                 password = args[i].toCharArray();
 155             } else {
 156                 throw new IllegalArgumentException("too many parameters");
 157             }
 158         }
 159         // we should get cache name before getting the default principal name
 160         if (cachename == null) {


 231                 "[-l lifetime] [-r renewable_time]\n" +
 232                 "          [[-k [-t keytab_file_name]] [principal] " +
 233                            "[password]");
 234         System.out.println("2. Renew a ticket:\n" +
 235                 "    kinit -R [-c cachename] [principal]");
 236         System.out.println("\nAvailable options to " +
 237                            "Kerberos 5 ticket request:");
 238         System.out.println("\t-A   do not include addresses");
 239         System.out.println("\t-f   forwardable");
 240         System.out.println("\t-p   proxiable");
 241         System.out.println("\t-c   cache name " +
 242                 "(i.e., FILE:\\d:\\myProfiles\\mykrb5cache)");
 243         System.out.println("\t-l   lifetime");
 244         System.out.println("\t-r   renewable time " +
 245                 "(total lifetime a ticket can be renewed)");
 246         System.out.println("\t-k   use keytab");
 247         System.out.println("\t-t   keytab file name");
 248         System.out.println("\tprincipal   the principal name "+
 249                 "(i.e., qweadf@ATHENA.MIT.EDU qweadf)");
 250         System.out.println("\tpassword    the principal's Kerberos password");

 251     }
 252 
 253     public boolean getAddressOption() {
 254         return includeAddresses;
 255     }
 256 
 257     public boolean useKeytabFile() {
 258         return useKeytab;
 259     }
 260 
 261     public String keytabFileName() {
 262         return ktabName;
 263     }
 264 
 265     public PrincipalName getPrincipal() {
 266         return principal;
 267     }
 268 
 269     private KerberosTime getTime(int s) {
 270         return new KerberosTime(Instant.now().plusSeconds(s));
   1 /*
   2  * Copyright (c) 2000, 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


 120             } else if (args[i].equals("-k")) {
 121                 useKeytab = true;
 122             } else if (args[i].equals("-t")) {
 123                 if (ktabName != null) {
 124                     throw new IllegalArgumentException
 125                         ("-t option/keytab file name repeated");
 126                 } else if (i + 1 < args.length) {
 127                     ktabName = args[++i];
 128                 } else {
 129                     throw new IllegalArgumentException
 130                         ("-t option requires keytab file name");
 131                 }
 132 
 133                 useKeytab = true;
 134             } else if (args[i].equals("-R")) {
 135                 action = 2;
 136             } else if (args[i].equals("-l")) {
 137                 lifetime = getTime(Config.duration(args[++i]));
 138             } else if (args[i].equals("-r")) {
 139                 renewable_lifetime = getTime(Config.duration(args[++i]));
 140             } else if (args[i].equalsIgnoreCase("-?") ||
 141                        args[i].equalsIgnoreCase("-h") ||
 142                        args[i].equalsIgnoreCase("--help") ||
 143                        // -help: legacy. Undocumented.
 144                        args[i].equalsIgnoreCase("-help")) {
 145                 printHelp();
 146                 System.exit(0);
 147             } else if (p == null) { // Haven't yet processed a "principal"
 148                 p = args[i];
 149                 try {
 150                     principal = new PrincipalName(p);
 151                 } catch (Exception e) {
 152                     throw new IllegalArgumentException("invalid " +
 153                                                        "Principal name: " + p +
 154                                                        e.getMessage());
 155                 }
 156             } else if (this.password == null) {
 157                 // Have already processed a Principal, this must be a password
 158                 password = args[i].toCharArray();
 159             } else {
 160                 throw new IllegalArgumentException("too many parameters");
 161             }
 162         }
 163         // we should get cache name before getting the default principal name
 164         if (cachename == null) {


 235                 "[-l lifetime] [-r renewable_time]\n" +
 236                 "          [[-k [-t keytab_file_name]] [principal] " +
 237                            "[password]");
 238         System.out.println("2. Renew a ticket:\n" +
 239                 "    kinit -R [-c cachename] [principal]");
 240         System.out.println("\nAvailable options to " +
 241                            "Kerberos 5 ticket request:");
 242         System.out.println("\t-A   do not include addresses");
 243         System.out.println("\t-f   forwardable");
 244         System.out.println("\t-p   proxiable");
 245         System.out.println("\t-c   cache name " +
 246                 "(i.e., FILE:\\d:\\myProfiles\\mykrb5cache)");
 247         System.out.println("\t-l   lifetime");
 248         System.out.println("\t-r   renewable time " +
 249                 "(total lifetime a ticket can be renewed)");
 250         System.out.println("\t-k   use keytab");
 251         System.out.println("\t-t   keytab file name");
 252         System.out.println("\tprincipal   the principal name "+
 253                 "(i.e., qweadf@ATHENA.MIT.EDU qweadf)");
 254         System.out.println("\tpassword    the principal's Kerberos password");
 255         System.out.println("\t-? -h --help Print this help message");
 256     }
 257 
 258     public boolean getAddressOption() {
 259         return includeAddresses;
 260     }
 261 
 262     public boolean useKeytabFile() {
 263         return useKeytab;
 264     }
 265 
 266     public String keytabFileName() {
 267         return ktabName;
 268     }
 269 
 270     public PrincipalName getPrincipal() {
 271         return principal;
 272     }
 273 
 274     private KerberosTime getTime(int s) {
 275         return new KerberosTime(Instant.now().plusSeconds(s));
< prev index next >