use of org.wildfly.naming.java.permission.JndiPermission in project wildfly by wildfly.
the class NamingContextTestCase method testLookupLink.
@Test
public void testLookupLink() throws Exception {
final Name name = new CompositeName("test");
namingStore.bind(name, "testValue", String.class);
final Name linkName = new CompositeName("link");
namingStore.bind(linkName, new LinkRef("./test"));
Object result = namingContext.lookup(linkName);
assertEquals("testValue", result);
//the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test", "lookup")), namingContext, "link");
assertEquals("testValue", result);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitialContextFactory.class.getName());
namingStore.rebind(linkName, new LinkRef(name));
result = namingContext.lookup(linkName);
assertEquals("testValue", result);
//the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test", "lookup")), namingContext, "link");
assertEquals("testValue", result);
}
use of org.wildfly.naming.java.permission.JndiPermission in project wildfly by wildfly.
the class SharedBindingTestCase method deployOne.
@Deployment(name = BEAN_ONE_JAR_NAME, managed = false)
public static Archive<?> deployOne() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, BEAN_ONE_JAR_NAME + ".jar");
jar.addClasses(BeanOne.class, TestResults.class);
jar.addAsManifestResource(SharedBindingTestCase.class.getPackage(), "ejb-jar-one.xml", "ejb-jar.xml");
jar.addAsManifestResource(createPermissionsXmlAsset(new JndiPermission("global/sharedbinds/two", "rebind")), "permissions.xml");
return jar;
}
use of org.wildfly.naming.java.permission.JndiPermission in project wildfly by wildfly.
the class SecurityHelper method testActionWithPermission.
public static Object testActionWithPermission(final int action, final Collection<JndiPermission> additionalRequiredPerms, final NamingContext namingContext, final String name, final Object... params) throws Exception {
final CompositeName n = name == null ? new CompositeName() : new CompositeName(name);
final String sn = name == null ? "" : name;
ArrayList<JndiPermission> allPerms = new ArrayList<JndiPermission>(additionalRequiredPerms);
allPerms.add(new JndiPermission(sn, action));
return runWithSecurityManager(new Callable<Object>() {
@Override
public Object call() throws Exception {
return performAction(action, namingContext, n, params);
}
}, getSecurityContextForJNDILookup(allPerms));
}
use of org.wildfly.naming.java.permission.JndiPermission in project wildfly by wildfly.
the class NamingContextTestCase method testLookupWitResolveResult.
@Test
public void testLookupWitResolveResult() throws Exception {
namingStore.bind(new CompositeName("test/nested"), "test");
final Reference reference = new Reference(String.class.getName(), new StringRefAddr("blahh", "test"), TestObjectFactoryWithNameResolution.class.getName(), null);
namingStore.bind(new CompositeName("comp"), reference);
Object result = namingContext.lookup(new CompositeName("comp/nested"));
assertEquals("test", result);
//the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test/nested", "lookup")), namingContext, "comp/nested");
assertEquals("test", result);
}
Aggregations