Search in sources :

Example 71 with CompositeName

use of javax.naming.CompositeName 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));
}
Also used : CompositeName(javax.naming.CompositeName) ArrayList(java.util.ArrayList) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) PrivilegedActionException(java.security.PrivilegedActionException) NamingException(javax.naming.NamingException)

Example 72 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class ServiceBasedNamingStoreTestCase method testLookupParentContext.

@Test
public void testLookupParentContext() throws Exception {
    final ServiceName bindingName = ServiceName.JBOSS.append("foo", "bar");
    store.add(bindingName);
    final Object obj = store.lookup(new CompositeName("foo"));
    assertNotNull(obj);
    assertTrue(obj instanceof Context);
}
Also used : StopContext(org.jboss.msc.service.StopContext) Context(javax.naming.Context) StartContext(org.jboss.msc.service.StartContext) ServiceName(org.jboss.msc.service.ServiceName) CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 73 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class ServiceBasedNamingStoreTestCase method testList.

@Test
public void testList() throws Exception {
    final Object value = new Object();
    bindObject(ServiceName.JBOSS.append("TestBean"), value);
    bindObject(ServiceName.JBOSS.append("foo", "TestBean"), value);
    bindObject(ServiceName.JBOSS.append("foo", "bar", "TestBean"), value);
    bindObject(ServiceName.JBOSS.append("foo", "bar", "baz", "TestBean"), value);
    store.add(ServiceName.JBOSS.append("foos", "bar"));
    store.add(ServiceName.JBOSS.append("fo", "bar"));
    store.add(ServiceName.JBOSS.append("foo", "ba", "baz"));
    store.add(ServiceName.JBOSS.append("foo", "bart", "baz"));
    store.add(ServiceName.JBOSS.append("foo", "bar", "ba"));
    store.add(ServiceName.JBOSS.append("foo", "bar", "bazt"));
    store.add(ServiceName.JBOSS.append("foo", "bar", "art"));
    store.add(ServiceName.JBOSS.append("other", "one"));
    List<NameClassPair> list = store.list(new CompositeName(""));
    assertEquals(5, list.size());
    assertContains(list, "TestBean", Object.class);
    assertContains(list, "foo", Context.class);
    assertContains(list, "fo", Context.class);
    assertContains(list, "foos", Context.class);
    assertContains(list, "other", Context.class);
    list = store.list(new CompositeName("foo"));
    assertEquals(4, list.size());
    assertContains(list, "TestBean", Object.class);
    assertContains(list, "ba", Context.class);
    assertContains(list, "bart", Context.class);
    assertContains(list, "bar", Context.class);
}
Also used : NameClassPair(javax.naming.NameClassPair) CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 74 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class WritableServiceBasedNamingStoreTestCase method testCreateSubContextNoOwner.

@Test
public void testCreateSubContextNoOwner() throws Exception {
    try {
        store.createSubcontext(new CompositeName("test"));
        fail("Should have failed with a read-only context exception");
    } catch (UnsupportedOperationException expected) {
    }
}
Also used : CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 75 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class WritableServiceBasedNamingStoreTestCase method testUnBindNoOwner.

@Test
public void testUnBindNoOwner() throws Exception {
    try {
        store.unbind(new CompositeName("test"));
        fail("Should have failed with a read-only context exception");
    } catch (UnsupportedOperationException expected) {
    }
}
Also used : CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Aggregations

CompositeName (javax.naming.CompositeName)124 Test (org.junit.Test)69 Name (javax.naming.Name)43 NameNotFoundException (javax.naming.NameNotFoundException)27 NamingException (javax.naming.NamingException)25 Reference (javax.naming.Reference)19 Context (javax.naming.Context)18 InvalidNameException (javax.naming.InvalidNameException)13 NotContextException (javax.naming.NotContextException)12 ServiceName (org.jboss.msc.service.ServiceName)11 Test (org.junit.jupiter.api.Test)10 JndiPermission (org.wildfly.naming.java.permission.JndiPermission)10 Hashtable (java.util.Hashtable)9 Binding (javax.naming.Binding)8 LinkRef (javax.naming.LinkRef)8 OperationNotSupportedException (javax.naming.OperationNotSupportedException)8 CallableWithoutResult (org.apereo.portal.concurrency.CallableWithoutResult)7 IEntityGroup (org.apereo.portal.groups.IEntityGroup)7 BaseAggrEventsJpaDaoTest (org.apereo.portal.test.BaseAggrEventsJpaDaoTest)7 StringRefAddr (javax.naming.StringRefAddr)5