Source:
private List<String> getUserListFromNonGroupFilterResult(NamingEnumeration<SearchResult> answer, List<String> returnedAttributes) { List<String> finalUserList = new ArrayList<>(); String userAttributeSeparator = ","; NamingEnumeration<?> attrs = null; try { while (answer.hasMoreElements()) { SearchResult searchResult = answer.next(); Attributes attributes = searchResult.getAttributes(); if (attributes != null) { Attribute attribute = attributes.get(returnedAttributes.get(0)); if (attribute != null) { StringBuffer attrBuffer = new StringBuffer(); for (attrs = attribute.getAll(); attrs.hasMore(); ) { String attr = (String) attrs.next(); if (attr != null && attr.trim().length() > 0) { String attrSeparator = realmConfig.getUserStoreProperty(MULTI_ATTRIBUTE_SEPARATOR); if (attrSeparator != null && !attrSeparator.trim().isEmpty()) { userAttributeSeparator = attrSeparator; } attrBuffer.append(attr + userAttributeSeparator); if (log.isDebugEnabled()) { log.debug(returnedAttributes.get(0) + " : " + attr); } } } String propertyValue = attrBuffer.toString(); Attribute serviceNameObject = attributes.get(returnedAttributes.get(1)); String serviceNameAttributeValue = null; if (serviceNameObject != null) { serviceNameAttributeValue = (String) serviceNameObject.get(); } if (propertyValue != null && propertyValue.trim().length() > userAttributeSeparator.length()) { if (LDAPConstants.SERVER_PRINCIPAL_ATTRIBUTE_VALUE.equals(serviceNameAttributeValue)) { continue; } propertyValue = propertyValue.substring(0, propertyValue.length() - userAttributeSeparator.length()); finalUserList.add(propertyValue); } } } } } catch (NamingException e) { if (log.isDebugEnabled()) { log.debug(e.getMessage(), e); } } finally { JNDIUtil.closeNamingEnumeration(attrs); JNDIUtil.closeNamingEnumeration(answer); } return finalUserList; }

Target:
private List<String> getUserListFromNonGroupFilterResult(NamingEnumeration<SearchResult> answer, List<String> returnedAttributes) throws UserStoreException { List<String> finalUserList = new ArrayList<>(); String userAttributeSeparator = ","; NamingEnumeration<?> attrs = null; try { while (answer.hasMoreElements()) { SearchResult searchResult = answer.next(); Attributes attributes = searchResult.getAttributes(); if (attributes == null) { continue; } Attribute attribute = attributes.get(returnedAttributes.get(0)); if (attribute == null) { continue; } StringBuffer attrBuffer = new StringBuffer(); for (attrs = attribute.getAll(); attrs.hasMore(); ) { String attr = (String) attrs.next(); if (StringUtils.isNotEmpty(attr.trim())) { String attrSeparator = realmConfig.getUserStoreProperty(MULTI_ATTRIBUTE_SEPARATOR); if (StringUtils.isNotEmpty(attrSeparator.trim())) { userAttributeSeparator = attrSeparator; } attrBuffer.append(attr + userAttributeSeparator); if (log.isDebugEnabled()) { log.debug(returnedAttributes.get(0) + " : " + attr); } } } String propertyValue = attrBuffer.toString(); Attribute serviceNameObject = attributes.get(returnedAttributes.get(1)); String serviceNameAttributeValue = null; if (serviceNameObject != null) { serviceNameAttributeValue = (String) serviceNameObject.get(); } if (propertyValue.trim().length() > userAttributeSeparator.length()) { if (LDAPConstants.SERVER_PRINCIPAL_ATTRIBUTE_VALUE.equals(serviceNameAttributeValue)) { continue; } propertyValue = propertyValue.substring(0, propertyValue.length() - userAttributeSeparator.length()); finalUserList.add(propertyValue); } } } catch (NamingException e) { log.error(String.format("Error occurred while getting user list from non group filter %s", e.getMessage())); throw new UserStoreException(e.getMessage(), e); } finally { JNDIUtil.closeNamingEnumeration(attrs); } return finalUserList; }