public final class AttributeUtil
extends java.lang.Object
Attribute
.Constructor and Description |
---|
AttributeUtil() |
Modifier and Type | Method and Description |
---|---|
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 java.util.Set<Attribute> |
getCurrentAttributes(java.util.Set<Attribute> attrs)
Get the
OperationalAttributes.CURRENT_ATTRIBUTES from the set of attributes. |
static GuardedString |
getCurrentPasswordValue(java.util.Set<Attribute> attrs)
Get the current password value from the provided set of
Attribute s. |
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
Attribute s. |
static GuardedString |
getPasswordValue(java.util.Set<Attribute> attrs)
Get the password value from the provided set of
Attribute s. |
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)
|
public static java.lang.String getStringValue(Attribute attr)
attr
- Attribute from which to retrieve the string value.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).public static GuardedString getGuardedStringValue(Attribute attr)
GuardedString
value from the specified (single-valued)
attribute.attr
- Attribute from which to retrieve the string value.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).public static java.lang.String getAsStringValue(Attribute attr)
attr
- Attribute from which to retrieve the string value.java.lang.IllegalArgumentException
- iff the attribute is a multi-valued (rather than
single-valued).public static java.lang.Integer getIntegerValue(Attribute attr)
attr
- Attribute from which to retrieve the integer value.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).public static java.lang.Long getLongValue(Attribute attr)
attr
- Attribute from which to retrieve the long value.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).public static java.util.Date getDateValue(Attribute attr)
attr
- Attribute from which to retrieve the date value.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).public static java.lang.Double getDoubleValue(Attribute attr)
attr
- Attribute from which to retrieve the integer value.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)..public static java.math.BigDecimal getBigDecimalValue(Attribute attr)
attr
- Attribute from which to retrieve the big decimal value.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).public static java.lang.Boolean getBooleanValue(Attribute attr)
attr
- Attribute from which to retrieve the boolean value.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).public static EmbeddedObject getEmbeddedObjectValue(Attribute attr)
EmbeddedObject
value from the specified (single-valued) attribute.attr
- Attribute from which to retrieve the EmbeddedObject
value.EmbeddedObject
value for the
attribute.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).public static java.lang.Object getSingleValue(Attribute attr)
Object
value from the specified (single-valued)
attribute. Return null
if the attribute's list of values
is null
or empty.public static java.util.Map<java.lang.String,Attribute> toMap(java.util.Collection<? extends Attribute> attributes)
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.attributes
- set of attribute to transform to a map.java.lang.NullPointerException
- iff the parameter attributes is
null.public static Uid getUidAttribute(java.util.Set<Attribute> attrs)
Uid
from the specified set of attributes.public static java.util.Set<Attribute> getBasicAttributes(java.util.Set<Attribute> attrs)
Name
, Uid
, and
OperationalAttributes
.attrs
- set of Attribute
s to filter out the operational and
default attributes.public static java.util.Set<Attribute> getSpecialAttributes(java.util.Set<Attribute> attrs)
Name
, Uid
,
and OperationalAttributes
.attrs
- set of Attribute
s to filter out the basic attributespublic static java.util.Set<Attribute> filterUid(java.util.Set<Attribute> attrs)
attrs
- The original set. Must not be null.public static java.util.Set<Attribute> addUid(java.util.Set<Attribute> attrs, Uid uid)
attrs
- The original set. Must not be null.uid
- The uid. Must not be null.public static boolean isSpecial(Attribute attr)
Uid
, ObjectClass
and
OperationalAttributes
.attr
- Attribute
to test for against.Uid
,
ObjectClass
or one of the OperationalAttributes
.java.lang.NullPointerException
- iff the attribute parameter is null.public static boolean isSpecial(AttributeInfo attr)
Uid
, ObjectClass
and OperationalAttributes
.attr
- AttributeInfo
to test for against.Uid
,
ObjectClass
or one of the OperationalAttributes
.java.lang.NullPointerException
- iff the attribute parameter is null.public static boolean isSpecialName(java.lang.String name)
createSpecialName(java.lang.String)
.name
- the attribute name to test against.public static java.lang.String createSpecialName(java.lang.String name)
__
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
.public static boolean namesEqual(java.lang.String name1, java.lang.String name2)
name1
- the first attribute name.name2
- the second attribute name.public static Name getNameFromAttributes(java.util.Set<Attribute> attrs)
Name
attribute from the specified set of attributes.attrs
- set of attributes to search against.Name
attribute it if exsist otherwise
null
.public static Attribute find(java.lang.String name, java.util.Set<Attribute> attrs)
Attribute
of the given name in the Set
.public static GuardedString getPasswordValue(java.util.Set<Attribute> attrs)
Attribute
s.public static GuardedString getCurrentPasswordValue(java.util.Set<Attribute> attrs)
Attribute
s.attrs
- Set of Attribute
s that may contain the current password
OperationalAttributes.CURRENT_PASSWORD_NAME
Attribute
.null
if it does not exist in the Set
else
the value.public static java.lang.Boolean isLockedOut(ConnectorObject obj)
ConnectorObject
is locked out. By getting the
value of the OperationalAttributes.LOCK_OUT_NAME
.obj
- ConnectorObject
object to inspect.null
if the attribute does not exist otherwise to
value of the Attribute
.java.lang.NullPointerException
- iff the parameter 'obj' is null
.public static java.lang.Boolean isEnabled(ConnectorObject obj)
ConnectorObject
is enable. By getting the value
of the OperationalAttributes.ENABLE_NAME
.obj
- ConnectorObject
object to inspect.null
if the attribute does not exist otherwise to
value of the Attribute
.java.lang.IllegalStateException
- if the object does not contain attribute in question.java.lang.NullPointerException
- iff the parameter 'obj' is null
.public static java.util.Date getPasswordExpirationDate(ConnectorObject obj)
ConnectorObject
.obj
- ConnectorObject
object to inspect.null
if the Attribute
does not exist
otherwise the value of the Attribute
.java.lang.IllegalStateException
- if the object does not contain attribute in question.java.lang.NullPointerException
- iff the parameter 'obj' is null
.public static java.lang.Boolean getPasswordExpired(java.util.Set<Attribute> attrs)
Collection
of
Attribute
s.public static java.lang.Boolean isPasswordExpired(ConnectorObject obj)
obj
- ConnectorObject
that should contain a password expired
attribute.null
if the attribute does not exist and the value
of the Attribute
if it does.public static java.util.Date getEnableDate(java.util.Set<Attribute> attrs)
public static java.util.Set<Attribute> getCurrentAttributes(java.util.Set<Attribute> attrs)
OperationalAttributes.CURRENT_ATTRIBUTES
from the set of attributes. Since CURRENT_ATTRIBUTES
are represented as EmbeddedObject, it returns attributes of the embedded object.attrs
- set of attribute to find the current attributes embedded objectnull
if the attributes does not exist and the attributes of the
OperationalAttributes.CURRENT_ATTRIBUTES
embedded object if it does