jdk/src/share/classes/sun/security/pkcs11/Config.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 7808 992bb9918576
child 9275 1df1f7dfab7f
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 7808
diff changeset
     2
 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.pkcs11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import static java.io.StreamTokenizer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.security.action.GetPropertyAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.security.util.PropertyExpander;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.security.pkcs11.wrapper.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import static sun.security.pkcs11.wrapper.CK_ATTRIBUTE.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import static sun.security.pkcs11.TemplateManager.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Configuration container and file parsing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author  Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
final class Config {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    static final int ERR_HALT       = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    static final int ERR_IGNORE_ALL = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    static final int ERR_IGNORE_LIB = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    // same as allowSingleThreadedModules but controlled via a system property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // and applied to all providers. if set to false, no SunPKCS11 instances
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    // will accept single threaded modules regardless of the setting in their
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    // config files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static final boolean staticAllowSingleThreadedModules;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        String p = "sun.security.pkcs11.allowSingleThreadedModules";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        String s = AccessController.doPrivileged(new GetPropertyAction(p));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        if ("false".equalsIgnoreCase(s)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            staticAllowSingleThreadedModules = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            staticAllowSingleThreadedModules = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // temporary storage for configurations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // needed because the SunPKCS11 needs to call the superclass constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    // in provider before accessing any instance variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private final static Map<String,Config> configMap =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                                        new HashMap<String,Config>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    static Config getConfig(final String name, final InputStream stream) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        Config config = configMap.get(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        if (config != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            return config;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            config = new Config(name, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            configMap.put(name, config);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            return config;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            throw new ProviderException("Error parsing configuration", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    static Config removeConfig(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        return configMap.remove(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private final static boolean DEBUG = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private static void debug(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            System.out.println(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    // Reader and StringTokenizer used during parsing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    private Reader reader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    private StreamTokenizer st;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private Set<String> parsedKeywords;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    // name suffix of the provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    // name of the PKCS#11 library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    private String library;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    // description to pass to the provider class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    private String description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    // slotID of the slot to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    private int slotID = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    // slot to use, specified as index in the slotlist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private int slotListIndex = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    // set of enabled mechanisms (or null to use default)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    private Set<Long> enabledMechanisms;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    // set of disabled mechanisms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    private Set<Long> disabledMechanisms;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    // whether to print debug info during startup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    private boolean showInfo = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    // template manager, initialized from parsed attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    private TemplateManager templateManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    // how to handle error during startup, one of ERR_
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private int handleStartupErrors = ERR_HALT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    // flag indicating whether the P11KeyStore should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    // be more tolerant of input parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    private boolean keyStoreCompatibilityMode = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    // flag indicating whether we need to explicitly cancel operations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    // see Token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    private boolean explicitCancel = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    // how often to test for token insertion, if no token is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    private int insertionCheckInterval = 2000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    // flag inidicating whether to omit the call to C_Initialize()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    // should be used only if we are running within a process that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    // has already called it (e.g. Plugin inside of Mozilla/NSS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    private boolean omitInitialize = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    // whether to allow modules that only support single threaded access.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    // they cannot be used safely from multiple PKCS#11 consumers in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    // same process, for example NSS and SunPKCS11
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    private boolean allowSingleThreadedModules = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    // name of the C function that returns the PKCS#11 functionlist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    // This option primarily exists for the deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    // Secmod.Module.getProvider() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    private String functionList = "C_GetFunctionList";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    // whether to use NSS secmod mode. Implicitly set if nssLibraryDirectory,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    // nssSecmodDirectory, or nssModule is specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    private boolean nssUseSecmod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    // location of the NSS library files (libnss3.so, etc.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    private String nssLibraryDirectory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    // location of secmod.db
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    private String nssSecmodDirectory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    // which NSS module to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    private String nssModule;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    private Secmod.DbMode nssDbMode = Secmod.DbMode.READ_WRITE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    // Whether the P11KeyStore should specify the CKA_NETSCAPE_DB attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    // when creating private keys. Only valid if nssUseSecmod is true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    private boolean nssNetscapeDbWorkaround = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    // Special init argument string for the NSS softtoken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    // This is used when using the NSS softtoken directly without secmod mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    private String nssArgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    // whether to use NSS trust attributes for the KeyStore of this provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    // this option is for internal use by the SunPKCS11 code only and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    // works only for NSS providers created via the Secmod API
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    private boolean nssUseSecmodTrust = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    private Config(String filename, InputStream in) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (in == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            if (filename.startsWith("--")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                // inline config
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                String config = filename.substring(2).replace("\\n", "\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                reader = new StringReader(config);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                in = new FileInputStream(expand(filename));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (reader == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            reader = new BufferedReader(new InputStreamReader(in));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        parsedKeywords = new HashSet<String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        st = new StreamTokenizer(reader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        setupTokenizer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        parse();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    String getLibrary() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return library;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    String getDescription() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (description != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        return "SunPKCS11-" + name + " using library " + library;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    int getSlotID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return slotID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    int getSlotListIndex() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if ((slotID == -1) && (slotListIndex == -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            // if neither is set, default to first slot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            return slotListIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    boolean getShowInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        return (SunPKCS11.debug != null) || showInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    TemplateManager getTemplateManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        if (templateManager == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            templateManager = new TemplateManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return templateManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    boolean isEnabled(long m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        if (enabledMechanisms != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            return enabledMechanisms.contains(Long.valueOf(m));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        if (disabledMechanisms != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            return !disabledMechanisms.contains(Long.valueOf(m));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    int getHandleStartupErrors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        return handleStartupErrors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    boolean getKeyStoreCompatibilityMode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        return keyStoreCompatibilityMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    boolean getExplicitCancel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        return explicitCancel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    int getInsertionCheckInterval() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return insertionCheckInterval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    boolean getOmitInitialize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        return omitInitialize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    boolean getAllowSingleThreadedModules() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return staticAllowSingleThreadedModules && allowSingleThreadedModules;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    String getFunctionList() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        return functionList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    boolean getNssUseSecmod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        return nssUseSecmod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    String getNssLibraryDirectory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        return nssLibraryDirectory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    String getNssSecmodDirectory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        return nssSecmodDirectory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    String getNssModule() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        return nssModule;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    Secmod.DbMode getNssDbMode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        return nssDbMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public boolean getNssNetscapeDbWorkaround() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        return nssUseSecmod && nssNetscapeDbWorkaround;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    String getNssArgs() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return nssArgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    boolean getNssUseSecmodTrust() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        return nssUseSecmodTrust;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    private static String expand(final String s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            return PropertyExpander.expand(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            throw new RuntimeException(e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    private void setupTokenizer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        st.resetSyntax();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        st.wordChars('a', 'z');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        st.wordChars('A', 'Z');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        st.wordChars('0', '9');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        st.wordChars(':', ':');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        st.wordChars('.', '.');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        st.wordChars('_', '_');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        st.wordChars('-', '-');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        st.wordChars('/', '/');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        st.wordChars('\\', '\\');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        st.wordChars('$', '$');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        st.wordChars('{', '{'); // need {} for property subst
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        st.wordChars('}', '}');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        st.wordChars('*', '*');
7808
992bb9918576 6581254: pkcs11 provider fails to parse configuration file contains windows short path
valeriep
parents: 5506
diff changeset
   346
        st.wordChars('~', '~');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        // XXX check ASCII table and add all other characters except special
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        // special: #="(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        st.whitespaceChars(0, ' ');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        st.commentChar('#');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        st.eolIsSignificant(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        st.quoteChar('\"');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    private ConfigurationException excToken(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        return new ConfigurationException(msg + " " + st);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    private ConfigurationException excLine(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        return new ConfigurationException(msg + ", line " + st.lineno());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    private void parse() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            if (token == TT_EOF) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            if (token == TT_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            if (token != TT_WORD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                throw excToken("Unexpected token:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            String word = st.sval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            if (word.equals("name")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                name = parseStringEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            } else if (word.equals("library")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                library = parseLibrary(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            } else if (word.equals("description")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                parseDescription(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            } else if (word.equals("slot")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                parseSlotID(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            } else if (word.equals("slotListIndex")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                parseSlotListIndex(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            } else if (word.equals("enabledMechanisms")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                parseEnabledMechanisms(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            } else if (word.equals("disabledMechanisms")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                parseDisabledMechanisms(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            } else if (word.equals("attributes")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                parseAttributes(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            } else if (word.equals("handleStartupErrors")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                parseHandleStartupErrors(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            } else if (word.endsWith("insertionCheckInterval")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                insertionCheckInterval = parseIntegerEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                if (insertionCheckInterval < 100) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                    throw excLine(word + " must be at least 100 ms");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            } else if (word.equals("showInfo")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                showInfo = parseBooleanEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            } else if (word.equals("keyStoreCompatibilityMode")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                keyStoreCompatibilityMode = parseBooleanEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            } else if (word.equals("explicitCancel")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                explicitCancel = parseBooleanEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            } else if (word.equals("omitInitialize")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                omitInitialize = parseBooleanEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            } else if (word.equals("allowSingleThreadedModules")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                allowSingleThreadedModules = parseBooleanEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            } else if (word.equals("functionList")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                functionList = parseStringEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            } else if (word.equals("nssUseSecmod")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                nssUseSecmod = parseBooleanEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            } else if (word.equals("nssLibraryDirectory")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                nssLibraryDirectory = parseLibrary(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                nssUseSecmod = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            } else if (word.equals("nssSecmodDirectory")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                nssSecmodDirectory = expand(parseStringEntry(word));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                nssUseSecmod = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            } else if (word.equals("nssModule")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                nssModule = parseStringEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                nssUseSecmod = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            } else if (word.equals("nssDbMode")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                String mode = parseStringEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                if (mode.equals("readWrite")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                    nssDbMode = Secmod.DbMode.READ_WRITE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                } else if (mode.equals("readOnly")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                    nssDbMode = Secmod.DbMode.READ_ONLY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                } else if (mode.equals("noDb")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                    nssDbMode = Secmod.DbMode.NO_DB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                    throw excToken("nssDbMode must be one of readWrite, readOnly, and noDb:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                nssUseSecmod = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            } else if (word.equals("nssNetscapeDbWorkaround")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                nssNetscapeDbWorkaround = parseBooleanEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                nssUseSecmod = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            } else if (word.equals("nssArgs")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                parseNSSArgs(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            } else if (word.equals("nssUseSecmodTrust")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                nssUseSecmodTrust = parseBooleanEntry(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                throw new ConfigurationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        ("Unknown keyword '" + word + "', line " + st.lineno());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            parsedKeywords.add(word);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        reader.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        reader = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        st = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        parsedKeywords = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            throw new ConfigurationException("name must be specified");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        if (nssUseSecmod == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            if (library == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                throw new ConfigurationException("library must be specified");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            if (library != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                throw new ConfigurationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                    ("library must not be specified in NSS mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            if ((slotID != -1) || (slotListIndex != -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                throw new ConfigurationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                    ("slot and slotListIndex must not be specified in NSS mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            if (nssArgs != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                throw new ConfigurationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                    ("nssArgs must not be specified in NSS mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            if (nssUseSecmodTrust != false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                throw new ConfigurationException("nssUseSecmodTrust is an "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                    + "internal option and must not be specified in NSS mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    // Parsing helper methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    private int nextToken() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        int token = st.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        debug(st);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        return token;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    private void parseEquals() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        if (token != '=') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            throw excToken("Expected '=', read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    private void parseOpenBraces() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
            if (token == TT_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            if ((token == TT_WORD) && st.sval.equals("{")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            throw excToken("Expected '{', read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    private boolean isCloseBraces(int token) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        return (token == TT_WORD) && st.sval.equals("}");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    private String parseWord() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        if (token != TT_WORD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            throw excToken("Unexpected value:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        return st.sval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    private String parseStringEntry(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        checkDup(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        if (token != TT_WORD && token != '\"') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            // not a word token nor a string enclosed by double quotes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            throw excToken("Unexpected value:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        String value = st.sval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        debug(keyword + ": " + value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    private boolean parseBooleanEntry(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        checkDup(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        boolean value = parseBoolean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        debug(keyword + ": " + value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    private int parseIntegerEntry(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        checkDup(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        int value = decodeNumber(parseWord());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        debug(keyword + ": " + value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    private boolean parseBoolean() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        String val = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        if (val.equals("true")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        } else if (val.equals("false")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
            throw excToken("Expected boolean value, read:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    private String parseLine() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        String s = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            if ((token == TT_EOL) || (token == TT_EOF)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            if (token != TT_WORD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                throw excToken("Unexpected value");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            s = s + " " + st.sval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        return s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    private int decodeNumber(String str) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            if (str.startsWith("0x") || str.startsWith("0X")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                return Integer.parseInt(str.substring(2), 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                return Integer.parseInt(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        } catch (NumberFormatException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            throw excToken("Expected number, read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    private static boolean isNumber(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        if (s.length() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        char ch = s.charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        return ((ch >= '0') && (ch <= '9'));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    private void parseComma() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        if (token != ',') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            throw excToken("Expected ',', read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    private static boolean isByteArray(String val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        return val.startsWith("0h");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    private byte[] decodeByteArray(String str) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        if (str.startsWith("0h") == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            throw excToken("Expected byte array value, read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        str = str.substring(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        // XXX proper hex parsing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            return new BigInteger(str, 16).toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        } catch (NumberFormatException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            throw excToken("Expected byte array value, read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    private void checkDup(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        if (parsedKeywords.contains(keyword)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            throw excLine(keyword + " must only be specified once");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    // individual entry parsing methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    private String parseLibrary(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        checkDup(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        String lib = parseLine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        lib = expand(lib);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        int i = lib.indexOf("/$ISA/");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        if (i != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            // replace "/$ISA/" with "/sparcv9/" on 64-bit Solaris SPARC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            // and with "/amd64/" on Solaris AMD64.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            // On all other platforms, just turn it into a "/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            String osName = System.getProperty("os.name", "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            String osArch = System.getProperty("os.arch", "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            String prefix = lib.substring(0, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            String suffix = lib.substring(i + 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            if (osName.equals("SunOS") && osArch.equals("sparcv9")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                lib = prefix + "/sparcv9" + suffix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            } else if (osName.equals("SunOS") && osArch.equals("amd64")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                lib = prefix + "/amd64" + suffix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                lib = prefix + suffix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        debug(keyword + ": " + lib);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        return lib;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    private void parseDescription(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        checkDup(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        description = parseLine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        debug("description: " + description);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    private void parseSlotID(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        if (slotID >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            throw excLine("Duplicate slot definition");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        if (slotListIndex >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
            throw excLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                ("Only one of slot and slotListIndex must be specified");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        String slotString = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        slotID = decodeNumber(slotString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        debug("slot: " + slotID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    private void parseSlotListIndex(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        if (slotListIndex >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            throw excLine("Duplicate slotListIndex definition");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        if (slotID >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            throw excLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                ("Only one of slot and slotListIndex must be specified");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        String slotString = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        slotListIndex = decodeNumber(slotString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        debug("slotListIndex: " + slotListIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    private void parseEnabledMechanisms(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        enabledMechanisms = parseMechanisms(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    private void parseDisabledMechanisms(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        disabledMechanisms = parseMechanisms(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    private Set<Long> parseMechanisms(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        checkDup(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        Set<Long> mechs = new HashSet<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        parseOpenBraces();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            if (isCloseBraces(token)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            if (token == TT_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            if (token != TT_WORD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                throw excToken("Expected mechanism, read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            long mech = parseMechanism(st.sval);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            mechs.add(Long.valueOf(mech));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            System.out.print("mechanisms: [");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
            for (Long mech : mechs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                System.out.print(Functions.getMechanismName(mech));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                System.out.print(", ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            System.out.println("]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        return mechs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    private long parseMechanism(String mech) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        if (isNumber(mech)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            return decodeNumber(mech);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                return Functions.getMechanismId(mech);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                throw excLine("Unknown mechanism: " + mech);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    private void parseAttributes(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        if (templateManager == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
            templateManager = new TemplateManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        if (token == '=') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            String s = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            if (s.equals("compatibility") == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                throw excLine("Expected 'compatibility', read " + s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            setCompatibilityAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        if (token != '(') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            throw excToken("Expected '(' or '=', read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        String op = parseOperation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        parseComma();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        long objectClass = parseObjectClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        parseComma();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        long keyAlg = parseKeyAlgorithm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        if (token != ')') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            throw excToken("Expected ')', read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        parseOpenBraces();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        List<CK_ATTRIBUTE> attributes = new ArrayList<CK_ATTRIBUTE>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
            if (isCloseBraces(token)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            if (token == TT_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            if (token != TT_WORD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                throw excToken("Expected mechanism, read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            String attributeName = st.sval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            long attributeId = decodeAttributeName(attributeName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            String attributeValue = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            attributes.add(decodeAttributeValue(attributeId, attributeValue));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        templateManager.addTemplate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                (op, objectClass, keyAlg, attributes.toArray(CK_A0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    private void setCompatibilityAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        // all secret keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        templateManager.addTemplate(O_ANY, CKO_SECRET_KEY, PCKK_ANY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            TOKEN_FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            SENSITIVE_FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            EXTRACTABLE_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            ENCRYPT_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            DECRYPT_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            WRAP_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            UNWRAP_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        // generic secret keys are special
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        // They are used as MAC keys plus for the SSL/TLS (pre)master secrets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        templateManager.addTemplate(O_ANY, CKO_SECRET_KEY, CKK_GENERIC_SECRET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            SIGN_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            VERIFY_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            ENCRYPT_NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            DECRYPT_NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            WRAP_NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            UNWRAP_NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            DERIVE_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        // all private and public keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        templateManager.addTemplate(O_ANY, CKO_PRIVATE_KEY, PCKK_ANY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            TOKEN_FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            SENSITIVE_FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            EXTRACTABLE_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        templateManager.addTemplate(O_ANY, CKO_PUBLIC_KEY, PCKK_ANY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            TOKEN_FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        // additional attributes for RSA private keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        templateManager.addTemplate(O_ANY, CKO_PRIVATE_KEY, CKK_RSA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            DECRYPT_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            SIGN_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            SIGN_RECOVER_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            UNWRAP_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        // additional attributes for RSA public keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        templateManager.addTemplate(O_ANY, CKO_PUBLIC_KEY, CKK_RSA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            ENCRYPT_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            VERIFY_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
            VERIFY_RECOVER_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            WRAP_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        // additional attributes for DSA private keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        templateManager.addTemplate(O_ANY, CKO_PRIVATE_KEY, CKK_DSA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            SIGN_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        // additional attributes for DSA public keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        templateManager.addTemplate(O_ANY, CKO_PUBLIC_KEY, CKK_DSA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
            VERIFY_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        // additional attributes for DH private keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        templateManager.addTemplate(O_ANY, CKO_PRIVATE_KEY, CKK_DH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            DERIVE_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        // additional attributes for EC private keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        templateManager.addTemplate(O_ANY, CKO_PRIVATE_KEY, CKK_EC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
            SIGN_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            DERIVE_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        // additional attributes for EC public keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        templateManager.addTemplate(O_ANY, CKO_PUBLIC_KEY, CKK_EC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
            VERIFY_TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    private final static CK_ATTRIBUTE[] CK_A0 = new CK_ATTRIBUTE[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    private String parseOperation() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        String op = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        if (op.equals("*")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            return TemplateManager.O_ANY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        } else if (op.equals("generate")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            return TemplateManager.O_GENERATE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        } else if (op.equals("import")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            return TemplateManager.O_IMPORT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            throw excLine("Unknown operation " + op);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    private long parseObjectClass() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        String name = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            return Functions.getObjectClassId(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            throw excLine("Unknown object class " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    private long parseKeyAlgorithm() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        String name = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        if (isNumber(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            return decodeNumber(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                return Functions.getKeyId(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                throw excLine("Unknown key algorithm " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    private long decodeAttributeName(String name) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        if (isNumber(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            return decodeNumber(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                return Functions.getAttributeId(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                throw excLine("Unknown attribute name " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    private CK_ATTRIBUTE decodeAttributeValue(long id, String value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        if (value.equals("null")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            return new CK_ATTRIBUTE(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        } else if (value.equals("true")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            return new CK_ATTRIBUTE(id, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        } else if (value.equals("false")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            return new CK_ATTRIBUTE(id, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        } else if (isByteArray(value)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
            return new CK_ATTRIBUTE(id, decodeByteArray(value));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        } else if (isNumber(value)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            return new CK_ATTRIBUTE(id, Integer.valueOf(decodeNumber(value)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            throw excLine("Unknown attribute value " + value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    private void parseNSSArgs(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        checkDup(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        int token = nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        if (token != '"') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            throw excToken("Expected quoted string");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        nssArgs = expand(st.sval);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
        debug("nssArgs: " + nssArgs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    private void parseHandleStartupErrors(String keyword) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        checkDup(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        parseEquals();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        String val = parseWord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        if (val.equals("ignoreAll")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            handleStartupErrors = ERR_IGNORE_ALL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        } else if (val.equals("ignoreMissingLibrary")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            handleStartupErrors = ERR_IGNORE_LIB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        } else if (val.equals("halt")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            handleStartupErrors = ERR_HALT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            throw excToken("Invalid value for handleStartupErrors:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        debug("handleStartupErrors: " + handleStartupErrors);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
class ConfigurationException extends IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
    ConfigurationException(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        super(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
}