Search in sources :

Example 51 with PropertyPermission

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;
    }
}
Also used : Policy(java.security.Policy) PermissionCollection(java.security.PermissionCollection) PropertyPermission(java.util.PropertyPermission) MBeanPermission(javax.management.MBeanPermission) SocketPermission(java.net.SocketPermission) ManagementPermission(java.lang.management.ManagementPermission) SSLPermission(javax.net.ssl.SSLPermission) CodeSource(java.security.CodeSource) FilePermission(java.io.FilePermission) MBeanServerPermission(javax.management.MBeanServerPermission) MBeanTrustPermission(javax.management.MBeanTrustPermission) Permissions(java.security.Permissions) ReflectPermission(java.lang.reflect.ReflectPermission) SerializablePermission(java.io.SerializablePermission) SecurityPermission(java.security.SecurityPermission)

Example 52 with PropertyPermission

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);
        }
    }
}
Also used : PropertyPermission(java.util.PropertyPermission) AccessControlException(java.security.AccessControlException)

Example 53 with PropertyPermission

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;
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) PropertyPermission(java.util.PropertyPermission) AuthPermission(javax.security.auth.AuthPermission) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) SocketPermission(java.net.SocketPermission) Util(org.jboss.as.test.shared.integration.ejb.security.Util) WhoAmIBean(org.jboss.additional.testsuite.jdkall.present.elytron.ejb.base.WhoAmIBean) TestSuiteEnvironment(org.jboss.as.test.shared.TestSuiteEnvironment) CommonCriteria(org.jboss.as.test.categories.CommonCriteria) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 54 with PropertyPermission

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.");
    }
}
Also used : PermissionCollection(java.security.PermissionCollection) PropertyPermission(java.util.PropertyPermission) BeforeMethod(org.testng.annotations.BeforeMethod) AfterMethod(org.testng.annotations.AfterMethod) Method(java.lang.reflect.Method) CodeSource(java.security.CodeSource) SecurityPermission(java.security.SecurityPermission) PrivilegedActionException(java.security.PrivilegedActionException) AccessControlException(java.security.AccessControlException) Test(org.testng.annotations.Test)

Example 55 with PropertyPermission

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);
    }
}
Also used : PermissionCollection(java.security.PermissionCollection) PropertyPermission(java.util.PropertyPermission) BeforeMethod(org.testng.annotations.BeforeMethod) AfterMethod(org.testng.annotations.AfterMethod) Method(java.lang.reflect.Method) CodeSource(java.security.CodeSource) PrivilegedActionException(java.security.PrivilegedActionException) AccessControlException(java.security.AccessControlException) Test(org.testng.annotations.Test)

Aggregations

PropertyPermission (java.util.PropertyPermission)99 Deployment (org.jboss.arquillian.container.test.api.Deployment)49 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)46 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)35 FilePermission (java.io.FilePermission)23 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)18 SocketPermission (java.net.SocketPermission)13 JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)13 Permission (java.security.Permission)10 AccessControlException (java.security.AccessControlException)8 RemotingPermission (org.jboss.remoting3.security.RemotingPermission)8 PermissionCollection (java.security.PermissionCollection)7 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)7 ReflectPermission (java.lang.reflect.ReflectPermission)6 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)6 Permissions (java.security.Permissions)5 SecurityPermission (java.security.SecurityPermission)5 AccessControlContext (java.security.AccessControlContext)4 TimeoutUtil (org.jboss.as.test.shared.TimeoutUtil)4 Method (java.lang.reflect.Method)3