use of java.lang.management.ManagementPermission in project elasticsearch by elastic.
the class JvmInfo method jvmInfo.
public static JvmInfo jvmInfo() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new ManagementPermission("monitor"));
sm.checkPropertyAccess("*");
}
return INSTANCE;
}
use of java.lang.management.ManagementPermission in project ignite by apache.
the class SecuritySubjectPermissionsTest method beforeTestsStarted.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTestsStarted() throws Exception {
if (System.getSecurityManager() == null) {
Policy.setPolicy(new Policy() {
@Override
public PermissionCollection getPermissions(CodeSource cs) {
Permissions res = new Permissions();
res.add(new RuntimePermission("*"));
res.add(new MBeanServerPermission("*"));
res.add(new MBeanPermission("*", "*"));
res.add(new MBeanTrustPermission("*"));
res.add(new ReflectPermission("*"));
res.add(new SSLPermission("*"));
res.add(new ManagementPermission("monitor"));
res.add(new ManagementPermission("control"));
res.add(new SerializablePermission("*"));
res.add(new SecurityPermission("*"));
res.add(new SocketPermission("*", "connect,accept,listen,resolve"));
res.add(new FilePermission("<<ALL FILES>>", "read,write,delete,execute,readlink"));
res.add(new PropertyPermission("*", "read,write"));
res.add(new TestPermission("common"));
return res;
}
});
System.setSecurityManager(new SecurityManager());
setupSM = true;
}
}
use of java.lang.management.ManagementPermission in project openj9 by eclipse.
the class TestManagementPermission method testManagementPermissionStringString.
/*
* Class under test for void ManagementPermission(String, String)
*/
@Test
public final void testManagementPermissionStringString() {
// Normal cases.
ManagementPermission mp = new ManagementPermission("monitor", "");
AssertJUnit.assertNotNull(mp);
mp = new ManagementPermission("control", null);
AssertJUnit.assertNotNull(mp);
// Bad input - null name
try {
mp = new ManagementPermission(null, null);
Assert.fail("Should have thrown NPE for null name.");
} catch (Exception e) {
}
// Bad input - unwanted name
try {
mp = new ManagementPermission("Sunset", null);
Assert.fail("Should have thrown IllegalArgumentException for incorrect name.");
} catch (Exception e) {
}
// Bad input - correct name but in incorrect type
try {
mp = new ManagementPermission("Monitor", null);
Assert.fail("Should have thrown IllegalArgumentException for upper-case name.");
} catch (Exception e) {
}
// Bad input - action not one of "" or null
try {
mp = new ManagementPermission("monitor", "You broke my heart Fredo.");
Assert.fail("Should have thrown IllegalArgumentException for bad action.");
} catch (Exception e) {
}
}
use of java.lang.management.ManagementPermission in project openj9 by eclipse.
the class TestManagementPermission method testManagementPermissionString.
/*
* Class under test for void ManagementPermission(String)
*/
@Test
public final void testManagementPermissionString() {
// Normal cases.
ManagementPermission mp = new ManagementPermission("monitor");
AssertJUnit.assertNotNull(mp);
mp = new ManagementPermission("control");
AssertJUnit.assertNotNull(mp);
// Bad input - null name
try {
mp = new ManagementPermission(null);
Assert.fail("Should have thrown NPE for null name.");
} catch (Exception e) {
}
// Bad input - unwanted name
try {
mp = new ManagementPermission("Sunset");
Assert.fail("Should have thrown IllegalArgumentException for incorrect name.");
} catch (Exception e) {
}
// Bad input - correct name but in incorrect type
try {
mp = new ManagementPermission("Monitor");
Assert.fail("Should have thrown IllegalArgumentException for upper-case name.");
} catch (Exception e) {
}
}
Aggregations