~ubuntu-branches/ubuntu/precise/classpath/precise

« back to all changes in this revision

Viewing changes to tools/gnu/classpath/tools/keytool/IdentityDBCmd.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2006-05-27 16:11:15 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060527161115-h6e39eposdt5snb6
Tags: 2:0.91-3
* Install header files to /usr/include/classpath.
* debian/control: classpath: Conflict with jamvm < 1.4.3 and
  cacao < 0.96 (Closes: #368172).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* IdentityDBCmd.java -- The identitydb command handler of the keytool
 
2
   Copyright (C) 2006 Free Software Foundation, Inc.
 
3
 
 
4
This file is part of GNU Classpath.
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.
 
20
 
 
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.
 
25
 
 
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. */
 
37
 
 
38
 
 
39
package gnu.classpath.tools.keytool;
 
40
 
 
41
import java.util.logging.Logger;
 
42
 
 
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>
 
57
 *      
 
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>
 
65
 *      
 
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>
 
78
 *      
 
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>
 
84
 *      
 
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>
 
92
 *      
 
93
 *      <dt>-v</dt>
 
94
 *      <dd>Use this option to enable more verbose output.</dd>
 
95
 * </dl>
 
96
 */
 
97
class IdentityDBCmd extends Command
 
98
{
 
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;
 
105
 
 
106
  // default 0-arguments constructor
 
107
 
 
108
  // public setters -----------------------------------------------------------
 
109
 
 
110
  /** @param pathName the fully qualified path name of the file to process. */
 
111
  public void setFile(String pathName)
 
112
  {
 
113
    this._idbFileName = pathName;
 
114
  }
 
115
 
 
116
  /** @param type the key-store type to use. */
 
117
  public void setStoretype(String type)
 
118
  {
 
119
    this._ksType = type;
 
120
  }
 
121
 
 
122
  /** @param url the key-store URL to use. */
 
123
  public void setKeystore(String url)
 
124
  {
 
125
    this._ksURL = url;
 
126
  }
 
127
 
 
128
  /** @param password the key-store password to use. */
 
129
  public void setStorepass(String password)
 
130
  {
 
131
    this._ksPassword = password;
 
132
  }
 
133
 
 
134
  /** @param className a security provider fully qualified class name to use. */
 
135
  public void setProvider(String className)
 
136
  {
 
137
    this._providerClassName = className;
 
138
  }
 
139
 
 
140
  // life-cycle methods -------------------------------------------------------
 
141
 
 
142
  int processArgs(String[] args, int i)
 
143
  {
 
144
    int limit = args.length;
 
145
    String opt;
 
146
    while (++i < limit)
 
147
      {
 
148
        opt = args[i];
 
149
        log.finest("args[" + i + "]=" + opt);
 
150
        if (opt == null || opt.length() == 0)
 
151
          continue;
 
152
 
 
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;
 
167
      }
 
168
 
 
169
    return i;
 
170
  }
 
171
 
 
172
  void setup() throws Exception
 
173
  {
 
174
    setInputStreamParam(_idbFileName);
 
175
    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
 
176
 
 
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);
 
184
  }
 
185
}