1 /*
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
161 * Return a new ProviderList parsed from the java.security Properties.
162 */
163 private ProviderList() {
164 List<ProviderConfig> configList = new ArrayList<>();
165 for (int i = 1; true; i++) {
166 String entry = Security.getProperty("security.provider." + i);
167 if (entry == null) {
168 break;
169 }
170 entry = entry.trim();
171 if (entry.length() == 0) {
172 System.err.println("invalid entry for " +
173 "security.provider." + i);
174 break;
175 }
176 int k = entry.indexOf(' ');
177 ProviderConfig config;
178 if (k == -1) {
179 config = new ProviderConfig(entry);
180 } else {
181 String className = entry.substring(0, k);
182 String argument = entry.substring(k + 1).trim();
183 config = new ProviderConfig(className, argument);
184 }
185
186 // Get rid of duplicate providers.
187 if (configList.contains(config) == false) {
188 configList.add(config);
189 }
190 }
191 configs = configList.toArray(PC0);
192 if (debug != null) {
193 debug.println("provider configuration: " + configList);
194 }
195 }
196
197 /**
198 * Construct a special ProviderList for JAR verification. It consists
199 * of the providers specified via jarClassNames, which must be on the
200 * bootclasspath and cannot be in signed JAR files. This is to avoid
201 * possible recursion and deadlock during verification.
202 */
203 ProviderList getJarList(String[] jarClassNames) {
204 List<ProviderConfig> newConfigs = new ArrayList<>();
205 for (String className : jarClassNames) {
206 ProviderConfig newConfig = new ProviderConfig(className);
207 for (ProviderConfig config : configs) {
208 // if the equivalent object is present in this provider list,
209 // use the old object rather than the new object.
210 // this ensures that when the provider is loaded in the
211 // new thread local list, it will also become available
212 // in this provider list
213 if (config.equals(newConfig)) {
214 newConfig = config;
215 break;
216 }
217 }
218 newConfigs.add(newConfig);
219 }
220 ProviderConfig[] configArray = newConfigs.toArray(PC0);
221 return new ProviderList(configArray, false);
222 }
223
224 public int size() {
225 return configs.length;
226 }
|
1 /*
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
161 * Return a new ProviderList parsed from the java.security Properties.
162 */
163 private ProviderList() {
164 List<ProviderConfig> configList = new ArrayList<>();
165 for (int i = 1; true; i++) {
166 String entry = Security.getProperty("security.provider." + i);
167 if (entry == null) {
168 break;
169 }
170 entry = entry.trim();
171 if (entry.length() == 0) {
172 System.err.println("invalid entry for " +
173 "security.provider." + i);
174 break;
175 }
176 int k = entry.indexOf(' ');
177 ProviderConfig config;
178 if (k == -1) {
179 config = new ProviderConfig(entry);
180 } else {
181 String provName = entry.substring(0, k);
182 String argument = entry.substring(k + 1).trim();
183 config = new ProviderConfig(provName, argument);
184 }
185
186 // Get rid of duplicate providers.
187 if (configList.contains(config) == false) {
188 configList.add(config);
189 }
190 }
191 configs = configList.toArray(PC0);
192 if (debug != null) {
193 debug.println("provider configuration: " + configList);
194 }
195 }
196
197 /**
198 * Construct a special ProviderList for JAR verification. It consists
199 * of the providers specified via jarClassNames, which must be on the
200 * bootclasspath and cannot be in signed JAR files. This is to avoid
201 * possible recursion and deadlock during verification.
202 */
203 ProviderList getJarList(String[] jarProvNames) {
204 List<ProviderConfig> newConfigs = new ArrayList<>();
205 for (String provName : jarProvNames) {
206 ProviderConfig newConfig = new ProviderConfig(provName);
207 for (ProviderConfig config : configs) {
208 // if the equivalent object is present in this provider list,
209 // use the old object rather than the new object.
210 // this ensures that when the provider is loaded in the
211 // new thread local list, it will also become available
212 // in this provider list
213 if (config.equals(newConfig)) {
214 newConfig = config;
215 break;
216 }
217 }
218 newConfigs.add(newConfig);
219 }
220 ProviderConfig[] configArray = newConfigs.toArray(PC0);
221 return new ProviderList(configArray, false);
222 }
223
224 public int size() {
225 return configs.length;
226 }
|