LdapGroupsMapping implements GroupMappingServiceProvider, Configurable { @Override public synchronized List<String> getGroups(String user) throws IOException { List<String> emptyResults = new ArrayList<String>(); try { return doGetGroups(user); } catch (CommunicationException e) { LOG.warn("Connection is closed, will try to reconnect"); } catch (NamingException e) { LOG.warn("Exception trying to get groups for user " + user + ": " + e.getMessage()); return emptyResults; } int retryCount = 0; while (retryCount ++ < RECONNECT_RETRY_COUNT) { this.ctx = null; try { return doGetGroups(user); } catch (CommunicationException e) { LOG.warn("Connection being closed, reconnecting failed, retryCount = " + retryCount); } catch (NamingException e) { LOG.warn("Exception trying to get groups for user " + user + ":" + e.getMessage()); return emptyResults; } } return emptyResults; }  @Override synchronized List<String> getGroups(String user); @Override void cacheGroupsRefresh(); @Override void cacheGroupsAdd(List<String> groups); @Override synchronized Configuration getConf(); @Override synchronized void setConf(Configuration conf); 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 BIND_USER_KEY; static final String BIND_USER_DEFAULT; static final String BIND_PASSWORD_KEY; static final String BIND_PASSWORD_DEFAULT; static final String BIND_PASSWORD_FILE_KEY; static final String BIND_PASSWORD_FILE_DEFAULT; static final String BASE_DN_KEY; static final String BASE_DN_DEFAULT; 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 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 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 int RECONNECT_RETRY_COUNT; }
@Test public void testGetGroups() throws IOException, NamingException { when(mockContext.search(anyString(), anyString(), any(Object[].class), any(SearchControls.class))) .thenReturn(mockUserNamingEnum, mockGroupNamingEnum); doTestGetGroups(Arrays.asList(testGroups), 2); }