jdk/src/share/classes/java/security/AccessController.java
changeset 14213 91ba926457c6
parent 14208 fd8e875982e9
child 16906 44dfee24cb71
equal deleted inserted replaced
14212:faa4afc89a09 14213:91ba926457c6
   288      *
   288      *
   289      * @since 1.6
   289      * @since 1.6
   290      */
   290      */
   291     public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
   291     public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
   292 
   292 
   293         DomainCombiner dc = null;
       
   294         AccessControlContext acc = getStackAccessControlContext();
   293         AccessControlContext acc = getStackAccessControlContext();
   295         if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
   294         if (acc == null) {
   296             return AccessController.doPrivileged(action, acc);
   295             return AccessController.doPrivileged(action);
   297         }
   296         }
       
   297         DomainCombiner dc = acc.getAssignedCombiner();
   298         return AccessController.doPrivileged(action, preserveCombiner(dc));
   298         return AccessController.doPrivileged(action, preserveCombiner(dc));
   299     }
   299     }
   300 
   300 
   301 
   301 
   302     /**
   302     /**
   384      * @since 1.6
   384      * @since 1.6
   385      */
   385      */
   386     public static <T> T doPrivilegedWithCombiner
   386     public static <T> T doPrivilegedWithCombiner
   387         (PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
   387         (PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
   388 
   388 
   389         DomainCombiner dc = null;
       
   390         AccessControlContext acc = getStackAccessControlContext();
   389         AccessControlContext acc = getStackAccessControlContext();
   391         if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
   390         if (acc == null) {
   392             return AccessController.doPrivileged(action, acc);
   391             return AccessController.doPrivileged(action);
   393         }
   392         }
       
   393         DomainCombiner dc = acc.getAssignedCombiner();
   394         return AccessController.doPrivileged(action, preserveCombiner(dc));
   394         return AccessController.doPrivileged(action, preserveCombiner(dc));
   395     }
   395     }
   396 
   396 
   397     /**
   397     /**
   398      * preserve the combiner across the doPrivileged call
   398      * preserve the combiner across the doPrivileged call
   415         });
   415         });
   416 
   416 
   417         // perform 'combine' on the caller of doPrivileged,
   417         // perform 'combine' on the caller of doPrivileged,
   418         // even if the caller is from the bootclasspath
   418         // even if the caller is from the bootclasspath
   419         ProtectionDomain[] pds = new ProtectionDomain[] {callerPd};
   419         ProtectionDomain[] pds = new ProtectionDomain[] {callerPd};
   420         return new AccessControlContext(combiner.combine(pds, null), combiner);
   420         if (combiner == null) {
       
   421             return new AccessControlContext(pds);
       
   422         } else {
       
   423             return new AccessControlContext(combiner.combine(pds, null),
       
   424                                             combiner);
       
   425         }
   421     }
   426     }
   422 
   427 
   423 
   428 
   424     /**
   429     /**
   425      * Performs the specified <code>PrivilegedExceptionAction</code> with
   430      * Performs the specified <code>PrivilegedExceptionAction</code> with