Imported GNU Classpath 0.90
[official-gcc.git] / libjava / classpath / tools / gnu / classpath / tools / keytool / IdentityDBCmd.java
blobcb6b6dac2a5367f73fdb38d548d18a2e71a19a58
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)
9 any later version.
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
19 02110-1301 USA.
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
24 combination.
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 java.util.logging.Logger;
43 /**
44 * <b>NOT IMPLEMENTED YET</b>
45 * <p>
46 * The <b>-identitydb</b> keytool command handler is used to read the JDK 1.1.x-
47 * style identity database and add its entries to the key store. If a key store
48 * does not exist, it is created.
49 * <p>
50 * Possible options for this command are:
51 * <p>
52 * <dl>
53 * <dt>-file FILE_NAME</dt>
54 * <dd>The fully qualified path of the identity file to import. If this
55 * option is omitted, the tool will process STDIN.
56 * <p></dd>
58 * <dt>-storetype STORE_TYP}</dt>
59 * <dd>Use this option to specify the type of the key store to use. The
60 * default value, if this option is omitted, is that of the property
61 * <code>keystore.type</code> in the security properties file, which is
62 * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
63 * static method.
64 * <p></dd>
66 * <dt>-keystore URL</dt>
67 * <dd>Use this option to specify the location of the key store to use.
68 * The default value is a file {@link java.net.URL} referencing the file
69 * named <code>.keystore</code> located in the path returned by the call to
70 * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
71 * as argument.
72 * <p>
73 * If a URL was specified, but was found to be malformed --e.g. missing
74 * protocol element-- the tool will attempt to use the URL value as a file-
75 * name (with absolute or relative path-name) of a key store --as if the
76 * protocol was <code>file:</code>.
77 * <p></dd>
79 * <dt>-storepass PASSWORD</dt>
80 * <dd>Use this option to specify the password protecting the key store. If
81 * this option is omitted from the command line, you will be prompted to
82 * provide a password.
83 * <p></dd>
85 * <dt>-provider PROVIDER_CLASS_NAME</dt>
86 * <dd>A fully qualified class name of a Security Provider to add to the
87 * current list of Security Providers already installed in the JVM in-use.
88 * If a provider class is specified with this option, and was successfully
89 * added to the runtime --i.e. it was not already installed-- then the tool
90 * will attempt to removed this Security Provider before exiting.
91 * <p></dd>
93 * <dt>-v</dt>
94 * <dd>Use this option to enable more verbose output.</dd>
95 * </dl>
97 class IdentityDBCmd extends Command
99 private static final Logger log = Logger.getLogger(IdentityDBCmd.class.getName());
100 private String _idbFileName;
101 private String _ksType;
102 private String _ksURL;
103 private String _ksPassword;
104 private String _providerClassName;
106 // default 0-arguments constructor
108 // public setters -----------------------------------------------------------
110 /** @param pathName the fully qualified path name of the file to process. */
111 public void setFile(String pathName)
113 this._idbFileName = pathName;
116 /** @param type the key-store type to use. */
117 public void setStoretype(String type)
119 this._ksType = type;
122 /** @param url the key-store URL to use. */
123 public void setKeystore(String url)
125 this._ksURL = url;
128 /** @param password the key-store password to use. */
129 public void setStorepass(String password)
131 this._ksPassword = password;
134 /** @param className a security provider fully qualified class name to use. */
135 public void setProvider(String className)
137 this._providerClassName = className;
140 // life-cycle methods -------------------------------------------------------
142 int processArgs(String[] args, int i)
144 int limit = args.length;
145 String opt;
146 while (++i < limit)
148 opt = args[i];
149 log.finest("args[" + i + "]=" + opt);
150 if (opt == null || opt.length() == 0)
151 continue;
153 if ("-file".equals(opt)) // -file FILE_NAME
154 _idbFileName = args[++i];
155 else if ("-storetype".equals(opt)) // -storetype STORE_TYPE
156 _ksType = args[++i];
157 else if ("-keystore".equals(opt)) // -keystore URL
158 _ksURL = args[++i];
159 else if ("-storepass".equals(opt)) // -storepass PASSWORD
160 _ksPassword = args[++i];
161 else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME
162 _providerClassName = args[++i];
163 else if ("-v".equals(opt))
164 verbose = true;
165 else
166 break;
169 return i;
172 void setup() throws Exception
174 setInputStreamParam(_idbFileName);
175 setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
177 log.finer("-identitydb handler will use the following options:");
178 log.finer(" -file=" + _idbFileName);
179 log.finer(" -storetype=" + storeType);
180 log.finer(" -keystore=" + storeURL);
181 log.finer(" -storepass=" + new String(storePasswordChars));
182 log.finer(" -provider=" + provider);
183 log.finer(" -v=" + verbose);