public class IdentityData
extends java.lang.Object
implements java.lang.Cloneable
This class includes support for the following types of attributes:
- attributes with a single String value, e.g: firstName = "Susie"
- attributes with multiple String values, e.g: city = [ "Novato", "Chicago", "New York ]
- attributes with a single complex value, e.g: name = { "first": "John", "last": "Smith" }
- attributes with multiple complex values, e.g: name = [ { "first": "John", "last": "Smith" },
{ "first": "Jane", "last": "Smith" }]
Note: for a given attribute name, this class does not support having a mix of both String values and complex values. An attribute can have either String values or complex values, but not both.
Examples:IdentityData newEntry = new IdentityData(); // cn, sn, and givenName are single-valued attributes newEntry.addAttribute("cn", "John Smith"); newEntry.addAttribute("sn", "Smith"); newEntry.addAttribute("givenName", "John"); // mail and objectclass are multi-valued attributes newEntry.addAttribute("mail", "jsmith@radiantlogic.com", "jsmith@gmail.com"); newEntry.addAttribute("objectclass", "top", "person", "organizationalPerson", "inetOrgPerson"); IdentityData newEntry = new IdentityData(); // userName is a single-valued attribute newEntry.addAttribute("userName", "dschrute");
// name is a single-valued complex attribute with 3 sub-attributes: givenName, middleName, and familyName
ComplexValue nameComplexValue = new ComplexValue();
nameComplexValue.add("givenName", "Dwight");
nameComplexValue.add("middleName", "Kurt");
nameComplexValue.add("familyName", "Schrute");
newEntry.addComplexAttribute("name", nameComplexValue);
// phoneNumbers is a multi-valued complex attribute with 2 sub-attributes: type and value
ComplexValue workPhoneValue = new ComplexValue();
workPhoneValue.add("type", "work");
workPhoneValue.add("value", "555-555-8377");
ComplexValue homePhoneValue = new ComplexValue();
homePhoneValue.add("type", "home");
homePhoneValue.add("value", "555-333-4322");
newEntry.addComplexAttribute("phoneNumbers", workPhoneValue, homePhoneValue);
| Modifier and Type | Field and Description |
|---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
mapper |
| Constructor and Description |
|---|
IdentityData() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttribute(java.lang.String attributeName,
java.util.List<java.lang.String> values)
Sets one or more values for the specified attribute.
|
void |
addAttribute(java.lang.String attributeName,
java.lang.String... values)
Sets one or more values for the specified attribute.
|
void |
addAttribute(java.lang.String attributeName,
java.lang.String value)
Sets a single value for the specified attribute.
|
void |
addComplexAttribute(java.lang.String attributeName,
ComplexValue... complexValues)
Sets one or more complex values for the specified complex value.
|
void |
addComplexAttribute(java.lang.String attributeName,
ComplexValue complexValue)
Sets a single complex value for the specified attribute.
|
void |
addComplexAttribute(java.lang.String attributeName,
java.util.List<ComplexValue> complexValues)
Sets one or more complex values for the specified complex value.
|
java.lang.Object |
clone()
Creates and returns a copy of this object.
|
boolean |
containsAttribute(java.lang.String attributeName)
Indicates whether this IdentityData contains the specified attribute.
|
boolean |
containsComplexAttributeValue(java.lang.String attributeName)
Indicates whether this IdentityData contains an attribute that has at least one complex value.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getAdditionalProperties() |
java.util.Set<java.lang.String> |
getAttributeNames()
Returns the names of all the attributes that have been set for this IdentityData object.
|
java.util.List<ComplexValue> |
getComplexValues(java.lang.String attributeName)
Returns the list of complex values associated with the specified attribute or
null if the attribute
does not exist. |
protected java.lang.Object |
getExtraAttributeValue(java.lang.String attributeName) |
ComplexValue |
getFirstComplexValue(java.lang.String attributeName)
Returns the first complex value of the specified attribute or
null if the attribute does not exist. |
java.lang.String |
getFirstValueAsString(java.lang.String attributeName)
Returns the first value associated with the specified attribute.
|
java.util.List<java.lang.String> |
getNullSafeValuesAsString(java.lang.String attributeName)
Returns the list of values associated with the specified attribute.
|
java.util.List<java.lang.String> |
getValuesAsString(java.lang.String attributeName)
Returns the list of values associated with the specified attribute.
|
boolean |
isAttributeValueComplex(java.lang.String attributeName)
Indicates whether the specified attribute contains a ComplexValue value.
|
java.util.List<java.lang.String> |
listAttributeNames()
!!!Not public and subject to changes
list the attribute names that compose the message, the list is a deep copy of the keys' underlying data structure and can be modified independently |
java.lang.Object |
putAttribute(java.lang.String attributeName,
java.lang.Object value)
!!!Not public and subject to changes
force a put into the map - this method can be used when dealing with maintenance of the internal structure, returns the value of the key if already present |
void |
removeAttribute(java.lang.String attributeName)
Removes the specified attribute and any of its associated values from this IdentityData object.
|
java.lang.Object |
renameAttribute(java.lang.String attributeName,
java.lang.String newAttributName)
!!!Not public and subject to changes
rename the attribute to the provided new name and return any existing value if the new attribute name is already present |
protected void |
setAdditionalProperty(java.lang.String name,
java.lang.Object value) |
java.lang.String |
toString()
Returns the String representation of this IdentityData object.
|
java.lang.String |
toString(boolean isHideValueOfPasswordAttributes)
Returns the String representation of this object.
|
public java.lang.Object clone()
clone in class java.lang.Objectpublic void addAttribute(java.lang.String attributeName,
java.lang.String value)
attributeName - The name of an attribute.value - The value to set for the attribute.public void addAttribute(java.lang.String attributeName,
java.util.List<java.lang.String> values)
attributeName - The name of an attribute.values - The values to set for the attributes.public void addAttribute(java.lang.String attributeName,
java.lang.String... values)
attributeName - The name of an attribute.values - The values to set for the attributes.public void addComplexAttribute(java.lang.String attributeName,
ComplexValue complexValue)
attributeName - The name of an attribute.complexValue - The complex value to set for the attribute.public void addComplexAttribute(java.lang.String attributeName,
java.util.List<ComplexValue> complexValues)
attributeName - The name of an attribute.complexValues - The complex values to set for the attribute.public void addComplexAttribute(java.lang.String attributeName,
ComplexValue... complexValues)
attributeName - The name of an attribute.complexValues - The complex values to set for the attribute.public void removeAttribute(java.lang.String attributeName)
attributeName - The attribute to remove.public java.lang.Object putAttribute(java.lang.String attributeName,
java.lang.Object value)
public java.lang.Object renameAttribute(java.lang.String attributeName,
java.lang.String newAttributName)
public java.util.List<java.lang.String> listAttributeNames()
public java.util.Set<java.lang.String> getAttributeNames()
public java.lang.String getFirstValueAsString(java.lang.String attributeName)
null.attributeName - The name of the attribute.public java.util.List<java.lang.String> getValuesAsString(java.lang.String attributeName)
attributeName - The name of the attribute.public java.util.List<java.lang.String> getNullSafeValuesAsString(java.lang.String attributeName)
null.attributeName - The name of the attribute.public ComplexValue getFirstComplexValue(java.lang.String attributeName)
null if the attribute does not exist.
If the attribute contains a non-complex value (such as a basic String value), this method will throw an
IllegalArgumentException. To avoid this exception, you can call the isAttributeValueComplex(String)
method to first check if an attribute is complex before calling this method.attributeName - The name of the attribute.null if the attribute does not exist.public java.util.List<ComplexValue> getComplexValues(java.lang.String attributeName)
null if the attribute
does not exist. This method will also return null if an empty set of values is found for the specified
attribute. If the attribute contains a non-complex value (such as a basic String value), this method will throw an
IllegalArgumentException. To avoid this exception, you can call the isAttributeValueComplex(String)
method to first check if an attribute is complex before calling this method.attributeName - The name of the attribute.null if the attribute
does not exist.public boolean containsAttribute(java.lang.String attributeName)
attributeName - The name of an attribute.true if this IdentityData contains the specified attribute, or false otherwise.public boolean containsComplexAttributeValue(java.lang.String attributeName)
attributeName - The name of an attribute.true if this IdentityData objects contains the specified attribute, and if that attribute has
at least one complex value. Returns false otherwise.public boolean isAttributeValueComplex(java.lang.String attributeName)
attributeName - The name of an attribute.true if the specified attribute contains a ComplexValue value, or false otherwise.protected java.lang.Object getExtraAttributeValue(java.lang.String attributeName)
protected java.util.Map<java.lang.String,java.lang.Object> getAdditionalProperties()
protected void setAdditionalProperty(java.lang.String name,
java.lang.Object value)
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(boolean isHideValueOfPasswordAttributes)
isHideValueOfPasswordAttributes - Indicates whether attributes with password values should be hidden
from the returned String.