1 /* IdentityDBCmd.java -- The identitydb command handler of the keytool
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.classpath.tools.keytool;
41 import gnu.classpath.tools.getopt.ClasspathToolParser;
42 import gnu.classpath.tools.getopt.Option;
43 import gnu.classpath.tools.getopt.OptionException;
44 import gnu.classpath.tools.getopt.OptionGroup;
45 import gnu.classpath.tools.getopt.Parser;
47 import java.util.logging.Logger;
50 * <b>NOT IMPLEMENTED YET</b>
52 * The <b>-identitydb</b> keytool command handler is used to read the JDK 1.1.x-
53 * style identity database and add its entries to the key store. If a key store
54 * does not exist, it is created.
56 * Possible options for this command are:
59 * <dt>-file FILE_NAME</dt>
60 * <dd>The fully qualified path of the identity file to import. If this
61 * option is omitted, the tool will process STDIN.
64 * <dt>-storetype STORE_TYPE</dt>
65 * <dd>Use this option to specify the type of the key store to use. The
66 * default value, if this option is omitted, is that of the property
67 * <code>keystore.type</code> in the security properties file, which is
68 * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
72 * <dt>-keystore URL</dt>
73 * <dd>Use this option to specify the location of the key store to use.
74 * The default value is a file {@link java.net.URL} referencing the file
75 * named <code>.keystore</code> located in the path returned by the call to
76 * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
79 * If a URL was specified, but was found to be malformed --e.g. missing
80 * protocol element-- the tool will attempt to use the URL value as a file-
81 * name (with absolute or relative path-name) of a key store --as if the
82 * protocol was <code>file:</code>.
85 * <dt>-storepass PASSWORD</dt>
86 * <dd>Use this option to specify the password protecting the key store. If
87 * this option is omitted from the command line, you will be prompted to
91 * <dt>-provider PROVIDER_CLASS_NAME</dt>
92 * <dd>A fully qualified class name of a Security Provider to add to the
93 * current list of Security Providers already installed in the JVM in-use.
94 * If a provider class is specified with this option, and was successfully
95 * added to the runtime --i.e. it was not already installed-- then the tool
96 * will attempt to removed this Security Provider before exiting.
100 * <dd>Use this option to enable more verbose output.</dd>
103 class IdentityDBCmd extends Command
105 private static final Logger log = Logger.getLogger(IdentityDBCmd.class.getName());
106 protected String _idbFileName;
107 protected String _ksType;
108 protected String _ksURL;
109 protected String _ksPassword;
110 protected String _providerClassName;
112 // default 0-arguments constructor
114 // public setters -----------------------------------------------------------
116 /** @param pathName the fully qualified path name of the file to process. */
117 public void setFile(String pathName)
119 this._idbFileName = pathName;
122 /** @param type the key-store type to use. */
123 public void setStoretype(String type)
128 /** @param url the key-store URL to use. */
129 public void setKeystore(String url)
134 /** @param password the key-store password to use. */
135 public void setStorepass(String password)
137 this._ksPassword = password;
140 /** @param className a security provider fully qualified class name to use. */
141 public void setProvider(String className)
143 this._providerClassName = className;
146 // life-cycle methods -------------------------------------------------------
148 void setup() throws Exception
150 setInputStreamParam(_idbFileName);
151 setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
153 log.finer("-identitydb handler will use the following options:"); //$NON-NLS-1$
154 log.finer(" -file=" + _idbFileName); //$NON-NLS-1$
155 log.finer(" -storetype=" + storeType); //$NON-NLS-1$
156 log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
157 log.finer(" -provider=" + provider); //$NON-NLS-1$
158 log.finer(" -v=" + verbose); //$NON-NLS-1$
161 // own methods --------------------------------------------------------------
165 log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
167 Parser result = new ClasspathToolParser(Main.IDENTITYDB_CMD, true);
168 result.setHeader(Messages.getString("IdentityDBCmd.7")); //$NON-NLS-1$
169 result.setFooter(Messages.getString("IdentityDBCmd.8")); //$NON-NLS-1$
170 OptionGroup options = new OptionGroup(Messages.getString("IdentityDBCmd.9")); //$NON-NLS-1$
171 options.add(new Option(Main.FILE_OPT,
172 Messages.getString("IdentityDBCmd.10"), //$NON-NLS-1$
173 Messages.getString("IdentityDBCmd.11")) //$NON-NLS-1$
175 public void parsed(String argument) throws OptionException
177 _idbFileName = argument;
180 options.add(new Option(Main.STORETYPE_OPT,
181 Messages.getString("IdentityDBCmd.12"), //$NON-NLS-1$
182 Messages.getString("IdentityDBCmd.13")) //$NON-NLS-1$
184 public void parsed(String argument) throws OptionException
189 options.add(new Option(Main.KEYSTORE_OPT,
190 Messages.getString("IdentityDBCmd.14"), //$NON-NLS-1$
191 Messages.getString("IdentityDBCmd.15")) //$NON-NLS-1$
193 public void parsed(String argument) throws OptionException
198 options.add(new Option(Main.STOREPASS_OPT,
199 Messages.getString("IdentityDBCmd.16"), //$NON-NLS-1$
200 Messages.getString("IdentityDBCmd.17")) //$NON-NLS-1$
202 public void parsed(String argument) throws OptionException
204 _ksPassword = argument;
207 options.add(new Option(Main.PROVIDER_OPT,
208 Messages.getString("IdentityDBCmd.18"), //$NON-NLS-1$
209 Messages.getString("IdentityDBCmd.19")) //$NON-NLS-1$
211 public void parsed(String argument) throws OptionException
213 _providerClassName = argument;
216 options.add(new Option(Main.VERBOSE_OPT,
217 Messages.getString("IdentityDBCmd.20")) //$NON-NLS-1$
219 public void parsed(String argument) throws OptionException
226 log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$