< prev index next >

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

Print this page




 595             return getInnocuousAcc();
 596         } else {
 597             return new AccessControlContext(callerPD, combiner, parent,
 598                                             context, perms);
 599         }
 600     }
 601 
 602     private static class AccHolder {
 603         // An AccessControlContext with no granted permissions.
 604         // Only initialized on demand when getInnocuousAcc() is called.
 605         static final AccessControlContext innocuousAcc =
 606             new AccessControlContext(new ProtectionDomain[] {
 607                                      new ProtectionDomain(null, null) });
 608     }
 609     private static AccessControlContext getInnocuousAcc() {
 610         return AccHolder.innocuousAcc;
 611     }
 612 
 613     private static ProtectionDomain getCallerPD(final Class <?> caller) {
 614         ProtectionDomain callerPd = doPrivileged
 615             (new PrivilegedAction<ProtectionDomain>() {
 616             public ProtectionDomain run() {
 617                 return caller.getProtectionDomain();
 618             }
 619         });
 620 
 621         return callerPd;
 622     }
 623 
 624     /**
 625      * Performs the specified {@code PrivilegedExceptionAction} with
 626      * privileges enabled and restricted by the specified
 627      * {@code AccessControlContext}.  The action is performed with the
 628      * intersection of the permissions possessed by the caller's
 629      * protection domain, and those possessed by the domains represented by the
 630      * specified {@code AccessControlContext}.
 631      * <p>
 632      * If the action's {@code run} method throws an <i>unchecked</i>
 633      * exception, it will propagate through this method.
 634      * <p>
 635      * If a security manager is installed and the specified




 595             return getInnocuousAcc();
 596         } else {
 597             return new AccessControlContext(callerPD, combiner, parent,
 598                                             context, perms);
 599         }
 600     }
 601 
 602     private static class AccHolder {
 603         // An AccessControlContext with no granted permissions.
 604         // Only initialized on demand when getInnocuousAcc() is called.
 605         static final AccessControlContext innocuousAcc =
 606             new AccessControlContext(new ProtectionDomain[] {
 607                                      new ProtectionDomain(null, null) });
 608     }
 609     private static AccessControlContext getInnocuousAcc() {
 610         return AccHolder.innocuousAcc;
 611     }
 612 
 613     private static ProtectionDomain getCallerPD(final Class <?> caller) {
 614         ProtectionDomain callerPd = doPrivileged
 615             (new PrivilegedAction<>() {
 616             public ProtectionDomain run() {
 617                 return caller.getProtectionDomain();
 618             }
 619         });
 620 
 621         return callerPd;
 622     }
 623 
 624     /**
 625      * Performs the specified {@code PrivilegedExceptionAction} with
 626      * privileges enabled and restricted by the specified
 627      * {@code AccessControlContext}.  The action is performed with the
 628      * intersection of the permissions possessed by the caller's
 629      * protection domain, and those possessed by the domains represented by the
 630      * specified {@code AccessControlContext}.
 631      * <p>
 632      * If the action's {@code run} method throws an <i>unchecked</i>
 633      * exception, it will propagate through this method.
 634      * <p>
 635      * If a security manager is installed and the specified


< prev index next >