mx4j/src/test/test/javax/management SecurityManagerTestCase.java,1.3,1.4
Jeremy Boynes <[email protected]> Tue, 08 Feb 2005 07:12:26 +0000
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/test/test/javax/management
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27674/src/test/test/javax/management
Modified Files:
SecurityManagerTestCase.java
Log Message:
[ 1116245 ] MBeanPermission implies is incorrect with wildcards
[ 1116450 ] spec ambiguity? security check for getDomains()
Fix both with testcases
Index: SecurityManagerTestCase.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/test/test/javax/management/SecurityManagerTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SecurityManagerTestCase.java 13 Nov 2004 16:38:31 -0000 1.3
--- SecurityManagerTestCase.java 8 Feb 2005 07:12:23 -0000 1.4
***************
*** 12,27 ****
import java.util.Iterator;
import java.util.Set;
! import javax.management.Attribute;
! import javax.management.AttributeList;
! import javax.management.MBeanInfo;
! import javax.management.MBeanPermission;
! import javax.management.MBeanServerConnection;
! import javax.management.MBeanTrustPermission;
! import javax.management.Notification;
! import javax.management.NotificationListener;
! import javax.management.ObjectInstance;
! import javax.management.ObjectName;
! import javax.management.Query;
! import javax.management.QueryExp;
import test.MX4JTestCase;
--- 12,17 ----
import java.util.Iterator;
import java.util.Set;
! import java.io.IOException;
! import javax.management.*;
import test.MX4JTestCase;
***************
*** 265,272 ****
protected void testGetDomains(MBeanServerConnection server) throws Exception
{
String[] results = server.getDomains();
assertNotNull(results);
assertEquals(results.length, 1);
! assertEquals(results[0], "JMImplementation");
}
--- 255,279 ----
protected void testGetDomains(MBeanServerConnection server) throws Exception
{
+ try
+ {
+ server.getDomains();
+ fail();
+ }
+ catch (SecurityException e)
+ {
+ // OK
+ }
+ ObjectName name = new ObjectName("test:x=x");
+ addPermission(new MBeanPermission(Simple.class.getName(), null, name, "instantiate"));
+ addPermission(new MBeanPermission(Simple.class.getName(), null, name, "registerMBean"));
+ addPermission(new MBeanTrustPermission("register"));
+ server.createMBean(Simple.class.getName(), name);
+
+ addPermission(new MBeanPermission(null, null, name, "getDomains"));
+
String[] results = server.getDomains();
assertNotNull(results);
assertEquals(results.length, 1);
! assertEquals(results[0], "test");
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click