< prev index next >

src/java.base/share/classes/java/security/Policy.java

Print this page




 205             policyProvider.equals(DEFAULT_POLICY))
 206         {
 207             Policy polFile = new sun.security.provider.PolicyFile();
 208             policy.set(new PolicyInfo(polFile, true));
 209             return polFile;
 210         }
 211 
 212         /*
 213          * Locate, load, and instantiate the policy.provider impl using
 214          * the system class loader. While doing so, install the bootstrap
 215          * provider to avoid potential recursion.
 216          */
 217         Policy polFile = new sun.security.provider.PolicyFile();
 218         policy.set(new PolicyInfo(polFile, false));
 219 
 220         Policy pol = AccessController.doPrivileged(new PrivilegedAction<>() {
 221             @Override
 222             public Policy run() {
 223                 try {
 224                     ClassLoader scl = ClassLoader.getSystemClassLoader();
 225                     Class<?> c = Class.forName(policyProvider, true, scl);
 226                     return (Policy)c.newInstance();

 227                 } catch (Exception e) {
 228                     if (debug != null) {
 229                         debug.println("policy provider " + policyProvider +
 230                                       " not available");
 231                         e.printStackTrace();
 232                     }
 233                     return null;
 234                 }
 235             }
 236         });
 237 
 238         if (pol == null) {
 239             // Fallback and use the system default implementation
 240             if (debug != null) {
 241                 debug.println("using " + DEFAULT_POLICY);
 242             }
 243             pol = polFile;
 244         }
 245         policy.set(new PolicyInfo(pol, true));
 246         return pol;




 205             policyProvider.equals(DEFAULT_POLICY))
 206         {
 207             Policy polFile = new sun.security.provider.PolicyFile();
 208             policy.set(new PolicyInfo(polFile, true));
 209             return polFile;
 210         }
 211 
 212         /*
 213          * Locate, load, and instantiate the policy.provider impl using
 214          * the system class loader. While doing so, install the bootstrap
 215          * provider to avoid potential recursion.
 216          */
 217         Policy polFile = new sun.security.provider.PolicyFile();
 218         policy.set(new PolicyInfo(polFile, false));
 219 
 220         Policy pol = AccessController.doPrivileged(new PrivilegedAction<>() {
 221             @Override
 222             public Policy run() {
 223                 try {
 224                     ClassLoader scl = ClassLoader.getSystemClassLoader();
 225                     @SuppressWarnings("deprecation")
 226                     Object o = Class.forName(policyProvider, true, scl).newInstance();
 227                     return (Policy)o;
 228                 } catch (Exception e) {
 229                     if (debug != null) {
 230                         debug.println("policy provider " + policyProvider +
 231                                       " not available");
 232                         e.printStackTrace();
 233                     }
 234                     return null;
 235                 }
 236             }
 237         });
 238 
 239         if (pol == null) {
 240             // Fallback and use the system default implementation
 241             if (debug != null) {
 242                 debug.println("using " + DEFAULT_POLICY);
 243             }
 244             pol = polFile;
 245         }
 246         policy.set(new PolicyInfo(pol, true));
 247         return pol;


< prev index next >