Kabir Khan [
http://community.jboss.org/people/kabir.khan%40jboss.com] created the
discussion
"Testing jboss-reflect with a SecurityManager enabled"
To view the discussion, visit:
http://community.jboss.org/message/534031#534031
--------------------------------------------------------------
I am enabling security for jboss-reflect and going through and adding privileged blocks
where needed. Currently I am using this test policy plugin
public class ContainerTestPolicyPlugin extends TestsPolicyPlugin
{
public ContainerTestPolicyPlugin(Class<?> clazz)
{
super(clazz);
}
public PermissionCollection getPermissions(CodeSource codesource)
{
PermissionCollection collection = super.getPermissions(codesource);
collection.add(new RuntimePermission("accessDeclaredMembers"));
collection.add(new RuntimePermission("getClassloader"));
collection.add(new
RuntimePermission("accessClassInPackage.sun.reflect"));
return collection;
}
}
Once I'm done I'll see about adding property files for individual tests, or I
might just leave this in?
Anyway, the problem I am having is for the following tests:
* BeanInfoUtilTestCase - which seems to assume that it will ALWAYS be able to set/get
fields whether they are public or private.
* Field-/MethodAccessRestrictionTestCase - which seems to assume that it can set/get
private fields when there is no security manager, but not when there is one.
From what I can work out BeanInfoUtilTestCase was not written with a
security manager enabled, so I will modify BeanInfoUtilTestCase to override the delegate
so it will never use a security manager no matter what ContainerTest.getDelegate() does.
The next problem is the Javassist version of the Field-/MethodAccessRestrictionTestCase.
These fail since the javassist generated accessors (from JBREFLECT-6) are able to access
private members, due to inheriting from sun.reflect.MagicAccessorImpl, so we don't get
the expected exceptions when calling private members with a security manager enabled. My
plan there is to modify JavassistFieldInfo and JavassistMethodInfo to throw an exception
if an attempt is made to access them if they are not public and there is a security
manager present.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/534031#534031]
Start a new discussion in JBoss Microcontainer Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]