src/java.naming/share/classes/sun/security/provider/certpath/ldap/JdkLDAP.java

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

@@ -25,15 +25,11 @@
 
 package sun.security.provider.certpath.ldap;
 
 import java.util.HashMap;
 import java.util.List;
-import java.security.Provider;
-import java.security.NoSuchAlgorithmException;
-import java.security.InvalidParameterException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.ProviderException;
+import java.security.*;
 import java.security.cert.CertStoreParameters;
 
 /**
  * Provider class for the JdkLDAP provider.
  * Supports LDAP cert store.

@@ -73,18 +69,24 @@
     }
 
     public JdkLDAP() {
         super("JdkLDAP", 1.9d, "JdkLDAP Provider (implements LDAP CertStore)");
 
+        final Provider p = this;
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
         HashMap<String, String> attrs = new HashMap<>(2);
         attrs.put("LDAPSchema", "RFC2587");
         attrs.put("ImplementedIn", "Software");
 
         /*
          * CertStore
          * attrs: LDAPSchema, ImplementedIn
          */
-        putService(new ProviderService(this, "CertStore",
+                putService(new ProviderService(p, "CertStore",
             "LDAP", "sun.security.provider.certpath.ldap.LDAPCertStore",
             null, attrs));
+                return null;
     }
+        });
+    }
 }