8036841: Reuse no-perms AccessControlContext object when performing isAuthorized check
Reviewed-by: wetmore
This commit is contained in:
parent
1eef4367df
commit
605924f8ef
@ -592,14 +592,24 @@ public final class AccessController {
|
||||
System.getSecurityManager() != null &&
|
||||
!callerPD.impliesCreateAccessControlContext())
|
||||
{
|
||||
ProtectionDomain nullPD = new ProtectionDomain(null, null);
|
||||
return new AccessControlContext(new ProtectionDomain[] { nullPD });
|
||||
return getInnocuousAcc();
|
||||
} else {
|
||||
return new AccessControlContext(callerPD, combiner, parent,
|
||||
context, perms);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AccHolder {
|
||||
// An AccessControlContext with no granted permissions.
|
||||
// Only initialized on demand when getInnocuousAcc() is called.
|
||||
static final AccessControlContext innocuousAcc =
|
||||
new AccessControlContext(new ProtectionDomain[] {
|
||||
new ProtectionDomain(null, null) });
|
||||
}
|
||||
private static AccessControlContext getInnocuousAcc() {
|
||||
return AccHolder.innocuousAcc;
|
||||
}
|
||||
|
||||
private static ProtectionDomain getCallerPD(final Class <?> caller) {
|
||||
ProtectionDomain callerPd = doPrivileged
|
||||
(new PrivilegedAction<ProtectionDomain>() {
|
||||
|
Loading…
Reference in New Issue
Block a user