public class LDAPAttribute
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
LDAPAttributeSet,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isDuplicatedAllowed |
| Constructor and Description |
|---|
LDAPAttribute(BERElement element)
Constructs an attribute from a BER (Basic Encoding Rules) element.
|
LDAPAttribute(LDAPAttribute attr)
Constructs an attribute from another existing attribute.
|
LDAPAttribute(java.lang.String attrName)
Constructs an attribute with no values.
|
LDAPAttribute(java.lang.String attrName,
boolean isDuplicatedAllowed) |
LDAPAttribute(java.lang.String attrName,
byte[] attrValue)
Constructs an attribute with a byte-formatted value.
|
LDAPAttribute(java.lang.String attrName,
byte[][] arrayAttrValue)
Constructs an attribute with a byte-formatted value.
|
LDAPAttribute(java.lang.String attrName,
byte[] attrValue,
boolean isDuplicatedAllowed) |
LDAPAttribute(java.lang.String attrName,
java.util.Collection<byte[]> attrValue)
constructor with byte[]
|
LDAPAttribute(java.lang.String attrName,
java.util.List<java.lang.String> attrValues)
constructor with String
|
LDAPAttribute(java.lang.String attrName,
java.lang.Object[] attrValue) |
LDAPAttribute(java.lang.String attrName,
java.lang.Object[] attrValue,
boolean isDuplicatedAllowed) |
LDAPAttribute(java.lang.String attrName,
java.lang.String attrValue)
Constructs an attribute that has a single string value.
|
LDAPAttribute(java.lang.String attrName,
java.lang.String[] attrValues)
Constructs an attribute that has an array of string values.
|
LDAPAttribute(java.lang.String attrName,
java.lang.String[] attrValues,
boolean isDuplicatedAllowed) |
LDAPAttribute(java.lang.String attrName,
java.lang.String attrValue,
boolean isDuplicatedAllowed) |
LDAPAttribute(java.lang.String attrName,
java.util.Vector<byte[]> attrValue,
boolean isDuplicatedAllowed) |
| Modifier and Type | Method and Description |
|---|---|
void |
addValue(byte[] attrValue)
Adds a
byte[]-formatted value to the attribute. |
void |
addValue(java.lang.Object attrValue) |
void |
addValue(java.lang.String attrValue)
Adds a string value to the attribute.
|
protected void |
addValue(java.lang.String strValue,
byte[] byteValue)
Adds a value to the attribute.
|
protected void |
addValue(java.lang.String strValue,
byte[] byteValue,
boolean avoidCheckDuplicated)
Adds a value to the attribute.
|
void |
addValues(java.lang.String[] arrayStrValue)
add arrray of str to values, each value will be checked for duplicated is
checking is required.
|
boolean |
addValueStrAllowDecodeB64(java.lang.String attrValue)
add string, if base64binary, decode it before adding.
|
void |
clear() |
java.lang.Object |
clone() |
boolean |
contains(byte[] attrValue) |
boolean |
containsIgnoreCase(byte[] attrValue)
return true if value is contained in attribute, check ignore case
|
boolean |
containsIgnoreCase(java.lang.String attrValue)
return true if value is contained in attribute, check ignore case
|
static void |
decrypt(LDAPAttribute attr)
Decrypt attibute
Here is how the decryption works:
1) if the value does not start with "{
|
void |
deleteAllValues() |
static void |
encrypt(LDAPAttribute attr)
Use the deafult/global CryptoManager to encrypt attibute
Here is how encryption works:
1) if the value does start with "{
|
static void |
encrypt(LDAPAttribute attr,
boolean forceNoSalt) |
static void |
encrypt(LDAPAttribute attr,
CryptoManager cm)
Use the given CryptoManager to encrypt attibute
Here is how encryption works:
1) if the value does start with "{
|
static void |
encrypt(LDAPAttribute attr,
CryptoManager cm,
boolean forceNoSalt) |
boolean |
equals(java.lang.Object obj)
- equals attr name (ignore case) - equals values, same order, respect
case
|
static LDAPAttribute |
findLDAPAttribute(LDAPAttribute[] arrayLDAPAttribute,
java.lang.String attrName)
find attribute by its name, return null if not found.
|
protected java.lang.String |
findValueAsStored(java.lang.String attrValue)
returns value as stored, not found returns null.
|
static byte[] |
generateByteValue(java.lang.String valueString) |
static java.lang.String |
generateStringValue(byte[] valueByte) |
java.util.Enumeration<java.lang.Object> |
getAll()
each object returned could be String or byte[] depending on what it was
when orignally added to attribute
|
java.util.List<java.lang.Object> |
getAllValues() |
java.lang.String |
getBaseName()
Extracts the base name from the attribute name of the current
LDAPAttribute object. |
static java.lang.String |
getBaseName(java.lang.String attrName)
Extracts the base name from the specified attribute name.
|
BERElement |
getBERElement()
Retrieves the BER (Basic Encoding Rules) representation of an attribute.
|
byte[][] |
getByteValueArray()
Returns the values of the attribute in an array of
byte[]
format. |
java.lang.Object[] |
getByteValueInObjectArray() |
java.util.Enumeration<byte[]> |
getByteValues()
Returns an enumerator for the values of the attribute in
byte[] format. |
byte[] |
getFirsValueArrayByte()
just return the first value of the result or null if nothing found.
|
java.lang.String |
getFirsValueGUIDString()
returns the first value of the result as GUID formatted String or null if nothing found.
|
java.lang.String |
getFirsValueSIDString()
returns the first value of the result as SID formatted String or null if nothing found.
|
java.lang.String |
getFirsValueString()
just return the first value of the result or null if nothing found.
|
java.lang.String |
getLangSubtype()
Extracts the language subtype from the attribute name of the
LDAPAttribute object, if any. |
java.util.List<byte[]> |
getListValueArrayByte()
return values as a list of byte[] (best perf to retrieve data, return
stored list)
|
java.util.Collection<java.lang.String> |
getListValueString()
return values as a list of String
|
java.util.Collection<java.lang.String> |
getListValueString(boolean lowerCase)
return values as a list of String
|
java.lang.String |
getName()
Returns the name of the attribute.
|
java.util.Set<java.lang.String> |
getOptions() |
java.util.Collection<java.lang.String> |
getSafeCopyListValueString()
return values as a (safe) copied list of String - useful for modifying the values while enumerating them or to safely modify them without affecting the attribute itself
|
java.lang.String |
getStringValue(int index) |
java.lang.String[] |
getStringValueArray()
Returns the values of the attribute as an array of
String
objects. |
java.lang.String[] |
getStringValueArray(boolean tob64) |
java.util.Enumeration<java.lang.String> |
getStringValues()
Returns an enumerator for the string values of an attribute.
|
java.lang.String[] |
getSubtypes()
Extracts the subtypes from the attribute name of the current
LDAPAttribute object. |
static java.lang.String[] |
getSubtypes(java.lang.String attrName)
Extracts the subtypes from the specified attribute name.
|
boolean |
hasSubtype(java.lang.String subtype)
Reports whether the attribute name contains the specified subtype.
|
boolean |
hasSubtypes(java.lang.String[] subtypes)
Reports if the attribute name contains all specified subtypes For
example, if you check for the subtypes
lang-en and
phonetic and the attribute name is
cn;lang-en;phonetic, this method returns true. |
boolean |
isDuplicatedAllowed() |
boolean |
isMultiValued()
more than one value
|
static boolean |
isPrintable(byte[] b)
Returns true if all the bytes in the given array are valid for output as
a String according to the LDIF specification.
|
boolean |
isRangedAttribute() |
boolean |
isString(int index)
return true if attribute found as index was inserted as a string
|
static boolean |
isValidUTF8(byte[] input) |
static boolean |
isValueDuplicate(java.lang.Object[] values) |
static boolean |
isValueDuplicate(java.lang.Object[] values,
boolean caseIgnoreMatch) |
static boolean |
isValueDuplicateIgnoreCase(java.lang.Object[] values) |
static void |
main(java.lang.String[] args) |
void |
mergeAttributeValue(LDAPAttribute attr)
merge current value with value from another attr.
|
void |
mergeAttributeValue(LDAPAttribute attr,
boolean ignoreCase)
merge current value with value from another attr.
|
boolean |
removeValue(byte[] attrValue)
Removes a string value from the attribute.
|
boolean |
removeValue(java.lang.String attrValue)
Removes a string value from the attribute.
|
boolean |
removeValue(java.lang.String strValue,
byte[] byteValue) |
boolean |
removeValueAllowDecodeB64(java.lang.String attrValue)
remove string, if base64binary, decode it before removeing.
|
boolean |
removeValueIgnoreCase(byte[] attrValue)
Removes a value from the attribute by ignoring its case.
|
boolean |
removeValueIgnoreCase(java.lang.String attrValue)
Removes a string value from the attribute.
|
void |
setDuplicatedAllowed(boolean isDuplicatedAllowed) |
void |
setName(java.lang.String attrName) |
void |
setOptions(java.util.Set<java.lang.String> options) |
void |
setString(boolean isString)
consider all attribute as string type
|
void |
setValue(java.lang.String attrValue)
for attr with only one value
|
protected void |
setValues(byte[][] arrayAttrValue)
do not check duplicate
|
void |
setValues(java.util.Collection<byte[]> colAttrValue)
do not check duplicate
|
void |
setValues(java.lang.Object[] arrayAttrValue)
do not check duplicate
|
void |
setValues(java.lang.String[] arrayAttrValue)
do not check duplicate
|
void |
setValues(java.util.Vector<byte[]> vertorOfByteArray)
do not check duplicate all values are considered as binary for meta
analysis
|
static int |
setValuesRange(LDAPAttribute attr,
int minrange,
int maxrange) |
static int |
setValuesRangeAndName(LDAPAttribute attr,
int minrange,
int maxrange) |
void |
setValuesStr(java.util.Collection<java.lang.String> attrValues) |
void |
setValuesStr(java.util.List<java.lang.String> attrValues) |
int |
size()
Returns the number of values of the attribute.
|
java.lang.String |
toOrderedString() |
java.lang.String |
toString()
Retrieves the string representation of an attribute in an LDAP entry.
|
java.lang.String |
toString(java.lang.String entryDn) |
public LDAPAttribute(LDAPAttribute attr)
attr - the attribute to copypublic LDAPAttribute(java.lang.String attrName)
attrName - name of the attributepublic LDAPAttribute(java.lang.String attrName,
boolean isDuplicatedAllowed)
public LDAPAttribute(java.lang.String attrName,
byte[] attrValue)
attrName - name of the attributeattrValue - value of the attribute in byte formatpublic LDAPAttribute(java.lang.String attrName,
byte[][] arrayAttrValue)
attrName - name of the attributearrayAttrValue - values of the attribute in byte formatpublic LDAPAttribute(java.lang.String attrName,
byte[] attrValue,
boolean isDuplicatedAllowed)
public LDAPAttribute(java.lang.String attrName,
java.lang.String attrValue)
attrName - name of the attributeattrValue - value of the attribute in String formatpublic LDAPAttribute(java.lang.String attrName,
java.lang.String attrValue,
boolean isDuplicatedAllowed)
public LDAPAttribute(java.lang.String attrName,
java.lang.Object[] attrValue)
attrName - attrValue - each object could be String or byte[]public LDAPAttribute(java.lang.String attrName,
java.lang.Object[] attrValue,
boolean isDuplicatedAllowed)
public LDAPAttribute(java.lang.String attrName,
java.util.List<java.lang.String> attrValues)
attrName - attrValues - public LDAPAttribute(java.lang.String attrName,
java.util.Collection<byte[]> attrValue)
attrName - attrValue - public LDAPAttribute(java.lang.String attrName,
java.util.Vector<byte[]> attrValue,
boolean isDuplicatedAllowed)
public LDAPAttribute(java.lang.String attrName,
java.lang.String[] attrValues)
attrName - name of the attributeattrValues - the list of string values for this attributepublic LDAPAttribute(java.lang.String attrName,
java.lang.String[] attrValues,
boolean isDuplicatedAllowed)
public LDAPAttribute(BERElement element)
throws java.io.IOException
element - element that you want translated into an attributejava.io.IOException - The attribute could not be created from the specified
element.public int size()
public java.util.Enumeration<java.lang.String> getStringValues()
public java.lang.String[] getStringValueArray()
String
objects.String object.public java.lang.String[] getStringValueArray(boolean tob64)
public java.util.Enumeration<byte[]> getByteValues()
byte[] format.byte[].public java.lang.Object[] getByteValueInObjectArray()
public java.util.List<byte[]> getListValueArrayByte()
public java.util.Collection<java.lang.String> getListValueString()
public java.util.Collection<java.lang.String> getSafeCopyListValueString()
public java.util.Collection<java.lang.String> getListValueString(boolean lowerCase)
lowerCase - put all value Str to lower case. WARNING: value are still
stored as is before lowering case.public byte[][] getByteValueArray()
byte[]
format.byte[].public java.lang.String getName()
public static java.lang.String[] getSubtypes(java.lang.String attrName)
cn;lang-ja;phonetic, this method
returns an array containing lang-ja and
phonetic.
attrName - name of the attribute from which to extract the subtypesLDAPAttribute.getBaseName()public java.lang.String[] getSubtypes()
LDAPAttribute object. For example, if the attribute name is
cn;lang-ja;phonetic, this method returns an array containing
lang-ja and phonetic.
public java.lang.String getLangSubtype()
LDAPAttribute object, if any. For example, if the attribute
name is cn;lang-ja;phonetic, this method returns the String
lang-ja.
public static java.lang.String getBaseName(java.lang.String attrName)
cn;lang-ja;phonetic, this method
returns cn.
attrName - name of the attribute from which to extract the base nameLDAPAttribute.getSubtypes()public java.lang.String getBaseName()
LDAPAttribute object. For example, if the attribute name is
cn;lang-ja;phonetic, this method returns cn.
LDAPAttribute.getSubtypes()public boolean hasSubtype(java.lang.String subtype)
lang-en and the
attribute name is cn;lang-en, this method returns
true.
subtype - the single subtype for which you want to checkLDAPAttribute.getSubtypes()public boolean hasSubtypes(java.lang.String[] subtypes)
lang-en and
phonetic and the attribute name is
cn;lang-en;phonetic, this method returns true.
If the attribute name is cn;phonetic or
cn;lang-en, this method returns false.
subtypes - an array of subtypes to checkLDAPAttribute.getSubtypes()public void addValue(java.lang.String attrValue)
attrValue - the string value to add to the attributepublic void addValue(java.lang.Object attrValue)
public void addValues(java.lang.String[] arrayStrValue)
arrayStrValue - protected void addValue(java.lang.String strValue,
byte[] byteValue)
strValue - byteValue - protected void addValue(java.lang.String strValue,
byte[] byteValue,
boolean avoidCheckDuplicated)
strValue - byteValue - public void addValue(byte[] attrValue)
byte[]-formatted value to the attribute.attrValue - the byte[]-formatted value to add to the
attributepublic boolean contains(byte[] attrValue)
public boolean containsIgnoreCase(byte[] attrValue)
attrValue - public boolean containsIgnoreCase(java.lang.String attrValue)
attrValue - protected java.lang.String findValueAsStored(java.lang.String attrValue)
attrValue - public void setName(java.lang.String attrName)
public void setValue(java.lang.String attrValue)
attrValue - protected void setValues(byte[][] arrayAttrValue)
arrayAttrValue - public void setValues(java.lang.Object[] arrayAttrValue)
arrayAttrValue - each object could be String or byte[]public void setValues(java.lang.String[] arrayAttrValue)
arrayAttrValue - public void setValuesStr(java.util.Collection<java.lang.String> attrValues)
public void setValuesStr(java.util.List<java.lang.String> attrValues)
public void setValues(java.util.Collection<byte[]> colAttrValue)
arrayAttrValue - public void setValues(java.util.Vector<byte[]> vertorOfByteArray)
vertorOfByteArray - public boolean removeValue(java.lang.String attrValue)
attrValue - the string value to removepublic boolean removeValueIgnoreCase(java.lang.String attrValue)
attrValue - the string value to removepublic boolean removeValue(byte[] attrValue)
attrValue - the string value to removepublic boolean removeValueIgnoreCase(byte[] attrValue)
attrValue - the value to removepublic boolean removeValueAllowDecodeB64(java.lang.String attrValue)
attrValue - public boolean removeValue(java.lang.String strValue,
byte[] byteValue)
public BERElement getBERElement()
public java.lang.String toOrderedString()
public static boolean isPrintable(byte[] b)
true if all the bytes in the given array are valid
for output as a String according to the LDIF specification;
otherwise, false.public static boolean isValidUTF8(byte[] input)
public java.lang.String toString()
LDAPAttribute {type='cn', values='Barbara Jensen,Babs Jensen'}
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String entryDn)
public boolean isDuplicatedAllowed()
public static void main(java.lang.String[] args)
public java.lang.String getFirsValueString()
public byte[] getFirsValueArrayByte()
public java.lang.String getFirsValueGUIDString()
public java.lang.String getFirsValueSIDString()
public static LDAPAttribute findLDAPAttribute(LDAPAttribute[] arrayLDAPAttribute, java.lang.String attrName)
arrayLDAPAttribute - attrName - public void deleteAllValues()
public boolean addValueStrAllowDecodeB64(java.lang.String attrValue)
attrValue - public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean isMultiValued()
public void mergeAttributeValue(LDAPAttribute attr)
attr - public void mergeAttributeValue(LDAPAttribute attr, boolean ignoreCase)
attr - ignoreCase - ignoring case.public static java.lang.String generateStringValue(byte[] valueByte)
public static byte[] generateByteValue(java.lang.String valueString)
public void setOptions(java.util.Set<java.lang.String> options)
public java.util.Set<java.lang.String> getOptions()
public void setDuplicatedAllowed(boolean isDuplicatedAllowed)
public java.lang.Object clone()
clone in class java.lang.Objectpublic boolean isString(int index)
index - public java.lang.String getStringValue(int index)
public void clear()
public java.util.Enumeration<java.lang.Object> getAll()
public java.util.List<java.lang.Object> getAllValues()
public void setString(boolean isString)
isString - public static boolean isValueDuplicate(java.lang.Object[] values)
public static boolean isValueDuplicateIgnoreCase(java.lang.Object[] values)
public static boolean isValueDuplicate(java.lang.Object[] values,
boolean caseIgnoreMatch)
public static void encrypt(LDAPAttribute attr) throws LDAPException
attr - the LDAPAttributeforceNoSalt - force the cipher text without saltingLDAPExceptionpublic static void encrypt(LDAPAttribute attr, boolean forceNoSalt) throws LDAPException
LDAPExceptionpublic static void encrypt(LDAPAttribute attr, CryptoManager cm) throws LDAPException
attr - the LDAPAttributeforceNoSalt - force the cipher text without saltingLDAPExceptionpublic static void encrypt(LDAPAttribute attr, CryptoManager cm, boolean forceNoSalt) throws LDAPException
LDAPExceptionpublic static void decrypt(LDAPAttribute attr) throws LDAPException
attr - LDAPExceptionpublic static int setValuesRange(LDAPAttribute attr, int minrange, int maxrange)
public static int setValuesRangeAndName(LDAPAttribute attr, int minrange, int maxrange)
public boolean isRangedAttribute()