test/sun/security/pkcs11/KeyStore/Basic.java

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

@@ -366,11 +366,16 @@
     }
 
     private static void module() throws Exception {
 
         // perform Security.addProvider of P11 provider
-        ProviderLoader.go(System.getProperty("CUSTOM_P11_CONFIG"));
+        Provider p = getSunPKCS11(System.getProperty("CUSTOM_P11_CONFIG"));
+        if (p != null) {
+            Security.addProvider(p);
+        } else {
+            throw new Exception("Error: PKCS11 provider configuration failed");
+        }
 
         String KS_PROVIDER = "SunPKCS11-" + System.getProperty("TOKEN");
 
         KeyStoreLoginModule m = new KeyStoreLoginModule();
         Subject s = new Subject();