Skip navigation links


org.identityconnectors.framework.common.objects
Class AttributeUtil

java.lang.Object
  extended by org.identityconnectors.framework.common.objects.AttributeUtil


public final class AttributeUtil
extends java.lang.Object

Utility methods to retrieve values from instances of Attribute.


Constructor Summary
AttributeUtil()
           

 

Method Summary
static java.util.Set<Attribute> addUid(java.util.Set<Attribute> attrs, Uid uid)
          Returns a mutable copy of the original set with the uid attribute added.
static java.lang.String createSpecialName(java.lang.String name)
          Create a special name from the specified name.
static java.util.Set<Attribute> filterUid(java.util.Set<Attribute> attrs)
          Returns a mutable copy of the original set with the uid attribute removed.
static Attribute find(java.lang.String name, java.util.Set<Attribute> attrs)
          Find the Attribute of the given name in the Set.
static java.lang.String getAsStringValue(Attribute attr)
          Get the string value from the specified (single-valued) attribute.
static java.util.Set<Attribute> getBasicAttributes(java.util.Set<Attribute> attrs)
          Filter out any special attribute from the specified set.
static java.math.BigDecimal getBigDecimalValue(Attribute attr)
          Get the big decimal value from the specified (single-valued) attribute.
static java.lang.Boolean getBooleanValue(Attribute attr)
          Get the boolean value from the specified (single-valued) attribute.
static GuardedString getCurrentPasswordValue(java.util.Set<Attribute> attrs)
          Get the current password value from the provided set of Attributes.
static java.util.Date getDateValue(Attribute attr)
          Get the date value from the specified (single-valued) attribute that contains a long.
static java.lang.Double getDoubleValue(Attribute attr)
          Get the integer value from the specified (single-valued) attribute.
static EmbeddedObject getEmbeddedObjectValue(Attribute attr)
          Get the EmbeddedObject value from the specified (single-valued) attribute.
static java.util.Date getEnableDate(java.util.Set<Attribute> attrs)
          Get the enable date from the set of attributes.
static GuardedString getGuardedStringValue(Attribute attr)
          Get the GuardedString value from the specified (single-valued) attribute.
static java.lang.Integer getIntegerValue(Attribute attr)
          Get the integer value from the specified (single-valued) attribute.
static java.lang.Long getLongValue(Attribute attr)
          Get the long value from the specified (single-valued) attribute.
static Name getNameFromAttributes(java.util.Set<Attribute> attrs)
          Get the Name attribute from the specified set of attributes.
static java.util.Date getPasswordExpirationDate(ConnectorObject obj)
          Retrieve the password expiration date from the ConnectorObject.
static java.lang.Boolean getPasswordExpired(java.util.Set<Attribute> attrs)
          Get the password expired attribute from a Collection of Attributes.
static GuardedString getPasswordValue(java.util.Set<Attribute> attrs)
          Get the password value from the provided set of Attributes.
static java.lang.Object getSingleValue(Attribute attr)
          Get the Object value from the specified (single-valued) attribute.
static java.util.Set<Attribute> getSpecialAttributes(java.util.Set<Attribute> attrs)
          Filter out any basic attributes from the specified set, leaving only special attributes.
static java.lang.String getStringValue(Attribute attr)
          Get the string value from the specified (single-valued) attribute.
static Uid getUidAttribute(java.util.Set<Attribute> attrs)
          Get the Uid from the specified set of attributes.
static java.lang.Boolean isEnabled(ConnectorObject obj)
          Determine if the ConnectorObject is enable.
static java.lang.Boolean isLockedOut(ConnectorObject obj)
          Determine if the ConnectorObject is locked out.
static java.lang.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(java.lang.String name)
          Determines whether the specified attribute name is special in the sense of createSpecialName(java.lang.String).
static boolean namesEqual(java.lang.String name1, java.lang.String name2)
          Compares two attribute names for equality.
static java.util.Map<java.lang.String,Attribute> toMap(java.util.Collection<? extends Attribute> attributes)
          Transform a Collection of Attribute instances into a Map.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

AttributeUtil

public AttributeUtil()

Method Detail

getStringValue

public static java.lang.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:
java.lang.ClassCastException - iff the object in the attribute is not an string.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).

getGuardedStringValue

public static GuardedString getGuardedStringValue(Attribute attr)
Get the GuardedString 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:
java.lang.ClassCastException - iff the object in the attribute is not an GuardedString.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).

getAsStringValue

public static java.lang.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:
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).

getIntegerValue

public static java.lang.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:
java.lang.ClassCastException - iff the object in the attribute is not an integer.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).

getLongValue

public static java.lang.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:
java.lang.ClassCastException - iff the object in the attribute is not an long.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).

getDateValue

public static java.util.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:
java.lang.ClassCastException - iff the object in the attribute is not an long.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).

getDoubleValue

public static java.lang.Double getDoubleValue(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:
java.lang.ClassCastException - iff the object in the attribute is not an integer.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued)..

getBigDecimalValue

public static java.math.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:
java.lang.ClassCastException - iff the object in the attribute is not an big decimal.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).

getBooleanValue

public static java.lang.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:
java.lang.ClassCastException - iff the object in the attribute is not an Boolean.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).

getEmbeddedObjectValue

public static EmbeddedObject getEmbeddedObjectValue(Attribute attr)
Get the EmbeddedObject value from the specified (single-valued) attribute.
Parameters:
attr - Attribute from which to retrieve the EmbeddedObject value.
Returns:
null if the value is null otherwise the EmbeddedObject value for the attribute.
Throws:
java.lang.ClassCastException - iff the object in the attribute is not an EmbeddedObject.
java.lang.IllegalArgumentException - iff the attribute is a multi-valued (rather than single-valued).
Since:
1.2

getSingleValue

public static java.lang.Object getSingleValue(Attribute attr)
Get the Object value from the specified (single-valued) attribute. Return null if the attribute's list of values is null or empty.

toMap

public static java.util.Map<java.lang.String,Attribute> toMap(java.util.Collection<? extends Attribute> attributes)
Transform a Collection of Attribute instances into a Map. The key to each element in the map is the name of an Attribute. The value of each element in the map is the Attribute instance with that name.
Parameters:
attributes - set of attribute to transform to a map.
Returns:
a map of string and attribute.
Throws:
java.lang.NullPointerException - iff the parameter attributes is null.

getUidAttribute

public static Uid getUidAttribute(java.util.Set<Attribute> attrs)
Get the Uid from the specified set of attributes.
Parameters:
attrs - set of Attributes that may contain a Uid.
Returns:
null if the set does not contain a Uid object the first one found.

getBasicAttributes

public static java.util.Set<Attribute> getBasicAttributes(java.util.Set<Attribute> attrs)
Filter out any special attribute from the specified set. Special attributes include Name, Uid, and OperationalAttributes.
Parameters:
attrs - set of Attributes to filter out the operational and default attributes.
Returns:
a set that only contains plain attributes or empty.

getSpecialAttributes

public static java.util.Set<Attribute> getSpecialAttributes(java.util.Set<Attribute> attrs)
Filter out any basic attributes from the specified set, leaving only special attributes. Special attributes include Name, Uid, and OperationalAttributes.
Parameters:
attrs - set of Attributes 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 java.util.Set<Attribute> filterUid(java.util.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 java.util.Set<Attribute> addUid(java.util.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 include Uid, ObjectClass and OperationalAttributes.
Parameters:
attr - Attribute to test for against.
Returns:
true iff the attribute value is a Uid, ObjectClass or one of the OperationalAttributes.
Throws:
java.lang.NullPointerException - iff 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 include Uid, ObjectClass and OperationalAttributes.
Parameters:
attr - AttributeInfo to test for against.
Returns:
true iff the attribute value is a Uid, ObjectClass or one of the OperationalAttributes.
Throws:
java.lang.NullPointerException - iff the attribute parameter is null.

isSpecialName

public static boolean isSpecialName(java.lang.String name)
Determines whether the specified attribute name is special in the sense of createSpecialName(java.lang.String).
Parameters:
name - the attribute name to test against.
Returns:
true iff the attribute name is special.

createSpecialName

public static java.lang.String createSpecialName(java.lang.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 as Uid, ObjectClass or one of the OperationalAttributes.

namesEqual

public static boolean namesEqual(java.lang.String name1,
                                 java.lang.String name2)
Compares two attribute names for equality.
Parameters:
name1 - the first attribute name.
name2 - the second attribute name.
Returns:
true iff the two attribute names are equal.

getNameFromAttributes

public static Name getNameFromAttributes(java.util.Set<Attribute> attrs)
Get the Name attribute from the specified set of attributes.
Parameters:
attrs - set of attributes to search against.
Returns:
the Name attribute it if exsist otherwise null.

find

public static Attribute find(java.lang.String name,
                             java.util.Set<Attribute> attrs)
Find the Attribute of the given name in the Set.
Parameters:
name - Attribute's name to search for.
attrs - Set of attribute to search.
Returns:
Attribute with the specified otherwise null.

getPasswordValue

public static GuardedString getPasswordValue(java.util.Set<Attribute> attrs)
Get the password value from the provided set of Attributes.

getCurrentPasswordValue

public static GuardedString getCurrentPasswordValue(java.util.Set<Attribute> attrs)
Get the current password value from the provided set of Attributes.
Parameters:
attrs - Set of Attributes that may contain the current password OperationalAttributes.CURRENT_PASSWORD_NAME Attribute.
Returns:
null if it does not exist in the Set else the value.

isLockedOut

public static java.lang.Boolean isLockedOut(ConnectorObject obj)
Determine if the ConnectorObject is locked out. By getting the value of the OperationalAttributes.LOCK_OUT_NAME.
Parameters:
obj - ConnectorObject object to inspect.
Returns:
null if the attribute does not exist otherwise to value of the Attribute.
Throws:
java.lang.NullPointerException - iff the parameter 'obj' is null.

isEnabled

public static java.lang.Boolean isEnabled(ConnectorObject obj)
Determine if the ConnectorObject is enable. By getting the value of the OperationalAttributes.ENABLE_NAME.
Parameters:
obj - ConnectorObject object to inspect.
Returns:
null if the attribute does not exist otherwise to value of the Attribute.
Throws:
java.lang.IllegalStateException - if the object does not contain attribute in question.
java.lang.NullPointerException - iff the parameter 'obj' is null.

getPasswordExpirationDate

public static java.util.Date getPasswordExpirationDate(ConnectorObject obj)
Retrieve the password expiration date from the ConnectorObject.
Parameters:
obj - ConnectorObject object to inspect.
Returns:
null if the Attribute does not exist otherwise the value of the Attribute.
Throws:
java.lang.IllegalStateException - if the object does not contain attribute in question.
java.lang.NullPointerException - iff the parameter 'obj' is null.

getPasswordExpired

public static java.lang.Boolean getPasswordExpired(java.util.Set<Attribute> attrs)
Get the password expired attribute from a Collection of Attributes.
Parameters:
attrs - set of attribute to find the expired password Attribute.
Returns:
null if the attribute does not exist and the value of the Attribute if it does.

isPasswordExpired

public static java.lang.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 the Attribute if it does.

getEnableDate

public static java.util.Date getEnableDate(java.util.Set<Attribute> attrs)
Get the enable date from the set of attributes.
Parameters:
attrs - set of attribute to find the enable date Attribute.
Returns:
null if the attribute does not exist and the value of the Attribute if it does.

Skip navigation links


Copyright © 2011, Oracle and/or its affiliates. All rights reserved.