test/java/lang/SecurityManager/CheckSecurityProvider.java

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

@@ -21,11 +21,11 @@
  * questions.
  */
 
 /*
  * @test
- * @bug 6997010
+ * @bug 6997010 7191662
  * @summary Consolidate java.security files into one file with modifications
  */
 
 import java.security.Provider;
 import java.security.Security;

@@ -34,30 +34,29 @@
 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
- * removed. This is why the known security providers have to
- * be explicitly listed below.
+ * removed. With the security manager enabled, this test can also catch
+ * scenarios where the default permission policy needs to be updated.
  */
 public class CheckSecurityProvider {
     public static void main(String[] args) throws Exception {
 
         String os = System.getProperty("os.name");
 
+        System.setSecurityManager(new SecurityManager());
         /*
          * 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<>();
 
         if (os.equals("SunOS")) {
-            if (!isOpenJDKOnly()) {
                 expected.add("com.oracle.security.ucrypto.UcryptoProvider");
-            }
             expected.add("sun.security.pkcs11.SunPKCS11");
         }
         expected.add("sun.security.provider.Sun");
         expected.add("sun.security.rsa.SunRsaSign");
         expected.add("sun.security.ec.SunEC");

@@ -66,10 +65,11 @@
         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");
         expected.add("sun.security.provider.certpath.ldap.JdkLDAP");
+        expected.add("com.sun.security.sasl.gsskerb.JdkSASL");
         if (os.startsWith("Windows")) {
             expected.add("sun.security.mscapi.SunMSCAPI");
         }
         if (os.contains("OS X")) {
             expected.add("apple.security.AppleProvider");

@@ -88,12 +88,6 @@
         }
         if (iter.hasNext()) {
             throw new Exception("More expected");
         }
     }
-
-    // Copied from CheckPackageAccess.java in the same directory
-    private static boolean isOpenJDKOnly() {
-        String prop = System.getProperty("java.runtime.name");
-        return prop != null && prop.startsWith("OpenJDK");
-    }
 }