src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Config.java

Print this page
7191662: JCE providers should be located via ServiceLoader

*** 1,7 **** /* ! * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 67,108 **** } else { staticAllowSingleThreadedModules = true; } } - // temporary storage for configurations - // needed because the SunPKCS11 needs to call the superclass constructor - // in provider before accessing any instance variables - private final static Map<String,Config> configMap = - new HashMap<String,Config>(); - - static Config getConfig(final String name, final InputStream stream) { - Config config = configMap.get(name); - if (config != null) { - return config; - } - try { - config = new Config(name, stream); - configMap.put(name, config); - return config; - } catch (Exception e) { - throw new ProviderException("Error parsing configuration", e); - } - } - - static Config removeConfig(String name) { - return configMap.remove(name); - } - private final static boolean DEBUG = false; private static void debug(Object o) { if (DEBUG) { System.out.println(o); } } // Reader and StringTokenizer used during parsing private Reader reader; private StreamTokenizer st; --- 67,93 ---- } else { staticAllowSingleThreadedModules = true; } } private final static boolean DEBUG = false; private static void debug(Object o) { if (DEBUG) { System.out.println(o); } } + private static final Config DUMMY = new Config(); + + static Config getDummyConfig() { + return DUMMY; + } + + // file name containing this configuration + private String filename; + // Reader and StringTokenizer used during parsing private Reader reader; private StreamTokenizer st;
*** 199,227 **** // Flag to indicate whether NSS should favour performance (false) or // memory footprint (true). private boolean nssOptimizeSpace = false; ! private Config(String filename, InputStream in) throws IOException { ! if (in == null) { if (filename.startsWith("--")) { // inline config String config = filename.substring(2).replace("\\n", "\n"); reader = new StringReader(config); } else { ! in = new FileInputStream(expand(filename)); } - } - if (reader == null) { - reader = new BufferedReader(new InputStreamReader(in)); - } parsedKeywords = new HashSet<String>(); st = new StreamTokenizer(reader); setupTokenizer(); parse(); } String getName() { return name; } String getLibrary() { --- 184,218 ---- // Flag to indicate whether NSS should favour performance (false) or // memory footprint (true). private boolean nssOptimizeSpace = false; ! private Config() { ! name = "Dummy"; ! description = "Unconfigured and unusable PKCS11 provider"; ! } ! ! Config(String fn) throws IOException { ! this.filename = fn; if (filename.startsWith("--")) { // inline config String config = filename.substring(2).replace("\\n", "\n"); reader = new StringReader(config); } else { ! reader = new BufferedReader(new InputStreamReader ! (new FileInputStream(expand(filename)))); } parsedKeywords = new HashSet<String>(); st = new StreamTokenizer(reader); setupTokenizer(); parse(); } + String getFileName() { + return filename; + } + String getName() { return name; } String getLibrary() {