use of javax.management.MBeanPermission in project wildfly by wildfly.
the class InfinispanResourceRefTestCase method deployment.
@Deployment
public static Archive<?> deployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class, "infinispan-resource-ref.war");
war.addClasses(InfinispanBean.class, InfinispanResourceRefTestCase.class);
war.addAsWebInfResource(getWebXml(), "web.xml");
war.setManifest(new StringAsset(Descriptors.create(ManifestDescriptor.class).attribute("Dependencies", "org.infinispan export").exportAsString()));
war.addAsManifestResource(createPermissionsXmlAsset(new MBeanPermission("-#-[-]", "queryNames"), new MBeanPermission("org.infinispan.*[jboss.infinispan:*,type=Cache]", "registerMBean"), new ReflectPermission("suppressAccessChecks"), new RuntimePermission("accessDeclaredMembers"), new RuntimePermission("getClassLoader")), "permissions.xml");
return war;
}
use of javax.management.MBeanPermission in project wildfly by wildfly.
the class ServiceMBeanSupportTestCase method geTestMBeanSar.
@Deployment(name = ServiceMBeanSupportTestCase.UNMANAGED_SAR_DEPLOYMENT_NAME, managed = false)
public static JavaArchive geTestMBeanSar() {
final JavaArchive sar = ShrinkWrap.create(JavaArchive.class, "service-mbean-support-test.sar");
sar.addClasses(TestServiceMBean.class, TestService.class);
sar.addAsManifestResource(ServiceMBeanSupportTestCase.class.getPackage(), "jboss-service.xml", "jboss-service.xml");
sar.addAsManifestResource(createPermissionsXmlAsset(new JndiPermission("global/env/foo/legacy", "bind,unbind"), new MBeanPermission(TestResultService.class.getPackage().getName() + ".*", "*")), "permissions.xml");
return sar;
}
use of javax.management.MBeanPermission in project jdk8u_jdk by JetBrains.
the class DcmdMBeanPermissionsTest method main.
public static void main(final String[] args) {
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName on = null;
try {
on = new ObjectName(HOTSPOT_DIAGNOSTIC_MXBEAN_NAME);
} catch (MalformedObjectNameException ex) {
ex.printStackTrace();
throw new RuntimeException("TEST FAILED");
}
MBeanInfo info = null;
try {
info = mbs.getMBeanInfo(on);
} catch (InstanceNotFoundException | IntrospectionException | ReflectionException ex) {
ex.printStackTrace();
throw new RuntimeException("TEST FAILED");
}
CustomSecurityManager sm = new CustomSecurityManager();
System.setSecurityManager(sm);
// Set of permission required to run the test cleanly
// Some permissions are required by the MBeanServer and other
// platform services (RuntimePermission("createClassLoader"),
// ReflectPermission("suppressAccessChecks"),
// java.util.logging.LoggingPermission("control"),
// RuntimePermission("exitVM.97")).
// Other permissions are required by commands being invoked
// in the test (for instance, RuntimePermission("modifyThreadGroup")
// and RuntimePermission("modifyThread") are checked when
// runFinalization() is invoked by the gcRunFinalization command.
sm.grantPermission(new RuntimePermission("createClassLoader"));
sm.grantPermission(new ReflectPermission("suppressAccessChecks"));
sm.grantPermission(new java.util.logging.LoggingPermission("control", ""));
sm.grantPermission(new java.lang.RuntimePermission("exitVM.97"));
sm.grantPermission(new java.lang.RuntimePermission("modifyThreadGroup"));
sm.grantPermission(new java.lang.RuntimePermission("modifyThread"));
for (MBeanOperationInfo opInfo : info.getOperations()) {
Permission opPermission = new MBeanPermission(info.getClassName(), opInfo.getName(), on, "invoke");
sm.grantPermission(opPermission);
testOperation(mbs, sm, on, opInfo);
sm.denyPermission(opPermission);
}
System.out.println("TEST PASSED");
}
use of javax.management.MBeanPermission in project jdk8u_jdk by JetBrains.
the class MBeanPermissionTest method main.
public static void main(String[] args) {
int error = 0;
System.out.println(">>> MBeanPermissionTest");
try {
System.out.println("Create MBeanPermission(null,\"\")");
MBeanPermission mbp = new MBeanPermission(null, "");
System.out.println("Didn't get expected IllegalArgumentException");
error++;
} catch (IllegalArgumentException e) {
System.out.println("Got expected exception = " + e);
} catch (Exception e) {
System.out.println("Got unexpected exception = " + e);
error++;
}
try {
System.out.println("Create MBeanPermission(\"\", null)");
MBeanPermission mbp = new MBeanPermission("", null);
System.out.println("Didn't get expected IllegalArgumentException");
error++;
} catch (IllegalArgumentException e) {
System.out.println("Got expected exception = " + e);
} catch (Exception e) {
System.out.println("Got unexpected exception = " + e);
error++;
}
if (error > 0) {
final String msg = "Test FAILED! Got " + error + " error(s)";
System.out.println(msg);
throw new IllegalArgumentException(msg);
} else {
System.out.println("Test PASSED!");
}
}
use of javax.management.MBeanPermission in project jdk8u_jdk by JetBrains.
the class ServerNotifForwarder method checkMBeanPermission.
static void checkMBeanPermission(final MBeanServer mbs, final ObjectName name, final String actions) throws InstanceNotFoundException, SecurityException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
AccessControlContext acc = AccessController.getContext();
ObjectInstance oi;
try {
oi = AccessController.doPrivileged(new PrivilegedExceptionAction<ObjectInstance>() {
public ObjectInstance run() throws InstanceNotFoundException {
return mbs.getObjectInstance(name);
}
});
} catch (PrivilegedActionException e) {
throw (InstanceNotFoundException) extractException(e);
}
String classname = oi.getClassName();
MBeanPermission perm = new MBeanPermission(classname, null, name, actions);
sm.checkPermission(perm, acc);
}
}
Aggregations