@Override public List<ILdapAttribute> getAttributes() { if (attributes == null) { attributes = new ArrayList<>(elem.getAttributes().size()); for (Attribute e : elem.getAttributes()) { attributes.add(new DefaultLdapAttribute(e)); } } return attributes; }
@Override public List<ILdapAttribute> getAttributes() { if (attributes == null) { attributes = new ArrayList<>(elem.getAttributes().size()); for (Attribute e : elem.getAttributes()) { attributes.add(new DefaultLdapAttribute(e)); } } return attributes; }
final Iterator<Attribute> iterator = getAttributes().iterator();
final Iterator<Attribute> iterator = getAttributes().iterator();
for (Attribute userAttribute : userSearchResult.getAttributes()) { pattern = pattern.replace("${" + userAttribute.getName() + "}", userAttribute.getValue()); for (Attribute userAttribute : userSearchResult.getAttributes()) { pattern = pattern.replace("${" + userAttribute.getName() + "}", userAttribute.getValue());
private void setAccountRoles(LDAPConnection ldapConnection, SearchResultEntry accountSearchResult, Account account) { String accountDN = accountSearchResult.getDN(); String groupMemberPattern = this.groupMemberPattern.replace("${dn}", escapeLDAPSearchFilter(accountDN)); groupMemberPattern = groupMemberPattern.replace("${username}", escapeLDAPSearchFilter(account.getUsername())); // Fill in attributes into groupMemberPattern for (Attribute attribute : accountSearchResult.getAttributes()) { groupMemberPattern = groupMemberPattern.replace("${" + attribute.getName() + "}", escapeLDAPSearchFilter(attribute.getValue())); } SearchResult groupsSearchResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, Arrays.asList("cn")); if (groupsSearchResult != null && groupsSearchResult.getEntryCount() > 0) { for (int i = 0; i < groupsSearchResult.getEntryCount(); i++) { SearchResultEntry groupEntry = groupsSearchResult.getSearchEntries().get(i); String roleName = groupEntry.getAttribute("cn").getValue(); account.getAuthorizations().addRole(roleName); } } }
private void setAccountRoles(LDAPConnection ldapConnection, SearchResultEntry accountSearchResult, Account account) { String accountDN = accountSearchResult.getDN(); String groupMemberPattern = this.groupMemberPattern.replace("${dn}", escapeLDAPSearchFilter(accountDN)); groupMemberPattern = groupMemberPattern.replace("${username}", escapeLDAPSearchFilter(account.getUsername())); // Fill in attributes into groupMemberPattern for (Attribute attribute : accountSearchResult.getAttributes()) { groupMemberPattern = groupMemberPattern.replace("${" + attribute.getName() + "}", escapeLDAPSearchFilter(attribute.getValue())); } SearchResult groupsSearchResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, Arrays.asList("cn")); if (groupsSearchResult != null && groupsSearchResult.getEntryCount() > 0) { for (int i = 0; i < groupsSearchResult.getEntryCount(); i++) { SearchResultEntry groupEntry = groupsSearchResult.getSearchEntries().get(i); String roleName = groupEntry.getAttribute("cn").getValue(); account.getAuthorizations().addRole(roleName); } } }
for (Attribute userAttribute : userSearchResult.getAttributes()) { pattern = pattern.replace("${" + userAttribute.getName() + "}", userAttribute.getValue()); for (Attribute userAttribute : userSearchResult.getAttributes()) { pattern = pattern.replace("${" + userAttribute.getName() + "}", userAttribute.getValue());
for (Attribute attribute : entry.getAttributes()) { String name = attribute.getName(); switch (name) {
/** * {@inheritDoc} */ @Override() public void formatSearchResultEntry(final SearchResultEntry entry) { jsonBuffer.clear(); jsonBuffer.beginObject(); jsonBuffer.appendString("result-type", "entry"); jsonBuffer.appendString("dn", entry.getDN()); jsonBuffer.beginArray("attributes"); for (final Attribute a : entry.getAttributes()) { jsonBuffer.beginObject(); jsonBuffer.appendString("name", a.getName()); jsonBuffer.beginArray("values"); for (final String value : a.getValues()) { jsonBuffer.appendString(value); } jsonBuffer.endArray(); jsonBuffer.endObject(); } jsonBuffer.endArray(); handleControls(entry.getControls()); jsonBuffer.endObject(); ldapSearch.writeOut(jsonBuffer.toString()); }