/** * Retrieves the name for this attribute. * * @return The name for this attribute. */ public String getName() { return attribute.getName(); }
@Override public String getDescription() { return attribute.getName(); }
@Override public String getDescription() { return attribute.getName(); }
/** * Retrieves the "other" attribute with the specified name. * * @param name The name of the "other" attribute to retrieve. It must not * be {@code null}. * * @return The "other" attribute with the specified name, or {@code null} if * there is no such "other" attribute. */ public Attribute getOtherAttribute(final String name) { for (final Attribute a : otherAttributes) { if (a.getName().equalsIgnoreCase(name)) { return a; } } return null; }
/** * {@inheritDoc} */ public Attribute getAttribute(final String attributeName) { ensureNotNull(attributeName); for (final Attribute a : attributes) { if (a.getName().equalsIgnoreCase(attributeName)) { return a; } } return null; }
/** * Replaces the specified attribute in the entry to add. If no attribute with * the given name exists in the add request, it will be added. * * @param attribute The attribute to be replaced in this add request. It * must not be {@code null}. */ public void replaceAttribute(final Attribute attribute) { ensureNotNull(attribute); for (int i=0; i < attributes.size(); i++) { if (attributes.get(i).getName().equalsIgnoreCase(attribute.getName())) { attributes.set(i, attribute); return; } } attributes.add(attribute); }
/** * {@inheritDoc} */ public Attribute getAttribute(final String attributeName) { ensureNotNull(attributeName); for (final Attribute a : attributes) { if (a.getName().equalsIgnoreCase(attributeName)) { return a; } } return null; }
/** * Adds the provided attribute to the entry to add. * * @param attribute The attribute to be added to the entry to add. It must * not be {@code null}. */ public void addAttribute(final Attribute attribute) { ensureNotNull(attribute); for (int i=0 ; i < attributes.size(); i++) { final Attribute a = attributes.get(i); if (a.getName().equalsIgnoreCase(attribute.getName())) { attributes.set(i, Attribute.mergeAttributes(a, attribute)); return; } } attributes.add(attribute); }
/** * Creates a compact attribute from the provided attribute. * * @param attribute The attribute to use to create this compact attribute. */ CompactAttribute(final Attribute attribute) { name = internName(attribute.getName()); values = attribute.getValueByteArrays(); }
/** * Removes the provided value from this attribute. * * @param attrValue The value to remove. */ public void removeValue(final String attrValue) { attribute = Attribute.removeValues(attribute, new Attribute(attribute.getName(), attrValue)); }
/** * Removes the provided value from this attribute. * * @param attrValue The value to remove. */ public void removeValue(final byte[] attrValue) { attribute = Attribute.removeValues(attribute, new Attribute(attribute.getName(), attrValue)); }
/** * Adds the provided value to the set of values for this attribute. * * @param attrBytes The value to add to this attribute. */ public void addValue(final byte[] attrBytes) { attribute = Attribute.mergeAttributes(attribute, new Attribute(attribute.getName(), attrBytes)); }
/** * Creates a compact attribute from the provided attribute. * * @param attribute The attribute to use to create this compact attribute. */ CompactAttribute(final Attribute attribute) { name = internName(attribute.getName()); values = attribute.getValueByteArrays(); }
/** * Adds the provided value to the set of values for this attribute. * * @param attrString The value to add to this attribute. */ public void addValue(final String attrString) { attribute = Attribute.mergeAttributes(attribute, new Attribute(attribute.getName(), attrString)); }
/** * {@inheritDoc} */ public boolean hasAttribute(final Attribute attribute) { ensureNotNull(attribute); final Attribute a = getAttribute(attribute.getName()); return ((a != null) && attribute.equals(a)); }
/** * {@inheritDoc} */ public boolean hasAttribute(final Attribute attribute) { ensureNotNull(attribute); final Attribute a = getAttribute(attribute.getName()); return ((a != null) && attribute.equals(a)); }
/** * Indicates whether this entry contains the specified attribute. It will * only return {@code true} if this entry contains an attribute with the same * name and exact set of values. * * @param attribute The attribute for which to make the determination. It * must not be {@code null}. * * @return {@code true} if this entry contains the specified attribute, or * {@code false} if not. */ public final boolean hasAttribute(final Attribute attribute) { ensureNotNull(attribute); final String lowerName = toLowerCase(attribute.getName()); final Attribute attr = attributes.get(lowerName); return ((attr != null) && attr.equals(attribute)); }
/** * Indicates whether this entry contains the specified attribute. It will * only return {@code true} if this entry contains an attribute with the same * name and exact set of values. * * @param attribute The attribute for which to make the determination. It * must not be {@code null}. * * @return {@code true} if this entry contains the specified attribute, or * {@code false} if not. */ public final boolean hasAttribute(final Attribute attribute) { ensureNotNull(attribute); final String lowerName = toLowerCase(attribute.getName()); final Attribute attr = attributes.get(lowerName); return ((attr != null) && attr.equals(attribute)); }
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); } } }