Search in sources :

Example 6 with JndiPermission

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

the class NamingContextTestCase method testLookupContextLink.

@Test
public void testLookupContextLink() throws Exception {
    final Name name = new CompositeName("test/value");
    namingStore.bind(name, "testValue");
    final Name linkName = new CompositeName("link");
    namingStore.bind(linkName, new LinkRef("./test"));
    Object result = namingContext.lookup("link/value");
    assertEquals("testValue", result);
    //the same with security permissions
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test", "lookup"), new JndiPermission("test/value", "lookup")), namingContext, "link/value");
    assertEquals("testValue", result);
}
Also used : CompositeName(javax.naming.CompositeName) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) LinkRef(javax.naming.LinkRef) Test(org.junit.Test)

Example 7 with JndiPermission

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

the class NamingContextTestCase method testLookupWithContinuation.

@Test
public void testLookupWithContinuation() throws Exception {
    namingStore.bind(new CompositeName("comp/nested"), "test");
    final Reference reference = new Reference(String.class.getName(), new StringRefAddr("nns", "comp"), TestObjectFactoryWithNameResolution.class.getName(), null);
    namingStore.bind(new CompositeName("test"), reference);
    Object result = namingContext.lookup(new CompositeName("test/nested"));
    assertEquals("test", result);
    //the same with security permissions
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("comp/nested", "lookup")), namingContext, "test/nested");
    assertEquals("test", result);
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) CompositeName(javax.naming.CompositeName) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) Test(org.junit.Test)

Example 8 with JndiPermission

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

the class DeploymentWithBindTestCase method deploy.

@Deployment
public static Archive<?> deploy() {
    final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");
    war.addClasses(HttpRequest.class, BeanWithBind.class, ServletWithBind.class);
    war.addAsManifestResource(createPermissionsXmlAsset(new JndiPermission("global", "listBindings"), new JndiPermission("jboss", "listBindings"), new JndiPermission("jboss/exported", "listBindings"), new JndiPermission("/test", "bind"), new JndiPermission("jboss/test", "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 9 with JndiPermission

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

the class RemoteNamingEjbTestCase method deploy.

@Deployment
public static Archive<?> deploy() {
    final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, ARCHIVE_NAME + ".jar");
    jar.addClasses(Remote.class, BinderRemote.class, Bean.class, Singleton.class, StatefulBean.class);
    jar.addAsResource(createPermissionsXmlAsset(new JndiPermission("java:jboss/exported/-", "all")), "META-INF/jboss-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 10 with JndiPermission

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

the class LinkRefResourceInjectionTestCase method deployBinder.

@Deployment
public static Archive<?> deployBinder() {
    final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, BINDER_JAR_NAME + ".jar");
    jar.addClasses(BinderBean.class, Binder.class, Injected.class);
    jar.addAsManifestResource(createPermissionsXmlAsset(new JndiPermission("global/a", "bind"), new JndiPermission("global/b", "bind"), new JndiPermission("global/z", "bind")), "jboss-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)

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