< prev index next >

src/java.base/share/classes/sun/security/jca/ProviderConfig.java

Print this page




 168         if (shouldLoad() == false) {
 169             return null;
 170         }
 171 
 172         // Create providers which are in java.base directly
 173         if (provName.equals("SUN") || provName.equals("sun.security.provider.Sun")) {
 174             p = new sun.security.provider.Sun();
 175         } else if (provName.equals("SunRsaSign") || provName.equals("sun.security.rsa.SunRsaSign")) {
 176             p = new sun.security.rsa.SunRsaSign();
 177         } else if (provName.equals("SunJCE") || provName.equals("com.sun.crypto.provider.SunJCE")) {
 178             p = new com.sun.crypto.provider.SunJCE();
 179         } else if (provName.equals("SunJSSE") || provName.equals("com.sun.net.ssl.internal.ssl.Provider")) {
 180             p = new com.sun.net.ssl.internal.ssl.Provider();
 181         } else if (provName.equals("Apple") || provName.equals("apple.security.AppleProvider")) {
 182             // need to use reflection since this class only exists on MacOsx
 183             p = AccessController.doPrivileged(new PrivilegedAction<Provider>() {
 184                 public Provider run() {
 185                     try {
 186                         Class<?> c = Class.forName("apple.security.AppleProvider");
 187                         if (Provider.class.isAssignableFrom(c)) {
 188                             return (Provider) c.newInstance();


 189                         } else {
 190                             return null;
 191                         }
 192                     } catch (Exception ex) {
 193                         if (debug != null) {
 194                         debug.println("Error loading provider Apple");
 195                         ex.printStackTrace();
 196                     }
 197                     return null;
 198                 }
 199              }
 200              });
 201         } else {
 202             if (isLoading) {
 203                 // because this method is synchronized, this can only
 204                 // happen if there is recursion.
 205                 if (debug != null) {
 206                     debug.println("Recursion loading provider: " + this);
 207                     new Exception("Call trace").printStackTrace();
 208                 }


 369         private Provider legacyLoad(String classname) {
 370 
 371             if (debug != null) {
 372                 debug.println("Loading legacy provider: " + classname);
 373             }
 374 
 375             try {
 376                 Class<?> provClass =
 377                     ClassLoader.getSystemClassLoader().loadClass(classname);
 378 
 379                 // only continue if the specified class extends Provider
 380                 if (!Provider.class.isAssignableFrom(provClass)) {
 381                     if (debug != null) {
 382                         debug.println(classname + " is not a provider");
 383                     }
 384                     return null;
 385                 }
 386 
 387                 Provider p = AccessController.doPrivileged
 388                     (new PrivilegedExceptionAction<Provider>() {

 389                     public Provider run() throws Exception {
 390                         return (Provider) provClass.newInstance();
 391                     }
 392                 });
 393                 return p;
 394             } catch (Exception e) {
 395                 Throwable t;
 396                 if (e instanceof InvocationTargetException) {
 397                     t = ((InvocationTargetException)e).getCause();
 398                 } else {
 399                     t = e;
 400                 }
 401                 if (debug != null) {
 402                     debug.println("Error loading legacy provider " + classname);
 403                     t.printStackTrace();
 404                 }
 405                 // provider indicates fatal error, pass through exception
 406                 if (t instanceof ProviderException) {
 407                     throw (ProviderException) t;
 408                 }


 168         if (shouldLoad() == false) {
 169             return null;
 170         }
 171 
 172         // Create providers which are in java.base directly
 173         if (provName.equals("SUN") || provName.equals("sun.security.provider.Sun")) {
 174             p = new sun.security.provider.Sun();
 175         } else if (provName.equals("SunRsaSign") || provName.equals("sun.security.rsa.SunRsaSign")) {
 176             p = new sun.security.rsa.SunRsaSign();
 177         } else if (provName.equals("SunJCE") || provName.equals("com.sun.crypto.provider.SunJCE")) {
 178             p = new com.sun.crypto.provider.SunJCE();
 179         } else if (provName.equals("SunJSSE") || provName.equals("com.sun.net.ssl.internal.ssl.Provider")) {
 180             p = new com.sun.net.ssl.internal.ssl.Provider();
 181         } else if (provName.equals("Apple") || provName.equals("apple.security.AppleProvider")) {
 182             // need to use reflection since this class only exists on MacOsx
 183             p = AccessController.doPrivileged(new PrivilegedAction<Provider>() {
 184                 public Provider run() {
 185                     try {
 186                         Class<?> c = Class.forName("apple.security.AppleProvider");
 187                         if (Provider.class.isAssignableFrom(c)) {
 188                             @SuppressWarnings("deprecation")
 189                             Object tmp = c.newInstance();
 190                             return (Provider) tmp;
 191                         } else {
 192                             return null;
 193                         }
 194                     } catch (Exception ex) {
 195                         if (debug != null) {
 196                         debug.println("Error loading provider Apple");
 197                         ex.printStackTrace();
 198                     }
 199                     return null;
 200                 }
 201              }
 202              });
 203         } else {
 204             if (isLoading) {
 205                 // because this method is synchronized, this can only
 206                 // happen if there is recursion.
 207                 if (debug != null) {
 208                     debug.println("Recursion loading provider: " + this);
 209                     new Exception("Call trace").printStackTrace();
 210                 }


 371         private Provider legacyLoad(String classname) {
 372 
 373             if (debug != null) {
 374                 debug.println("Loading legacy provider: " + classname);
 375             }
 376 
 377             try {
 378                 Class<?> provClass =
 379                     ClassLoader.getSystemClassLoader().loadClass(classname);
 380 
 381                 // only continue if the specified class extends Provider
 382                 if (!Provider.class.isAssignableFrom(provClass)) {
 383                     if (debug != null) {
 384                         debug.println(classname + " is not a provider");
 385                     }
 386                     return null;
 387                 }
 388 
 389                 Provider p = AccessController.doPrivileged
 390                     (new PrivilegedExceptionAction<Provider>() {
 391                     @SuppressWarnings("deprecation") // Class.newInstance
 392                     public Provider run() throws Exception {
 393                         return (Provider) provClass.newInstance();
 394                     }
 395                 });
 396                 return p;
 397             } catch (Exception e) {
 398                 Throwable t;
 399                 if (e instanceof InvocationTargetException) {
 400                     t = ((InvocationTargetException)e).getCause();
 401                 } else {
 402                     t = e;
 403                 }
 404                 if (debug != null) {
 405                     debug.println("Error loading legacy provider " + classname);
 406                     t.printStackTrace();
 407                 }
 408                 // provider indicates fatal error, pass through exception
 409                 if (t instanceof ProviderException) {
 410                     throw (ProviderException) t;
 411                 }
< prev index next >