Open glassfishrobot opened 7 years ago
@arjantijms Commented
I don't fully know what the official TCK rules are, but indeed, to run with a Java SE SecurityManager the necessary extra permissions should be granted. I think we briefly discussed this on one of the last calls when the topic was about these permissions; working with the JASPIC factory requires certain permissions. I think they're all java.security.SecurityPermission.SecurityPermission(String)
with String
being the name of a more specific permission (as defined by public fields of javax.security.auth.message.config.AuthConfigFactory
).
Obtaining several JACC contexts also requires a permission, namely java.security.SecurityPermission.SecurityPermission(String)
with String
being "setPolicy" here. (the name is a wee bit peculiar, as no policy is actually being set, but instead a handler is being obtained).
@wmhopkins Commented
The issue isn't so much a question of permissions as a question of coding Soteria properly -- the Glassfish runtime jars should normally have AllPermission
.
I've updated Jaspic.java and JACC.java so that invocations on the AuthConfigFactory
and PolicyContext.getContext()
, respectively, are done inside PrivilegedAction
blocks. As such, the Soteria runtime will need the specified permissions (and should have them via the GF grants), but applications will not require special permissions to call into Soteria.
@wxwesther -- Hopefully the changes I'm about to commit will address these issues -- and maybe even #174, if we're lucky. Let me know if the exceptions go away, or if others appear.
@wmhopkins Commented
Re-opening to allow for further investigation -- there are several places where Soteria calls System.getProperty()
, which will throw a SecurityException if permission not granted. These may need to execute in a privileged block, or may not, if the code can't be reached from an application context.
Either way, since we're not getting exceptions for those under test, I'm deferring for now. They can be fixed in the next release.
As reported by @wxwesther via email:
In order to test
IdentityStorePermission
related requirements, I enabledSecurityManager
in Glassfish. AndIdentityStorePermission
works as expected.But unfortunately, there are several HAM and
SecurityContext
test cases failed (while all of them are PASSED before enablingSecurityManager
).Here I have 2 questions:
SecurityManager
enabled?SecurityManager
disabled after adding add permissions.xml in those test cases? If the latter, what is the class-name and method name in permission should I add in permissions.xml?If no, I will try to find a way to enable/disable
SecurityManager
only forIdentityStorePermission
related test cases.java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.security.AccessControlException: access denied ("java.security.SecurityPermission" "getProperty.authconfigprovider.factory")
[2017-08-15T19:24:43.668-0700] [glassfish 5.0] [FINE] [] [javax.enterprise.system.core.security] [tid: _ThreadID=28 _ThreadName=http-listener-1(2)] [timeMillis: 1502850283668] [levelValue: 500] [CLASSNAME: com.sun.enterprise.security.provider.BasePolicyWrapper] [METHODNAME: doImplies] [[
JACC Policy Provider, failed Permission Check at :
java.lang.Exception
[2017-08-15T19:24:43.673-0700] [glassfish 5.0] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=28 _ThreadName=http-listener-1(2)] [timeMillis: 1502850283673] [levelValue: 900] [[
StandardWrapperValve[com.sun.ts.tests.securityapi.securitycontext.callerdata.Servlet]: Servlet.service() for servlet com.sun.ts.tests.securityapi.securitycontext.callerdata.Servlet threw exception
java.security.AccessControlException: access denied ("java.security.SecurityPermission" "setPolicy")