1 /* |
1 /* |
2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
72 CipherSuiteList(String[] names) { |
72 CipherSuiteList(String[] names) { |
73 if (names == null) { |
73 if (names == null) { |
74 throw new IllegalArgumentException("CipherSuites may not be null"); |
74 throw new IllegalArgumentException("CipherSuites may not be null"); |
75 } |
75 } |
76 cipherSuites = new ArrayList<CipherSuite>(names.length); |
76 cipherSuites = new ArrayList<CipherSuite>(names.length); |
77 // refresh available cache once if a CipherSuite is not available |
|
78 // (maybe new JCE providers have been installed) |
|
79 boolean refreshed = false; |
|
80 for (int i = 0; i < names.length; i++) { |
77 for (int i = 0; i < names.length; i++) { |
81 String suiteName = names[i]; |
78 String suiteName = names[i]; |
82 CipherSuite suite = CipherSuite.valueOf(suiteName); |
79 CipherSuite suite = CipherSuite.valueOf(suiteName); |
83 if (suite.isAvailable() == false) { |
80 if (suite.isAvailable() == false) { |
84 if (refreshed == false) { |
81 throw new IllegalArgumentException("Cannot support " |
85 // clear the cache so that the isAvailable() call below |
82 + suiteName + " with currently installed providers"); |
86 // does a full check |
|
87 clearAvailableCache(); |
|
88 refreshed = true; |
|
89 } |
|
90 // still missing? |
|
91 if (suite.isAvailable() == false) { |
|
92 throw new IllegalArgumentException("Cannot support " |
|
93 + suiteName + " with currently installed providers"); |
|
94 } |
|
95 } |
83 } |
96 cipherSuites.add(suite); |
84 cipherSuites.add(suite); |
97 } |
85 } |
98 } |
86 } |
99 |
87 |
193 suiteBytes[i+1] = (byte)c.id; |
181 suiteBytes[i+1] = (byte)c.id; |
194 i += 2; |
182 i += 2; |
195 } |
183 } |
196 s.putBytes16(suiteBytes); |
184 s.putBytes16(suiteBytes); |
197 } |
185 } |
198 |
|
199 /** |
|
200 * Clear cache of available ciphersuites. If we support all ciphers |
|
201 * internally, there is no need to clear the cache and calling this |
|
202 * method has no effect. |
|
203 */ |
|
204 static synchronized void clearAvailableCache() { |
|
205 if (CipherSuite.DYNAMIC_AVAILABILITY) { |
|
206 CipherSuite.BulkCipher.clearAvailableCache(); |
|
207 JsseJce.clearEcAvailable(); |
|
208 } |
|
209 } |
|
210 } |
186 } |