use of java.util.PropertyPermission 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.util.PropertyPermission in project sulky by huxi.
the class TestSecurityManager method checkPermission.
@Override
public void checkPermission(Permission perm) {
if (perm instanceof PropertyPermission) {
PropertyPermission p = (PropertyPermission) perm;
String permissionName = p.getName();
if (deniedProperties != null && deniedProperties.contains(permissionName)) {
throw new AccessControlException(ACCESS_DENIED_BASE + perm, perm);
}
String actions = p.getActions();
if (PROPERTY_READ_ACTION.equals(actions) && unreadableProperties != null && unreadableProperties.contains(permissionName)) {
throw new AccessControlException(ACCESS_DENIED_BASE + perm, perm);
}
if (PROPERTY_WRITE_ACTION.equals(actions) && unwritableProperties != null && unwritableProperties.contains(permissionName)) {
throw new AccessControlException(ACCESS_DENIED_BASE + perm, perm);
}
if (PROPERTY_RW_ACTION.equals(actions) && ((unreadableProperties != null && unreadableProperties.contains(permissionName)) || (unwritableProperties != null && unwritableProperties.contains(permissionName)))) {
throw new AccessControlException(ACCESS_DENIED_BASE + perm, perm);
}
}
}
use of java.util.PropertyPermission in project eap-additional-testsuite by jboss-set.
the class AuthenticationTestCase method deployment.
/*I469
* Authentication Scenarios
*
* Client -> Bean
* Client -> Bean -> Bean
* Client -> Bean (Re-auth) -> Bean
* Client -> Servlet -> Bean
* Client -> Servlet (Re-auth) -> Bean
* Client -> Servlet -> Bean -> Bean
* Client -> Servlet -> Bean (Re Auth) -> Bean
*/
@Deployment
public static Archive<?> deployment() {
final Package currentPackage = AuthenticationTestCase.class.getPackage();
// using JavaArchive doesn't work, because of a bug in Arquillian, it only deploys wars properly
final WebArchive war = ShrinkWrap.create(WebArchive.class, "ejb3security.war").addPackage(WhoAmIBean.class.getPackage()).addPackage(EntryBean.class.getPackage()).addClass(WhoAmI.class).addClass(Util.class).addClass(Entry.class).addClasses(WhoAmIServlet.class, AuthenticationTestCase.class).addClasses(AbstractSecurityDomainSetup.class, EjbElytronDomainSetup.class, ElytronDomainSetup.class).addClass(TestSuiteEnvironment.class).addAsResource(currentPackage, "users.properties", "users.properties").addAsResource(currentPackage, "roles.properties", "roles.properties").addAsWebInfResource(currentPackage, "web.xml", "web.xml").addAsWebInfResource(currentPackage, "jboss-web.xml", "jboss-web.xml").addAsWebInfResource(currentPackage, "jboss-ejb3.xml", "jboss-ejb3.xml").addAsManifestResource(new StringAsset("Manifest-Version: 1.0\nDependencies: org.jboss.as.controller-client,org.jboss.dmr\n"), "MANIFEST.MF").addAsManifestResource(createPermissionsXmlAsset(// login module needs to modify principal to commit logging in
new AuthPermission("modifyPrincipals"), // AuthenticationTestCase#testAuthenticatedCall calls org.jboss.security.client.JBossSecurityClient#performSimpleLogin
new RuntimePermission("org.jboss.security.getSecurityContext"), new RuntimePermission("org.jboss.security.SecurityContextFactory.createSecurityContext"), new RuntimePermission("org.jboss.security.SecurityContextFactory.createUtil"), new RuntimePermission("org.jboss.security.plugins.JBossSecurityContext.setSubjectInfo"), new RuntimePermission("org.jboss.security.setSecurityContext"), // AuthenticationTestCase#execute calls ExecutorService#shutdownNow
new RuntimePermission("modifyThread"), // AuthenticationTestCase#execute calls sun.net.www.http.HttpClient#openServer under the hood
new SocketPermission(SERVER_HOST_PORT, "connect,resolve"), // TestSuiteEnvironment reads system properties
new PropertyPermission("management.address", "read"), new PropertyPermission("node0", "read"), new PropertyPermission("jboss.http.port", "read")), "permissions.xml");
war.addPackage(CommonCriteria.class.getPackage());
return war;
}
use of java.util.PropertyPermission in project openj9 by eclipse.
the class Test_AccessController method test_doPrivileged_createAccessControlContext.
/**
* java.security.AccessController#doPrivileged(java.security.PrivilegedAction, AccessControlContext)
*/
@Test
public void test_doPrivileged_createAccessControlContext() {
/*
* Classes loaded by this Classloader withPermCL have the Permission JAVA_HOME_READ & CREATE_ACC
*/
ClassLoader withPermCL = new TestURLClassLoader(new URL[] { this.getClass().getProtectionDomain().getCodeSource().getLocation() }, null) {
public PermissionCollection getPermissions(CodeSource cs) {
PermissionCollection pc = super.getPermissions(cs);
pc.add(new PropertyPermission("java.home", "read"));
pc.add(new SecurityPermission("createAccessControlContext"));
return pc;
}
};
try {
Class<?> mwp = Class.forName("org.openj9.test.java.security.Test_AccessController$MainWithPerm", true, withPermCL);
Object mwpObj = mwp.newInstance();
Method m = mwp.getDeclaredMethod("testCreateACC");
m.setAccessible(true);
m.invoke(mwpObj);
} catch (Exception e) {
e.printStackTrace();
Assert.fail("FAIL: TEST FAILED, probably setup issue.");
}
}
use of java.util.PropertyPermission in project openj9 by eclipse.
the class Test_AccessController method test_doPrivilegedWithCombiner4.
/**
* java.security.AccessController#doPrivilegedWithCombiner(java.security.PrivilegedAction)
*/
@Test
public void test_doPrivilegedWithCombiner4() {
ClassLoader cl = new TestURLClassLoader(new URL[] { getClass().getProtectionDomain().getCodeSource().getLocation() }, null) {
public PermissionCollection getPermissions(CodeSource cs) {
PermissionCollection pc = super.getPermissions(cs);
pc.add(new PropertyPermission(PROP_USER, "read"));
return pc;
}
};
try {
Class<?> c = Class.forName("org.openj9.test.java.security.Test_AccessController$TestClass", true, cl);
Object o = c.newInstance();
Method m = c.getMethod("test", AccessControlContext.class);
Boolean result = (Boolean) (m.invoke(o, AccessController.getContext()));
if (!result) {
Assert.fail("test_doPrivilegedWithCombiner4 failed!");
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Unexpected exception thrown: " + e);
}
}
Aggregations