use of javax.naming.CompositeName 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));
}
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class ServiceBasedNamingStore method suffix.
private Name suffix(ServiceName parent, ServiceName child) {
String[] p = parent.toArray();
String[] c = child.toArray();
CompositeName name = new CompositeName();
for (int i = p.length; i < c.length; i++) {
try {
name.add(c[i]);
} catch (InvalidNameException e) {
throw new IllegalStateException(e);
}
}
return name;
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class InMemoryNamingStoreTestCase method testList.
@Test
public void testList() throws Exception {
final Name name = new CompositeName("test");
final Object object = new Object();
nameStore.bind(name, object, Object.class);
final Name nameTwo = new CompositeName("testTwo");
final Object objectTwo = new Object();
nameStore.bind(nameTwo, objectTwo, Object.class);
final Name nameThree = new CompositeName("testThree");
final Object objectThree = new Object();
nameStore.bind(nameThree, objectThree, Object.class);
nameStore.bind(new CompositeName("testContext/test"), "test");
final List<NameClassPair> results = nameStore.list(new CompositeName());
assertEquals(4, results.size());
final Set<String> expected = new HashSet<String>(Arrays.asList("test", "testTwo", "testThree", "testContext"));
for (NameClassPair result : results) {
final String resultName = result.getName();
if ("test".equals(resultName) || "testTwo".equals(resultName) || "testThree".equals(resultName)) {
assertEquals(Object.class.getName(), result.getClassName());
} else if ("testContext".equals(resultName)) {
assertEquals(Context.class.getName(), result.getClassName());
} else {
fail("Unknown result name: " + resultName);
}
expected.remove(resultName);
}
assertTrue("Not all expected results were returned", expected.isEmpty());
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class InMemoryNamingStoreTestCase method testBindAndRebind.
@Test
public void testBindAndRebind() throws Exception {
final Name name = new CompositeName("test");
final Object object = new Object();
nameStore.bind(name, object, Object.class);
assertEquals(object, nameStore.lookup(name));
final Object objectTwo = new Object();
nameStore.rebind(name, objectTwo, Object.class);
assertEquals(objectTwo, nameStore.lookup(name));
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class InMemoryNamingStoreTestCase method testBindAndLookup.
@Test
public void testBindAndLookup() throws Exception {
final Name name = new CompositeName("test");
final Object object = new Object();
nameStore.bind(name, object, Object.class);
final Object result = nameStore.lookup(name);
assertEquals(object, result);
}
Aggregations