Class AttributeUtil
- java.lang.Object
-
- org.identityconnectors.framework.common.objects.AttributeUtil
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Set<Attribute>
addUid(Set<Attribute> attrs, Uid uid)
Returns a mutable copy of the original set with the uid attribute added.static String
createSpecialName(String name)
Create a special name from the specified name.static Set<Attribute>
filterUid(Set<Attribute> attrs)
Returns a mutable copy of the original set with the uid attribute removed.static Attribute
find(String name, Set<Attribute> attrs)
static String
getAsStringValue(Attribute attr)
Get the string value from the specified (single-valued) attribute.static Set<Attribute>
getBasicAttributes(Set<Attribute> attrs)
Filter out any special attribute from the specified set.static BigDecimal
getBigDecimalValue(Attribute attr)
Get the big decimal value from the specified (single-valued) attribute.static BigInteger
getBigIntegerValue(Attribute attr)
Get the big integer value from the specified (single-valued) attribute.static Boolean
getBooleanValue(Attribute attr)
Get the boolean value from the specified (single-valued) attribute.static Byte[]
getByteArrayValue(Attribute attr)
Get the byte array value from the specified (single-valued) attribute.static Byte
getByteValue(Attribute attr)
Get the byte value from the specified (single-valued) attribute.static Character
getCharacterValue(Attribute attr)
Get the character value from the specified (single-valued) attribute.static GuardedString
getCurrentPasswordValue(Set<Attribute> attrs)
Get the current password value from the provided set ofAttribute
s.static Date
getDateValue(Attribute attr)
Get the date value from the specified (single-valued) attribute that contains a long.static Double
getDoubleValue(Attribute attr)
Get the double value from the specified (single-valued) attribute.static Date
getEnableDate(Set<Attribute> attrs)
Get the enable date from the set of attributes.static Float
getFloatValue(Attribute attr)
Get the float value from the specified (single-valued) attribute.static GuardedByteArray
getGuardedByteArrayValue(Attribute attr)
Get theGuardedByteArray
value from the specified (single-valued) attribute.static GuardedString
getGuardedStringValue(Attribute attr)
Get theGuardedString
value from the specified (single-valued) attribute.static Integer
getIntegerValue(Attribute attr)
Get the integer value from the specified (single-valued) attribute.static Long
getLongValue(Attribute attr)
Get the long value from the specified (single-valued) attribute.static Map<String,Object>
getMapValue(Attribute attr)
Get the map value from the specified (single-valued) attribute.static Name
getNameFromAttributes(Set<Attribute> attrs)
Get theName
attribute from the specified set of attributes.static Date
getPasswordExpirationDate(ConnectorObject obj)
Retrieve the password expiration date from theConnectorObject
.static Boolean
getPasswordExpired(Set<Attribute> attrs)
Get the password expired attribute from aCollection
ofAttribute
s.static GuardedString
getPasswordValue(Set<Attribute> attrs)
Get the password value from the provided set ofAttribute
s.static Object
getSingleValue(Attribute attr)
Get theObject
value from the specified (single-valued) attribute.static Set<Attribute>
getSpecialAttributes(Set<Attribute> attrs)
Filter out any basic attributes from the specified set, leaving only special attributes.static String
getStringValue(Attribute attr)
Get the string value from the specified (single-valued) attribute.static Uid
getUidAttribute(Set<Attribute> attrs)
Get theUid
from the specified set of attributes.static Boolean
isEnabled(ConnectorObject obj)
Determine if theConnectorObject
is enable.static Boolean
isLockedOut(ConnectorObject obj)
Determine if theConnectorObject
is locked out.static Boolean
isPasswordExpired(ConnectorObject obj)
Determine if the password is expired for this object.static boolean
isSpecial(Attribute attr)
Determines whether the specified attribute is a special attribute.static boolean
isSpecial(AttributeInfo attr)
Determines whether the specified attribute info is for a special attribute.static boolean
isSpecialName(String name)
Determines whether the specified attribute name is special in the sense ofcreateSpecialName(java.lang.String)
.static boolean
namesEqual(String name1, String name2)
Compares two attribute names for equality.static Map<String,Attribute>
toMap(Collection<? extends Attribute> attributes)
-
-
-
Method Detail
-
getStringValue
public static String getStringValue(Attribute attr)
Get the string value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the string value.- Returns:
- null if the value is null otherwise the string value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a string.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getCharacterValue
public static Character getCharacterValue(Attribute attr)
Get the character value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the character value.- Returns:
- null if the value is null otherwise the character value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a character.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).- Since:
- 1.4
-
getGuardedByteArrayValue
public static GuardedByteArray getGuardedByteArrayValue(Attribute attr)
Get theGuardedByteArray
value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the guarded byte array value.- Returns:
- null if the value is null otherwise the guarded byte array value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a GuardedByteArray.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).- Since:
- 1.4
-
getGuardedStringValue
public static GuardedString getGuardedStringValue(Attribute attr)
Get theGuardedString
value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the guarded string value.- Returns:
- null if the value is null otherwise the guarded string value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a GuardedString.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getAsStringValue
public static String getAsStringValue(Attribute attr)
Get the string value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the string value.- Returns:
- null if the value is null otherwise the string value for the attribute.
- Throws:
IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getByteValue
public static Byte getByteValue(Attribute attr)
Get the byte value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the byte value.- Returns:
- null if the value is null otherwise the byte value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a byte.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).- Since:
- 1.4
-
getByteArrayValue
public static Byte[] getByteArrayValue(Attribute attr)
Get the byte array value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the byte array value.- Returns:
- null if the value is null otherwise the byte array value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a byte array.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).- Since:
- 1.4
-
getIntegerValue
public static Integer getIntegerValue(Attribute attr)
Get the integer value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the integer value.- Returns:
- null if the value is null otherwise the integer value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not an integer.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getLongValue
public static Long getLongValue(Attribute attr)
Get the long value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the long value.- Returns:
- null if the value is null otherwise the long value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a long.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getFloatValue
public static Float getFloatValue(Attribute attr)
Get the float value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the float value.- Returns:
- null if the value is null otherwise the float value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a float.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).- Since:
- 1.4
-
getDateValue
public static Date getDateValue(Attribute attr)
Get the date value from the specified (single-valued) attribute that contains a long.- Parameters:
attr
- Attribute from which to retrieve the date value.- Returns:
- null if the value is null otherwise the date value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a long.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getDoubleValue
public static Double getDoubleValue(Attribute attr)
Get the double value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the double value.- Returns:
- null if the value is null otherwise the double value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a double.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued)..
-
getBigDecimalValue
public static BigDecimal getBigDecimalValue(Attribute attr)
Get the big decimal value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the big decimal value.- Returns:
- null if the value is null otherwise the big decimal value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a big decimal.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getBigIntegerValue
public static BigInteger getBigIntegerValue(Attribute attr)
Get the big integer value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the big integer value.- Returns:
- null if the value is null otherwise the big integer value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not a big integer.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).- Since:
- 1.4
-
getBooleanValue
public static Boolean getBooleanValue(Attribute attr)
Get the boolean value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the boolean value.- Returns:
- null if the value is null otherwise the boolean value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not anBoolean
.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getMapValue
public static Map<String,Object> getMapValue(Attribute attr)
Get the map value from the specified (single-valued) attribute.- Parameters:
attr
- Attribute from which to retrieve the map value.- Returns:
- null if the value is null otherwise the map value for the attribute.
- Throws:
ClassCastException
- if the object in the attribute is not anMap
.IllegalArgumentException
- if the attribute is a multi-valued (rather than single-valued).
-
getSingleValue
public static Object getSingleValue(Attribute attr)
Get theObject
value from the specified (single-valued) attribute.- Returns:
null
if the attribute's list of values isnull
or empty.
-
toMap
public static Map<String,Attribute> toMap(Collection<? extends Attribute> attributes)
Transform aCollection
ofAttribute
instances into aMap
. The key to each element in the map is the name of anAttribute
. The value of each element in the map is theAttribute
instance with that name.- Parameters:
attributes
- set of attribute to transform to a map.- Returns:
- a map of string and attribute.
- Throws:
NullPointerException
- if the parameter attributes is null.
-
getUidAttribute
public static Uid getUidAttribute(Set<Attribute> attrs)
Get theUid
from the specified set of attributes.
-
getBasicAttributes
public static Set<Attribute> getBasicAttributes(Set<Attribute> attrs)
Filter out any special attribute from the specified set. Special attributes includeName
,Uid
, andOperationalAttributes
.- Parameters:
attrs
- set ofAttribute
s to filter out the operational and default attributes.- Returns:
- a set that only contains plain attributes or empty.
-
getSpecialAttributes
public static Set<Attribute> getSpecialAttributes(Set<Attribute> attrs)
Filter out any basic attributes from the specified set, leaving only special attributes. Special attributes includeName
,Uid
, andOperationalAttributes
.- Parameters:
attrs
- set ofAttribute
s to filter out the basic attributes- Returns:
- a set that only contains special attributes or an empty set if there are none.
-
filterUid
public static Set<Attribute> filterUid(Set<Attribute> attrs)
Returns a mutable copy of the original set with the uid attribute removed.- Parameters:
attrs
- The original set. Must not be null.- Returns:
- A mutable copy of the original set with the uid attribute removed.
-
addUid
public static Set<Attribute> addUid(Set<Attribute> attrs, Uid uid)
Returns a mutable copy of the original set with the uid attribute added.- Parameters:
attrs
- The original set. Must not be null.uid
- The uid. Must not be null.- Returns:
- A mutable copy of the original set with the uid attribute added.
-
isSpecial
public static boolean isSpecial(Attribute attr)
Determines whether the specified attribute is a special attribute. Special attributes includeUid
,ObjectClass
andOperationalAttributes
.- Parameters:
attr
-Attribute
to test for against.- Returns:
- true if the attribute value is a
Uid
,ObjectClass
or one of theOperationalAttributes
. - Throws:
NullPointerException
- if the attribute parameter is null.
-
isSpecial
public static boolean isSpecial(AttributeInfo attr)
Determines whether the specified attribute info is for a special attribute. Special attributes includeUid
,ObjectClass
andOperationalAttributes
.- Parameters:
attr
-AttributeInfo
to test for against.- Returns:
- true if the attribute value is a
Uid
,ObjectClass
or one of theOperationalAttributes
. - Throws:
NullPointerException
- if the attribute parameter is null.
-
isSpecialName
public static boolean isSpecialName(String name)
Determines whether the specified attribute name is special in the sense ofcreateSpecialName(java.lang.String)
.- Parameters:
name
- the attribute name to test against.- Returns:
- true if the attribute name is special.
-
createSpecialName
public static String createSpecialName(String name)
Create a special name from the specified name. Add the__
string as both prefix and suffix. This indicates that an attribute name identifies a "special attribute" such asUid
,ObjectClass
or one of theOperationalAttributes
.
-
namesEqual
public static boolean namesEqual(String name1, String name2)
Compares two attribute names for equality.- Parameters:
name1
- the first attribute name.name2
- the second attribute name.- Returns:
- true if the two attribute names are equal.
-
getNameFromAttributes
public static Name getNameFromAttributes(Set<Attribute> attrs)
Get theName
attribute from the specified set of attributes.- Parameters:
attrs
- set of attributes to search against.- Returns:
- the
Name
attribute it if exsist otherwisenull
.
-
getPasswordValue
public static GuardedString getPasswordValue(Set<Attribute> attrs)
Get the password value from the provided set ofAttribute
s.
-
getCurrentPasswordValue
public static GuardedString getCurrentPasswordValue(Set<Attribute> attrs)
Get the current password value from the provided set ofAttribute
s.- Parameters:
attrs
- Set ofAttribute
s that may contain the current passwordOperationalAttributes.CURRENT_PASSWORD_NAME
Attribute
.- Returns:
null
if it does not exist in theSet
else the value.
-
isLockedOut
public static Boolean isLockedOut(ConnectorObject obj)
Determine if theConnectorObject
is locked out. By getting the value of theOperationalAttributes.LOCK_OUT_NAME
.- Parameters:
obj
-ConnectorObject
object to inspect.- Returns:
null
if the attribute does not exist otherwise to value of theAttribute
.- Throws:
NullPointerException
- if the parameter 'obj' isnull
.
-
isEnabled
public static Boolean isEnabled(ConnectorObject obj)
Determine if theConnectorObject
is enable. By getting the value of theOperationalAttributes.ENABLE_NAME
.- Parameters:
obj
-ConnectorObject
object to inspect.- Returns:
null
if the attribute does not exist otherwise to value of theAttribute
.- Throws:
IllegalStateException
- if the object does not contain attribute in question.NullPointerException
- if the parameter 'obj' isnull
.
-
getPasswordExpirationDate
public static Date getPasswordExpirationDate(ConnectorObject obj)
Retrieve the password expiration date from theConnectorObject
.- Parameters:
obj
-ConnectorObject
object to inspect.- Returns:
null
if theAttribute
does not exist otherwise the value of theAttribute
.- Throws:
IllegalStateException
- if the object does not contain attribute in question.NullPointerException
- if the parameter 'obj' isnull
.
-
getPasswordExpired
public static Boolean getPasswordExpired(Set<Attribute> attrs)
Get the password expired attribute from aCollection
ofAttribute
s.
-
isPasswordExpired
public static Boolean isPasswordExpired(ConnectorObject obj)
Determine if the password is expired for this object.- Parameters:
obj
-ConnectorObject
that should contain a password expired attribute.- Returns:
null
if the attribute does not exist and the value of theAttribute
if it does.
-
-