提交 04b3472f 编写于 作者: I igerasim

8138811: Construction of static protection domains

Reviewed-by: valeriep
上级 2f541300
...@@ -475,6 +475,11 @@ public class ProtectionDomain { ...@@ -475,6 +475,11 @@ public class ProtectionDomain {
} }
}; };
} }
@Override
public boolean getStaticPermissionsField(ProtectionDomain pd) {
return pd.staticPermissions;
}
}); });
} }
} }
...@@ -37,6 +37,8 @@ import java.security.Security; ...@@ -37,6 +37,8 @@ import java.security.Security;
import java.util.Set; import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import sun.misc.SharedSecrets;
import sun.misc.JavaSecurityProtectionDomainAccess;
/** /**
* A {@code SubjectDomainCombiner} updates ProtectionDomains * A {@code SubjectDomainCombiner} updates ProtectionDomains
...@@ -65,6 +67,9 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { ...@@ -65,6 +67,9 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner {
private static final boolean allowCaching = private static final boolean allowCaching =
(useJavaxPolicy && cachePolicy()); (useJavaxPolicy && cachePolicy());
private static final JavaSecurityProtectionDomainAccess pdAccess =
SharedSecrets.getJavaSecurityProtectionDomainAccess();
/** /**
* Associate the provided {@code Subject} with this * Associate the provided {@code Subject} with this
* {@code SubjectDomainCombiner}. * {@code SubjectDomainCombiner}.
...@@ -239,10 +244,15 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { ...@@ -239,10 +244,15 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner {
subjectPd = cachedPDs.getValue(pd); subjectPd = cachedPDs.getValue(pd);
if (subjectPd == null) { if (subjectPd == null) {
subjectPd = new ProtectionDomain(pd.getCodeSource(), if (pdAccess.getStaticPermissionsField(pd)) {
// Need to keep static ProtectionDomain objects static
subjectPd = pd;
} else {
subjectPd = new ProtectionDomain(pd.getCodeSource(),
pd.getPermissions(), pd.getPermissions(),
pd.getClassLoader(), pd.getClassLoader(),
principals); principals);
}
cachedPDs.putValue(pd, subjectPd); cachedPDs.putValue(pd, subjectPd);
} else { } else {
allNew = false; allNew = false;
......
...@@ -36,4 +36,9 @@ public interface JavaSecurityProtectionDomainAccess { ...@@ -36,4 +36,9 @@ public interface JavaSecurityProtectionDomainAccess {
* Returns the ProtectionDomainCache. * Returns the ProtectionDomainCache.
*/ */
ProtectionDomainCache getProtectionDomainCache(); ProtectionDomainCache getProtectionDomainCache();
/**
* Returns the staticPermissions field of the specified object
*/
boolean getStaticPermissionsField(ProtectionDomain pd);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册