public class AttributeUtils extends Object
LdapService, but some of them are
more generally useful.| Modifier and Type | Field and Description |
|---|---|
static String |
ALTERNATE_ATTRIBUTE_POSTFIX
The text appended to attribute names to set alternate values - currently
;x-alternate. |
| Modifier and Type | Method and Description |
|---|---|
static void |
addAlternateAttribute(Map<String,Attribute> map,
String name,
List<FlaggableString> values)
Adds
BasicAttributes for both regular and alternate versions of the specified
attribute name to the provided Map, or sets appropriate nulls if null is
passed or no data of the given type is supplied. |
static void |
addAttribute(Map<String,Attribute> map,
String name,
Collection<String> values)
Adds a
BasicAttribute for the specified attribute name and values to the provided
Map, or adds a null if null is passed or no values are supplied. |
static void |
addAttribute(Map<String,Attribute> map,
String name,
org.threeten.bp.LocalDate value)
Adds a
BasicAttribute for the specified attribute name and value to the provided
Map, converting the date into a textual format, or adds a null if
null is passed. |
static void |
addAttribute(Map<String,Attribute> map,
String name,
Map<String,String> values,
String separator)
Adds a
BasicAttribute for the specified attribute name and values to the provided
Map, or adds a null if null is passed or no values are supplied. |
static void |
addAttribute(Map<String,Attribute> map,
String name,
String value)
Adds a
BasicAttribute for the specified attribute name and value to the provided
Map, or adds a null if null is passed. |
static void |
addUniqueAttribute(Map<String,Attribute> map,
String name,
Map<String,String> values)
Adds a
BasicAttribute for the specified attribute name and values to the provided
Map, or adds a null if null is passed or no values are supplied. |
static List<FlaggableString> |
extractAlternateAttribute(Attributes attribs,
String name)
Extracts the values for attributes with the supplied name, and the supplied name with
ALTERNATE_ATTRIBUTE_POSTFIX appended, from the supplied Attributes object
into a list of FlaggableStrings. |
static org.threeten.bp.LocalDate |
extractDateAttribute(Attributes attribs,
String name,
String dn)
Extracts the single value for the attribute with the supplied name from the supplied
Attributes object and converts it to a LocalDate, or returns null if
the attribute isn't set. |
static List<String> |
extractListAttribute(Attributes attribs,
String name)
Extracts the values for the attribute with the supplied name from the supplied
Attributes object into a List of Strings. |
static Map<String,String> |
extractMapAttribute(Attributes attribs,
String name,
String regex,
String dn)
Extracts the values for attribute with the supplied name from the supplied
Attributes
object into a @{code Map<String, String>}, using the supplied regular expression. |
static Set<String> |
extractSetAttribute(Attributes attribs,
String name)
Extracts the values for the attribute with the supplied name from the supplied
Attributes object into a Set of Strings. |
static String |
extractSingleValueAttribute(Attributes attribs,
String name)
Extracts the single value for the attribute with the supplied name from the supplied
Attributes object, or null if it isn't set. |
public static final String ALTERNATE_ATTRIBUTE_POSTFIX
;x-alternate.public static void addAttribute(Map<String,Attribute> map, String name, String value)
BasicAttribute for the specified attribute name and value to the provided
Map, or adds a null if null is passed.map - the map from attribute names to attribute objects to add toname - the name of the attribute to addvalue - the String to add, or null to add a nullpublic static void addAttribute(Map<String,Attribute> map, String name, org.threeten.bp.LocalDate value)
BasicAttribute for the specified attribute name and value to the provided
Map, converting the date into a textual format, or adds a null if
null is passed.map - the Map from attribute names to attribute objects to add toname - the name of the attribute to addvalue - the LocalDate to add, or null to add a nullpublic static void addAttribute(Map<String,Attribute> map, String name, Collection<String> values)
BasicAttribute for the specified attribute name and values to the provided
Map, or adds a null if null is passed or no values are supplied.map - the map from attribute names to attribute objects to add toname - the name of the attribute to addvalues - the collection of String values to add, or null to add a
nullpublic static void addAttribute(Map<String,Attribute> map, String name, Map<String,String> values, String separator)
BasicAttribute for the specified attribute name and values to the provided
Map, or adds a null if null is passed or no values are supplied. The
map of values provided is converted into set set of values by joining the key-value pairs
with the supplied separator.map - the map from attribute names to attribute objects to add toname - the name of the attribute to addvalues - the @{code Map<String, String>} to add, or null to add a
nullseparator - The separator to use when combining keys and valuespublic static void addAlternateAttribute(Map<String,Attribute> map, String name, List<FlaggableString> values)
BasicAttributes for both regular and alternate versions of the specified
attribute name to the provided Map, or sets appropriate nulls if null is
passed or no data of the given type is supplied.map - the map from attribute names to attribute objects to add toname - the name of the attribute to addvalues - a list of values to add, or null to add nullspublic static void addUniqueAttribute(Map<String,Attribute> map, String name, Map<String,String> values)
BasicAttribute for the specified attribute name and values to the provided
Map, or adds a null if null is passed or no values are supplied.
The values are the values from the supplied map values.values map must be populated by calling toUpper() on each
String you wish to add and using that as the key, the String to be written
forming the value.map - the map from attribute names to attribute objects to add toname - the name of the attribute to addvalues - the map with the values to add as both the values and, in upper case, the keys,
or null to add a nullpublic static String extractSingleValueAttribute(Attributes attribs, String name) throws NamingException
Attributes object, or null if it isn't set.attribs - the Attributes object containing the data to extractname - the name of the attributenull if it isn't setNamingException - in case of errorpublic static org.threeten.bp.LocalDate extractDateAttribute(Attributes attribs, String name, String dn) throws NamingException, LdapDataException
Attributes object and converts it to a LocalDate, or returns null if
the attribute isn't set.attribs - the Attributes object containing the data to extractname - the name of the attributedn - the Distinguished Name of the record, for use reporting errorsnull if it isn't setNamingException - in case of LDAP errorLdapDataException - if the format is incorrectpublic static List<String> extractListAttribute(Attributes attribs, String name) throws NamingException
Attributes object into a List of Strings.attribs - the Attributes object containing the data to extractname - the name of the attributeList of Strings with the extracted data, in no particular order, or
null if there are no valuesNamingException - in case of errorpublic static Set<String> extractSetAttribute(Attributes attribs, String name) throws NamingException
Attributes object into a Set of Strings.attribs - the Attributes object containing the data to extractname - the name of the attributeSet of Strings with the extracted data, or null if there
are no valuesNamingException - in case of errorpublic static Map<String,String> extractMapAttribute(Attributes attribs, String name, String regex, String dn) throws NamingException, LdapDataException
Attributes
object into a @{code Map<String, String>}, using the supplied regular expression.attribs - the Attributes object containing the data to extractname - the name of the attributeregex - the regular expression to split key and value from the attribute valuesdn - the Distinguished Name of the record, for use reporting errorsnull if there
are no valuesNamingException - in case of LDAP-related errorLdapDataException - in case of data format issuespublic static List<FlaggableString> extractAlternateAttribute(Attributes attribs, String name) throws NamingException
ALTERNATE_ATTRIBUTE_POSTFIX appended, from the supplied Attributes object
into a list of FlaggableStrings.attribs - the Attributes object containing the data to extractname - the name of the basic attribute, before appending the optionList<FlaggableString> with the extracted data, in no particular
order, or null if there are no valuesNamingException - in case of errorCopyright © 2018. All rights reserved.