Class DirectoryAttributeRetriever
java.lang.Object
com.atlassian.crowd.directory.ldap.util.DirectoryAttributeRetriever
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetValueFromAttributes(String directoryAttributeName, Attributes directoryAttributes) Retrieves the first value from the collection of attributes for the supplied name directoryAttributeName.static StringgetValueFromExternalIdAttribute(String externalIdAttribute, Attributes directoryAttributes) Retrieves the first value from the collection of attributes for the supplied name externalIdAttribute.static StringtoSaveableLDAPValue(String value) Transforms attribute values in order to comply with LDAP schemas.
-
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,nullis 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 attributedirectoryAttributes- 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
Transforms attribute values in order to comply with LDAP schemas. Reversing this transformation usingfromSavedLDAPValue(String)is not lossless; see notes aboutvaluebelow.- 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
-