2014-08-11 03:11:55 +00:00
|
|
|
/*
|
2015-05-15 01:14:25 +00:00
|
|
|
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
2014-08-11 03:11:55 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @test
|
2015-06-26 21:34:34 +00:00
|
|
|
* @bug 6997010 7191662
|
2014-08-11 03:11:55 +00:00
|
|
|
* @summary Consolidate java.security files into one file with modifications
|
2015-06-26 21:34:34 +00:00
|
|
|
* @run main/othervm CheckSecurityProvider
|
2014-08-11 03:11:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import java.security.Provider;
|
|
|
|
import java.security.Security;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The main benefit of this test is to catch merge errors or other types
|
|
|
|
* of issues where one or more of the security providers are accidentally
|
2015-06-26 21:34:34 +00:00
|
|
|
* removed. With the security manager enabled, this test can also catch
|
|
|
|
* scenarios where the default permission policy needs to be updated.
|
2014-08-11 03:11:55 +00:00
|
|
|
*/
|
|
|
|
public class CheckSecurityProvider {
|
|
|
|
public static void main(String[] args) throws Exception {
|
2015-06-26 21:34:34 +00:00
|
|
|
System.setSecurityManager(new SecurityManager());
|
2014-08-11 03:11:55 +00:00
|
|
|
|
|
|
|
String os = System.getProperty("os.name");
|
|
|
|
/*
|
|
|
|
* This array should be updated whenever new security providers
|
|
|
|
* are added to the the java.security file.
|
|
|
|
* NOTE: it should be in the same order as the java.security file
|
|
|
|
*/
|
|
|
|
|
|
|
|
List<String> expected = new ArrayList<>();
|
|
|
|
|
2015-06-26 21:34:34 +00:00
|
|
|
// NOTE: the ordering must match what's defined inside java.security
|
2014-08-11 03:11:55 +00:00
|
|
|
if (os.equals("SunOS")) {
|
2015-06-26 21:34:34 +00:00
|
|
|
expected.add("com.oracle.security.ucrypto.UcryptoProvider");
|
2014-08-11 03:11:55 +00:00
|
|
|
expected.add("sun.security.pkcs11.SunPKCS11");
|
|
|
|
}
|
|
|
|
expected.add("sun.security.provider.Sun");
|
|
|
|
expected.add("sun.security.rsa.SunRsaSign");
|
|
|
|
expected.add("sun.security.ec.SunEC");
|
|
|
|
expected.add("com.sun.net.ssl.internal.ssl.Provider");
|
|
|
|
expected.add("com.sun.crypto.provider.SunJCE");
|
|
|
|
expected.add("sun.security.jgss.SunProvider");
|
|
|
|
expected.add("com.sun.security.sasl.Provider");
|
|
|
|
expected.add("org.jcp.xml.dsig.internal.dom.XMLDSigRI");
|
|
|
|
expected.add("sun.security.smartcardio.SunPCSC");
|
2015-05-15 01:14:25 +00:00
|
|
|
expected.add("sun.security.provider.certpath.ldap.JdkLDAP");
|
2015-06-26 21:34:34 +00:00
|
|
|
expected.add("com.sun.security.sasl.gsskerb.JdkSASL");
|
2014-08-11 03:11:55 +00:00
|
|
|
if (os.startsWith("Windows")) {
|
|
|
|
expected.add("sun.security.mscapi.SunMSCAPI");
|
|
|
|
}
|
|
|
|
if (os.contains("OS X")) {
|
|
|
|
expected.add("apple.security.AppleProvider");
|
|
|
|
}
|
2015-06-26 21:34:34 +00:00
|
|
|
if (!os.equals("SunOS")) {
|
|
|
|
expected.add("sun.security.pkcs11.SunPKCS11");
|
|
|
|
}
|
2014-08-11 03:11:55 +00:00
|
|
|
|
|
|
|
Iterator<String> iter = expected.iterator();
|
|
|
|
for (Provider p: Security.getProviders()) {
|
|
|
|
if (!iter.hasNext()) {
|
|
|
|
throw new Exception("Less expected");
|
|
|
|
}
|
|
|
|
String n1 = iter.next();
|
|
|
|
String n2 = p.getClass().getName();
|
|
|
|
if (!n1.equals(n2)) {
|
|
|
|
throw new Exception("Expected " + n1 + ", actual " + n2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (iter.hasNext()) {
|
|
|
|
throw new Exception("More expected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|