6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6997010
27 * @summary Consolidate java.security files into one file with modifications
28 */
29
30 import java.security.Provider;
31 import java.security.Security;
32 import java.util.ArrayList;
33 import java.util.Iterator;
34 import java.util.List;
35
36 /*
37 * The main benefit of this test is to catch merge errors or other types
38 * of issues where one or more of the security providers are accidentally
39 * removed. This is why the known security providers have to
40 * be explicitly listed below.
41 */
42 public class CheckSecurityProvider {
43 public static void main(String[] args) throws Exception {
44
45 String os = System.getProperty("os.name");
46
47 /*
48 * This array should be updated whenever new security providers
49 * are added to the the java.security file.
50 * NOTE: it should be in the same order as the java.security file
51 */
52
53 List<String> expected = new ArrayList<>();
54
55 if (os.equals("SunOS")) {
56 if (!isOpenJDKOnly()) {
57 expected.add("com.oracle.security.ucrypto.UcryptoProvider");
58 }
59 expected.add("sun.security.pkcs11.SunPKCS11");
60 }
61 expected.add("sun.security.provider.Sun");
62 expected.add("sun.security.rsa.SunRsaSign");
63 expected.add("sun.security.ec.SunEC");
64 expected.add("com.sun.net.ssl.internal.ssl.Provider");
65 expected.add("com.sun.crypto.provider.SunJCE");
66 expected.add("sun.security.jgss.SunProvider");
67 expected.add("com.sun.security.sasl.Provider");
68 expected.add("org.jcp.xml.dsig.internal.dom.XMLDSigRI");
69 expected.add("sun.security.smartcardio.SunPCSC");
70 expected.add("sun.security.provider.certpath.ldap.JdkLDAP");
71 if (os.startsWith("Windows")) {
72 expected.add("sun.security.mscapi.SunMSCAPI");
73 }
74 if (os.contains("OS X")) {
75 expected.add("apple.security.AppleProvider");
76 }
77
78 Iterator<String> iter = expected.iterator();
79 for (Provider p: Security.getProviders()) {
80 if (!iter.hasNext()) {
81 throw new Exception("Less expected");
82 }
83 String n1 = iter.next();
84 String n2 = p.getClass().getName();
85 if (!n1.equals(n2)) {
86 throw new Exception("Expected " + n1 + ", actual " + n2);
87 }
88 }
89 if (iter.hasNext()) {
90 throw new Exception("More expected");
91 }
92 }
93
94 // Copied from CheckPackageAccess.java in the same directory
95 private static boolean isOpenJDKOnly() {
96 String prop = System.getProperty("java.runtime.name");
97 return prop != null && prop.startsWith("OpenJDK");
98 }
99 }
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6997010 7191662
27 * @summary Consolidate java.security files into one file with modifications
28 */
29
30 import java.security.Provider;
31 import java.security.Security;
32 import java.util.ArrayList;
33 import java.util.Iterator;
34 import java.util.List;
35
36 /*
37 * The main benefit of this test is to catch merge errors or other types
38 * of issues where one or more of the security providers are accidentally
39 * removed. With the security manager enabled, this test can also catch
40 * scenarios where the default permission policy needs to be updated.
41 */
42 public class CheckSecurityProvider {
43 public static void main(String[] args) throws Exception {
44
45 String os = System.getProperty("os.name");
46
47 System.setSecurityManager(new SecurityManager());
48 /*
49 * This array should be updated whenever new security providers
50 * are added to the the java.security file.
51 * NOTE: it should be in the same order as the java.security file
52 */
53
54 List<String> expected = new ArrayList<>();
55
56 // NOTE: the ordering must match what's defined inside java.security
57 if (os.equals("SunOS")) {
58 expected.add("com.oracle.security.ucrypto.UcryptoProvider");
59 expected.add("sun.security.pkcs11.SunPKCS11");
60 }
61 expected.add("sun.security.provider.Sun");
62 expected.add("sun.security.rsa.SunRsaSign");
63 expected.add("sun.security.ec.SunEC");
64 expected.add("com.sun.net.ssl.internal.ssl.Provider");
65 expected.add("com.sun.crypto.provider.SunJCE");
66 expected.add("sun.security.jgss.SunProvider");
67 expected.add("com.sun.security.sasl.Provider");
68 expected.add("org.jcp.xml.dsig.internal.dom.XMLDSigRI");
69 expected.add("sun.security.smartcardio.SunPCSC");
70 expected.add("sun.security.provider.certpath.ldap.JdkLDAP");
71 expected.add("com.sun.security.sasl.gsskerb.JdkSASL");
72 if (os.startsWith("Windows")) {
73 expected.add("sun.security.mscapi.SunMSCAPI");
74 }
75 if (os.contains("OS X")) {
76 expected.add("apple.security.AppleProvider");
77 }
78 if (!os.equals("SunOS")) {
79 expected.add("sun.security.pkcs11.SunPKCS11");
80 }
81
82 Iterator<String> iter = expected.iterator();
83 for (Provider p: Security.getProviders()) {
84 if (!iter.hasNext()) {
85 throw new Exception("Less expected");
86 }
87 String n1 = iter.next();
88 String n2 = p.getClass().getName();
89 if (!n1.equals(n2)) {
90 throw new Exception("Expected " + n1 + ", actual " + n2);
91 }
92 }
93 if (iter.hasNext()) {
94 throw new Exception("More expected");
95 }
96 }
97 }
|