Search in sources :

Example 11 with JndiPermission

use of org.wildfly.naming.java.permission.JndiPermission 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;
}
Also used : MBeanPermission(javax.management.MBeanPermission) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 12 with JndiPermission

use of org.wildfly.naming.java.permission.JndiPermission in project wildfly by wildfly.

the class SharedBindingTestCase method deployTwo.

@Deployment(name = BEAN_TWO_JAR_NAME, managed = false)
public static Archive<?> deployTwo() {
    final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, BEAN_TWO_JAR_NAME + ".jar");
    jar.addClasses(BeanTwo.class, TestResults.class);
    jar.addAsManifestResource(SharedBindingTestCase.class.getPackage(), "ejb-jar-two.xml", "ejb-jar.xml");
    jar.addAsManifestResource(createPermissionsXmlAsset(new JndiPermission("global/sharedbinds/two", "rebind")), "permissions.xml");
    return jar;
}
Also used : JndiPermission(org.wildfly.naming.java.permission.JndiPermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 13 with JndiPermission

use of org.wildfly.naming.java.permission.JndiPermission in project wildfly by wildfly.

the class JNDIBindingMBeanTestCase method createDeployment.

@Deployment
public static JavaArchive createDeployment() {
    final JavaArchive sar = ShrinkWrap.create(JavaArchive.class, "multiple-jndi-binding-mbeans.sar");
    sar.addClasses(JNDIBindingService.class, JNDIBindingMBeanTestCase.class, JNDIBindingServiceMBean.class);
    sar.addAsManifestResource(JNDIBindingMBeanTestCase.class.getPackage(), "multiple-jndi-binding-mbeans-jboss-service.xml", "jboss-service.xml");
    sar.addAsManifestResource(createPermissionsXmlAsset(new JndiPermission("global/env/foo/-", "bind,unbind")), "permissions.xml");
    return sar;
}
Also used : JndiPermission(org.wildfly.naming.java.permission.JndiPermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 14 with JndiPermission

use of org.wildfly.naming.java.permission.JndiPermission in project wildfly by wildfly.

the class ServletLifecycleMethodDescriptorTestCase method single.

@Deployment
public static WebArchive single() {
    WebArchive war = ShrinkWrap.create(WebArchive.class, "single.war");
    war.addClasses(HttpRequest.class, LifeCycleMethodServlet.class);
    war.addAsWebInfResource(ServletLifecycleMethodDescriptorTestCase.class.getPackage(), "web.xml", "web.xml");
    war.addAsManifestResource(createPermissionsXmlAsset(new JndiPermission("java:global/env/foo", "bind")), "permissions.xml");
    return war;
}
Also used : WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 15 with JndiPermission

use of org.wildfly.naming.java.permission.JndiPermission in project wildfly by wildfly.

the class NamingContext method check.

private void check(Name name, int actions) throws NamingException {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null && WildFlySecurityManager.isChecking()) {
        // build absolute name (including store's base name)
        Name absoluteName = (Name) namingStore.getBaseName().clone();
        if (name.isEmpty()) {
            absoluteName.addAll(prefix);
        } else {
            final String firstComponent = name.get(0);
            if (firstComponent.startsWith("java:")) {
                absoluteName = name;
            } else if (firstComponent.isEmpty()) {
                absoluteName.addAll(name.getSuffix(1));
            } else {
                absoluteName.addAll(prefix);
                if (name instanceof CompositeName) {
                    if (name.size() == 1) {
                        // name could be a nested name
                        absoluteName.addAll(parseName(firstComponent));
                    } else {
                        absoluteName.addAll(name);
                    }
                } else {
                    absoluteName.addAll(new CompositeName(name.toString()));
                }
            }
        }
        sm.checkPermission(new JndiPermission(absoluteName.toString(), actions));
    }
}
Also used : WildFlySecurityManager(org.wildfly.security.manager.WildFlySecurityManager) CompositeName(javax.naming.CompositeName) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name)

Aggregations

JndiPermission (org.wildfly.naming.java.permission.JndiPermission)19 CompositeName (javax.naming.CompositeName)10 Deployment (org.jboss.arquillian.container.test.api.Deployment)8 Test (org.junit.Test)7 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)6 ArrayList (java.util.ArrayList)3 Name (javax.naming.Name)3 PrivilegedActionException (java.security.PrivilegedActionException)2 LinkRef (javax.naming.LinkRef)2 NamingException (javax.naming.NamingException)2 Reference (javax.naming.Reference)2 StringRefAddr (javax.naming.StringRefAddr)2 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)2 AccessControlContext (java.security.AccessControlContext)1 AccessControlException (java.security.AccessControlException)1 CodeSource (java.security.CodeSource)1 Permissions (java.security.Permissions)1 ProtectionDomain (java.security.ProtectionDomain)1 Certificate (java.security.cert.Certificate)1 MBeanPermission (javax.management.MBeanPermission)1