use of javax.naming.CompositeName in project gerrit by GerritCodeReview.
the class Helper method recursivelyExpandGroups.
private void recursivelyExpandGroups(final Set<String> groupDNs, final LdapSchema schema, final DirContext ctx, final String groupDN) {
if (groupDNs.add(groupDN) && schema.accountMemberField != null && schema.accountMemberExpandGroups) {
ImmutableSet<String> cachedParentsDNs = parentGroups.getIfPresent(groupDN);
if (cachedParentsDNs == null) {
// Recursively identify the groups it is a member of.
ImmutableSet.Builder<String> dns = ImmutableSet.builder();
try {
final Name compositeGroupName = new CompositeName().add(groupDN);
final Attribute in = ctx.getAttributes(compositeGroupName, schema.accountMemberFieldArray).get(schema.accountMemberField);
if (in != null) {
final NamingEnumeration<?> groups = in.getAll();
try {
while (groups.hasMore()) {
dns.add((String) groups.next());
}
} catch (PartialResultException e) {
// Ignored
}
}
} catch (NamingException e) {
logger.atWarning().withCause(e).log("Could not find group %s", groupDN);
}
cachedParentsDNs = dns.build();
parentGroups.put(groupDN, cachedParentsDNs);
}
for (String dn : cachedParentsDNs) {
recursivelyExpandGroups(groupDNs, schema, ctx, dn);
}
}
}
use of javax.naming.CompositeName in project uPortal by Jasig.
the class JpaEventAggregationManagementDaoTest method testAggregatedGroupConfig.
@Test
public void testAggregatedGroupConfig() throws Exception {
final IEntityGroup everyoneGroup = mock(IEntityGroup.class);
when(everyoneGroup.getServiceName()).thenReturn(new CompositeName("local"));
when(everyoneGroup.getName()).thenReturn("Everyone");
when(compositeGroupService.findGroup("local.0")).thenReturn(everyoneGroup);
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(0, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNull(loginAggregatedGroupConfig);
loginAggregatedGroupConfig = eventAggregationManagementDao.createAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNotNull(loginAggregatedGroupConfig);
assertEquals(0, loginAggregatedGroupConfig.getExcluded().size());
assertEquals(0, loginAggregatedGroupConfig.getIncluded().size());
final AggregatedGroupMapping group = aggregatedGroupLookupDao.getGroupMapping("local.0");
defaultAggregatedGroupConfig.getIncluded().add(group);
loginAggregatedGroupConfig.getExcluded().add(group);
eventAggregationManagementDao.updateAggregatedGroupConfig(defaultAggregatedGroupConfig);
eventAggregationManagementDao.updateAggregatedGroupConfig(loginAggregatedGroupConfig);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(1, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNotNull(loginAggregatedGroupConfig);
assertEquals(1, loginAggregatedGroupConfig.getExcluded().size());
assertEquals(0, loginAggregatedGroupConfig.getIncluded().size());
eventAggregationManagementDao.deleteAggregatedGroupConfig(defaultAggregatedGroupConfig);
eventAggregationManagementDao.deleteAggregatedGroupConfig(loginAggregatedGroupConfig);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(0, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNull(loginAggregatedGroupConfig);
}
});
}
use of javax.naming.CompositeName in project uPortal by Jasig.
the class JpaAggregatedGroupLookupDaoTest method testLoginAggregationLifecycle.
@Test
public void testLoginAggregationLifecycle() throws Exception {
final IEntityGroup everyoneGroup = mock(IEntityGroup.class);
when(everyoneGroup.getServiceName()).thenReturn(new CompositeName("local"));
when(everyoneGroup.getName()).thenReturn("Everyone");
when(compositeGroupService.findGroup("local.0")).thenReturn(everyoneGroup);
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupMapping groupMapping = aggregatedGroupLookupDao.getGroupMapping("local.0");
assertNotNull(groupMapping);
assertEquals("local", groupMapping.getGroupService());
assertEquals("Everyone", groupMapping.getGroupName());
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupMapping groupMapping = aggregatedGroupLookupDao.getGroupMapping("local.0");
assertNotNull(groupMapping);
assertEquals("local", groupMapping.getGroupService());
assertEquals("Everyone", groupMapping.getGroupName());
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupMapping groupMapping = aggregatedGroupLookupDao.getGroupMapping("local.2");
assertNotNull(groupMapping);
assertEquals("local", groupMapping.getGroupService());
assertEquals("2", groupMapping.getGroupName());
}
});
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class WritableServiceBasedNamingStoreTestCase method testBindNoOwner.
@Test
public void testBindNoOwner() throws Exception {
try {
store.bind(new CompositeName("test"), new Object());
fail("Should have failed with a read-only context exception");
} catch (UnsupportedOperationException expected) {
}
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class WritableServiceBasedNamingStoreTestCase method testRebind.
@Test
public void testRebind() throws Exception {
final Name name = new CompositeName("test");
final Object value = new Object();
final Object newValue = new Object();
WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
try {
store.bind(name, value);
store.rebind(name, newValue);
} finally {
WritableServiceBasedNamingStore.popOwner();
}
assertEquals(newValue, store.lookup(name));
}
Aggregations