[jboss-dev-forums] [Design of AOP on JBoss (Aspects/JBoss)] - Re: Security errors with maven tests

adrian@jboss.org do-not-reply at jboss.com
Tue Dec 4 12:47:24 EST 2007


This is the security policy from jboss-test.
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/test/trunk/src/main/java/org/jboss/test/security/TestsPolicyPlugin.java?revision=62656&view=markup

Specifically:

  |          // Is this a test location?
  |          File file = new File(url.toString());
  |          String name = file.getName();
  |          if (name.indexOf("tests") != -1 || name.indexOf("test-classes") != -1 || name.indexOf("-test.jar") != -1)
  |          {
  | 

Your AOPTestDelegate class will be in target/test-classes so it gets no permissions.
If you can't figure out how to do it properly, you can workaround the problem with a hack.

You can't suspend the security manager, but there is somebody who can. ;-)


  | import org.jboss.test.AbstractTestCaseWithSetup;
  | 
  | // turn off security
  | SecurityManager sm = AbstractTestCaseWithSetup.suspendSecurity();
  | try
  | {
  |     // do bad things here
  | }
  | finally
  | {
  |    // resume security
  |    AbstractTestCaseWithSetup.resumeSecurity(sm);
  | }
  | 

This is only intended for test infrastructure.
The point of testing with a security manager enabled is to determine which parts
of the code need privileged blocks to work correctly.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110281#4110281

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110281



More information about the jboss-dev-forums mailing list