Class DirectoryAttributeRetriever

java.lang.Object
com.atlassian.crowd.directory.ldap.util.DirectoryAttributeRetriever

public class DirectoryAttributeRetriever extends Object
  • Constructor Details

    • DirectoryAttributeRetriever

      public DirectoryAttributeRetriever()
  • Method Details

    • getValueFromAttributes

      public static String getValueFromAttributes(String directoryAttributeName, Attributes directoryAttributes)
      Retrieves the first value from the collection of attributes for the supplied name directoryAttributeName. If no value exists or if the value is not safe for XML marshalling, null is returned.
      Parameters:
      directoryAttributeName - attribute name key.
      directoryAttributes - collection of attributes to examine.
      Returns:
      first attribute value.
    • getValueFromExternalIdAttribute

      @Nullable public static String getValueFromExternalIdAttribute(String externalIdAttribute, Attributes directoryAttributes)
      Retrieves the first value from the collection of attributes for the supplied name externalIdAttribute. If name of the attribute is empty or no value for attribute exists null is returned.

      Although RFC4530 (http://www.ietf.org/rfc/rfc4530.txt) says that the 'entryUUID' attribute is "encoded using the ASCII character string representation described in RFC4122, for example 597ae2f6-16a6-1027-98f4-d28b5365dc14", it is conceivable that a directory may be configured to use any other binary or text attribute (e.g., the email) as external identifier. Therefore, this method accepts both String values and byte arrays, and makes sure that the Strings are XML-safe.

      Parameters:
      externalIdAttribute - name of external Id attribute
      directoryAttributes - collection of attributes
      Returns:
      null if there is no attribute name or if there is no value for an attribute name or if there are multiple values, value of attribute otherwise
    • toSaveableLDAPValue

      public static String toSaveableLDAPValue(String value)
      Transforms attribute values in order to comply with LDAP schemas. Reversing this transformation using fromSavedLDAPValue(String) is not lossless; see notes about value below.
      Parameters:
      value - the value to save. If null, it will be treated as the empty string.
      Returns:
      a value which is safe for saving to LDAP
      Throws:
      IllegalArgumentException - if the given value can't be saved as the value of an LDAP attribute