LdapGroupsMapping implements GroupMappingServiceProvider, Configurable { void getGroupNames(SearchResult groupResult, Collection<String> groups, Collection<String> groupDNs, boolean doGetDNs) throws NamingException { Attribute groupName = groupResult.getAttributes().get(groupNameAttr); if (groupName == null) { throw new NamingException("The group object does not have " + "attribute '" + groupNameAttr + "'."); } groups.add(groupName.get().toString()); if (doGetDNs) { groupDNs.add(groupResult.getNameInNamespace()); } }  @Override synchronized List<String> getGroups(String user); @Override void cacheGroupsRefresh(); @Override void cacheGroupsAdd(List<String> groups); @Override Set<String> getGroupsSet(String user); @Override synchronized Configuration getConf(); @Override synchronized void setConf(Configuration conf); Iterator<String> getLdapUrls(); static final String LDAP_CONFIG_PREFIX; static final String LDAP_URL_KEY; static final String LDAP_URL_DEFAULT; static final String LDAP_USE_SSL_KEY; static final Boolean LDAP_USE_SSL_DEFAULT; static final String LDAP_KEYSTORE_KEY; static final String LDAP_KEYSTORE_DEFAULT; static final String LDAP_KEYSTORE_PASSWORD_KEY; static final String LDAP_KEYSTORE_PASSWORD_DEFAULT; static final String LDAP_KEYSTORE_PASSWORD_FILE_KEY; static final String LDAP_KEYSTORE_PASSWORD_FILE_DEFAULT; static final String LDAP_TRUSTSTORE_KEY; static final String LDAP_TRUSTSTORE_PASSWORD_KEY; static final String LDAP_TRUSTSTORE_PASSWORD_FILE_KEY; static final String BIND_USERS_KEY; static final String BIND_USER_SUFFIX; static final String BIND_USER_KEY; static final String BIND_USER_DEFAULT; static final String BIND_PASSWORD_SUFFIX; static final String BIND_PASSWORD_KEY; static final String BIND_PASSWORD_DEFAULT; static final String BIND_PASSWORD_FILE_SUFFIX; static final String BIND_PASSWORD_FILE_KEY; static final String BIND_PASSWORD_FILE_DEFAULT; static final String BIND_PASSWORD_ALIAS_SUFFIX; static final String BIND_PASSWORD_ALIAS_KEY; static final String BIND_PASSWORD_ALIAS_DEFAULT; static final String BASE_DN_KEY; static final String BASE_DN_DEFAULT; static final String USER_BASE_DN_KEY; static final String GROUP_BASE_DN_KEY; static final String USER_SEARCH_FILTER_KEY; static final String USER_SEARCH_FILTER_DEFAULT; static final String GROUP_SEARCH_FILTER_KEY; static final String GROUP_SEARCH_FILTER_DEFAULT; static final String MEMBEROF_ATTR_KEY; static final String MEMBEROF_ATTR_DEFAULT; static final String GROUP_MEMBERSHIP_ATTR_KEY; static final String GROUP_MEMBERSHIP_ATTR_DEFAULT; static final String GROUP_NAME_ATTR_KEY; static final String GROUP_NAME_ATTR_DEFAULT; static final String GROUP_HIERARCHY_LEVELS_KEY; static final int GROUP_HIERARCHY_LEVELS_DEFAULT; static final String POSIX_UID_ATTR_KEY; static final String POSIX_UID_ATTR_DEFAULT; static final String POSIX_GID_ATTR_KEY; static final String POSIX_GID_ATTR_DEFAULT; static final String POSIX_GROUP; static final String POSIX_ACCOUNT; static final String DIRECTORY_SEARCH_TIMEOUT; static final int DIRECTORY_SEARCH_TIMEOUT_DEFAULT; static final String CONNECTION_TIMEOUT; static final int CONNECTION_TIMEOUT_DEFAULT; static final String READ_TIMEOUT; static final int READ_TIMEOUT_DEFAULT; static final String LDAP_NUM_ATTEMPTS_KEY; static final int LDAP_NUM_ATTEMPTS_DEFAULT; static final String LDAP_NUM_ATTEMPTS_BEFORE_FAILOVER_KEY; static final int LDAP_NUM_ATTEMPTS_BEFORE_FAILOVER_DEFAULT; static final String LDAP_CTX_FACTORY_CLASS_KEY; static final String LDAP_CTX_FACTORY_CLASS_DEFAULT; }
@Test public void testGetGroupsWithHierarchy() throws NamingException { when(getContext().search(anyString(), anyString(), any(Object[].class), any(SearchControls.class))) .thenReturn(getUserNames(), getGroupNames()); when(getContext().search(anyString(), anyString(), any(SearchControls.class))) .thenReturn(getParentGroupNames()); doTestGetGroupsWithParent(Arrays.asList(getTestParentGroups()), 2, 1); }
@Test public void testGetGroupsWithConnectionClosed() throws NamingException { when(getContext().search(anyString(), anyString(), any(Object[].class), any(SearchControls.class))) .thenThrow(new CommunicationException("Connection is closed")) .thenReturn(getUserNames(), getGroupNames()); doTestGetGroups(Arrays.asList(getTestGroups()), 1 + 2); }