< prev index next >

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

Print this page
rev 15908 : 8165271: Fix use of reflection to gain access to private fields
Reviewed-by:


  72                 final AccessControlContext stack,
  73                 final AccessControlContext context) {
  74             if (action == null) {
  75                 throw new NullPointerException();
  76             }
  77 
  78             return AccessController.doPrivileged(
  79                 action,
  80                 getCombinedACC(context, stack)
  81             );
  82         }
  83 
  84         @Override
  85         public <T> T doIntersectionPrivilege(
  86                 PrivilegedAction<T> action,
  87                 AccessControlContext context) {
  88             return doIntersectionPrivilege(action,
  89                 AccessController.getContext(), context);
  90         }
  91 





  92         private static AccessControlContext getCombinedACC(
  93             AccessControlContext context, AccessControlContext stack) {
  94             AccessControlContext acc =
  95                 new AccessControlContext(context, stack.getCombiner(), true);
  96 
  97             return new AccessControlContext(stack.getContext(), acc).optimize();
  98         }
  99     }
 100 
 101     static {
 102         // setup SharedSecrets to allow access to doIntersectionPrivilege
 103         // methods and ProtectionDomain cache
 104         SharedSecrets.setJavaSecurityAccess(new JavaSecurityAccessImpl());
 105         SharedSecrets.setJavaSecurityProtectionDomainAccess(
 106             new JavaSecurityProtectionDomainAccess() {
 107                 @Override
 108                 public ProtectionDomainCache getProtectionDomainCache() {
 109                     return new PDCache();
 110                 }
 111             });




  72                 final AccessControlContext stack,
  73                 final AccessControlContext context) {
  74             if (action == null) {
  75                 throw new NullPointerException();
  76             }
  77 
  78             return AccessController.doPrivileged(
  79                 action,
  80                 getCombinedACC(context, stack)
  81             );
  82         }
  83 
  84         @Override
  85         public <T> T doIntersectionPrivilege(
  86                 PrivilegedAction<T> action,
  87                 AccessControlContext context) {
  88             return doIntersectionPrivilege(action,
  89                 AccessController.getContext(), context);
  90         }
  91 
  92         @Override
  93         public ProtectionDomain[] getProtectDomains(AccessControlContext context) {
  94             return context.getContext();
  95         }
  96 
  97         private static AccessControlContext getCombinedACC(
  98             AccessControlContext context, AccessControlContext stack) {
  99             AccessControlContext acc =
 100                 new AccessControlContext(context, stack.getCombiner(), true);
 101 
 102             return new AccessControlContext(stack.getContext(), acc).optimize();
 103         }
 104     }
 105 
 106     static {
 107         // setup SharedSecrets to allow access to doIntersectionPrivilege
 108         // methods and ProtectionDomain cache
 109         SharedSecrets.setJavaSecurityAccess(new JavaSecurityAccessImpl());
 110         SharedSecrets.setJavaSecurityProtectionDomainAccess(
 111             new JavaSecurityProtectionDomainAccess() {
 112                 @Override
 113                 public ProtectionDomainCache getProtectionDomainCache() {
 114                     return new PDCache();
 115                 }
 116             });


< prev index next >