< prev index next >

src/java.base/share/classes/sun/security/provider/PolicyFile.java

Print this page
rev 58266 : imported patch XXXXXXX-typos


 283         init((URL)null);
 284     }
 285 
 286     /**
 287      * Initializes the Policy object and reads the default policy
 288      * from the specified URL only.
 289      */
 290     public PolicyFile(URL url) {
 291         this.url = url;
 292         init(url);
 293     }
 294 
 295     /**
 296      * Initializes the Policy object and reads the default policy
 297      * configuration file(s) into the Policy object.
 298      *
 299      * See the class description for details on the algorithm used to
 300      * initialize the Policy object.
 301      */
 302     private void init(URL url) {
 303         // Properties are set once for each init(); ignore changes between
 304         // between diff invocations of initPolicyFile(policy, url, info).
 305         String numCacheStr =
 306           AccessController.doPrivileged(new PrivilegedAction<>() {
 307             @Override
 308             public String run() {
 309                 expandProperties = "true".equalsIgnoreCase
 310                     (Security.getProperty("policy.expandProperties"));
 311                 allowSystemProperties = "true".equalsIgnoreCase
 312                     (Security.getProperty("policy.allowSystemProperty"));
 313                 notUtf8 = "false".equalsIgnoreCase
 314                     (System.getProperty("sun.security.policy.utf8"));
 315                 return System.getProperty("sun.security.policy.numcaches");
 316             }});
 317 
 318         int numCaches;
 319         if (numCacheStr != null) {
 320             try {
 321                 numCaches = Integer.parseInt(numCacheStr);
 322             } catch (NumberFormatException e) {
 323                 numCaches = DEFAULT_CACHE_SIZE;
 324             }
 325         } else {
 326             numCaches = DEFAULT_CACHE_SIZE;
 327         }
 328         // System.out.println("number caches=" + numCaches);
 329         PolicyInfo newInfo = new PolicyInfo(numCaches);
 330         initPolicyFile(newInfo, url);
 331         policyInfo = newInfo;
 332     }
 333 
 334     private void initPolicyFile(final PolicyInfo newInfo, final URL url) {
 335 
 336         // always load default.policy
 337         AccessController.doPrivileged(new PrivilegedAction<>() {
 338             @Override
 339             public Void run() {
 340                 initDefaultPolicy(newInfo);
 341                 return null;
 342             }
 343         });
 344 
 345         if (url != null) {
 346 
 347             /**
 348              * If the caller specified a URL via Policy.getInstance,




 283         init((URL)null);
 284     }
 285 
 286     /**
 287      * Initializes the Policy object and reads the default policy
 288      * from the specified URL only.
 289      */
 290     public PolicyFile(URL url) {
 291         this.url = url;
 292         init(url);
 293     }
 294 
 295     /**
 296      * Initializes the Policy object and reads the default policy
 297      * configuration file(s) into the Policy object.
 298      *
 299      * See the class description for details on the algorithm used to
 300      * initialize the Policy object.
 301      */
 302     private void init(URL url) {
 303         // Properties are set once for each init(); ignore changes
 304         // between diff invocations of initPolicyFile(policy, url, info).
 305         String numCacheStr =
 306           AccessController.doPrivileged(new PrivilegedAction<>() {
 307             @Override
 308             public String run() {
 309                 expandProperties = "true".equalsIgnoreCase
 310                     (Security.getProperty("policy.expandProperties"));
 311                 allowSystemProperties = "true".equalsIgnoreCase
 312                     (Security.getProperty("policy.allowSystemProperty"));
 313                 notUtf8 = "false".equalsIgnoreCase
 314                     (System.getProperty("sun.security.policy.utf8"));
 315                 return System.getProperty("sun.security.policy.numcaches");
 316             }});
 317 
 318         int numCaches;
 319         if (numCacheStr != null) {
 320             try {
 321                 numCaches = Integer.parseInt(numCacheStr);
 322             } catch (NumberFormatException e) {
 323                 numCaches = DEFAULT_CACHE_SIZE;
 324             }
 325         } else {
 326             numCaches = DEFAULT_CACHE_SIZE;
 327         }

 328         PolicyInfo newInfo = new PolicyInfo(numCaches);
 329         initPolicyFile(newInfo, url);
 330         policyInfo = newInfo;
 331     }
 332 
 333     private void initPolicyFile(final PolicyInfo newInfo, final URL url) {
 334 
 335         // always load default.policy
 336         AccessController.doPrivileged(new PrivilegedAction<>() {
 337             @Override
 338             public Void run() {
 339                 initDefaultPolicy(newInfo);
 340                 return null;
 341             }
 342         });
 343 
 344         if (url != null) {
 345 
 346             /**
 347              * If the caller specified a URL via Policy.getInstance,


< prev index next >