public class LDAPEntry
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String[] |
DEFAULT_IGNORED_ATTR |
protected static java.util.Set<java.lang.String> |
DEFAULT_IGNORED_ATTR_SET |
| Constructor and Description |
|---|
LDAPEntry()
Constructs an empty entry.
|
LDAPEntry(java.lang.String distinguishedName)
Constructs a new entry with the specified distinguished name and with an
empty attribute set.
|
LDAPEntry(java.lang.String distinguishedName,
LDAPAttributeSet attrs)
Constructs a new entry with the specified distinguished name and set of
attributes.
|
| Modifier and Type | Method and Description |
|---|---|
static java.util.Set<java.lang.String> |
buildValidIgnoredAttributesForNormalization(java.lang.String[] customAttributes,
boolean addDefaults)
Build a valid
HashSet to pass to
setIgnoredAttributesForNormalization |
static LDAPEntry |
byteArrayToEntry(byte[] buf) |
java.lang.Object |
byteArrayToObject(byte[] buf,
int offset)
Constacted by CustomerizedSerializable interface.
|
java.lang.Object |
clone() |
int |
compare(LDAPEntry e2)
Compare the entry with an other one, and return byte-to-byte
hash-fingerprint comparison.
|
static int |
compare(LDAPEntry e1,
LDAPEntry e2)
Compare 2 entries regarding their content.
compare(e1,e2)==0 is equivalent to
e1.equals(e2). |
static LDAPModification[] |
compareAttributes(LDAPEntry oldInstance,
LDAPEntry newInstance)
Compare 2 versions (old and new) of one entry.
Case sensitive comparison. |
static LDAPModification[] |
compareAttributes(LDAPEntry oldInstance,
LDAPEntry newInstance,
boolean ignoreCase)
Same as
compareAttributes(LDAPEntry, LDAPEntry) with the ignoreCase option |
static boolean |
containsRangedAttribute(LDAPEntry entry,
java.lang.String attrName) |
static void |
decrypt(LDAPEntry entry,
java.util.Collection<java.lang.String> attrNames) |
static void |
encrypt(LDAPEntry entry,
java.util.Collection<java.lang.String> attrNames) |
static void |
encrypt(LDAPEntry entry,
java.util.Collection<java.lang.String> attrNames,
boolean forceNoSalt) |
boolean |
equals(LDAPEntry e2)
Test equivalence of content, based on hash-fingerprint.
|
LDAPAttribute |
getAttribute(java.lang.String attrName)
In an entry, returns the single attribute that exactly matches the
specified attribute name.
|
LDAPAttributeSet |
getAttributeSet()
Returns the attribute set of the entry.
|
java.lang.String |
getDN()
Returns the distinguished name of the current entry.
|
byte[] |
getHash()
Gets the MD5-hash(aka fingerprint) of the entry.
|
byte[] |
getHash(boolean reCompute)
Gets the MD5-hash(aka fingerprint) of the entry.
|
byte[] |
getHash(boolean reCompute,
java.lang.String algorithm)
Gets the hash(aka fingerprint) of the entry.
|
LDAPDN |
getLDAPDN() |
void |
setDN(java.lang.String name) |
void |
setIgnoredAttributesForNormalization(java.util.Set<java.lang.String> IgnoredAttributesSet)
Define the set of attributes to ignore before computing the
hash-fingerprint of the entry.
|
byte[] |
toByteArray()
Constacted by CustomerizedSerializable interface.
|
byte[] |
toByteArray(boolean normalize)
Constacted by CustomerizedSerializable interface.
|
java.lang.String |
toLDIF()
Gets the LDAPEntry in LDIF format.
|
java.lang.String |
toOrderedString() |
java.lang.String |
toString()
Retrieves the string representation of the entry's distinguished name
(DN) and its attributes.
|
protected static final java.lang.String[] DEFAULT_IGNORED_ATTR
protected static java.util.Set<java.lang.String> DEFAULT_IGNORED_ATTR_SET
public LDAPEntry()
public LDAPEntry(java.lang.String distinguishedName)
distinguishedName - the distinguished name of the new entrypublic LDAPEntry(java.lang.String distinguishedName,
LDAPAttributeSet attrs)
distinguishedName - the distinguished name of the new entryattrs - the set of attributes to assign to the new entryLDAPAttributeSetpublic java.lang.String getDN()
public void setDN(java.lang.String name)
public LDAPDN getLDAPDN() throws LDAPException
LDAPExceptionpublic LDAPAttributeSet getAttributeSet()
LDAPAttributeSetpublic LDAPAttribute getAttribute(java.lang.String attrName)
attrName - name of attribute to return For example:
"cn" // Only a non-subtyped version of cn
"cn;lang-ja" // Only a Japanese version of cn, will not
// return "cn;lang-ja-JP-kanji", for example
LDAPAttributepublic byte[] getHash()
WARNING : if hashkey has aready been computed and the entry has changed since, getHash() will not be accurate as it will return the previous hashkey ; use getHash(reCompute=true) instead.
Building of a consistent hashkey relies on the possibility to get a
unique and relevant representation of the entry. getHash
functions takes the unique Byte representation built by
toByteArray(normalize=true) and pass it to a hashing
function (default : MD5). In order to normalize an entry, some attributes
must be ignored. Server attributes, such as
'cacheCreateTimestamp' are indeed irrelevant in the process
of fingerprinting the entry. A default static set of ignored attribute is
built when toByteArray method is called, only if no custom
set is previously defined. To define a custom set, you can use
buildValidIgnoredAttributesForNormalization to build a valid
HashSet, then pass it to every entry by calling
setIgnoredAttributesForNormalization BEFORE calling
getHash.
setIgnoredAttributesForNormalization,
MessageDigestpublic byte[] getHash(boolean reCompute)
reCompute==true.
WARNING: if reCompute=false and hash has not been computed yet, or entry has changed since, the hash returned will not be accurate (null or wrong).
Building of a consistent hashkey relies on the possibility to get a
unique and relevant representation of the entry. getHash
functions takes the unique Byte representation built by
toByteArray(normalize=true) and pass it to a hashing
function (default : MD5). In order to normalize an entry, some attributes
must be ignored. Server attributes, such as
'cacheCreateTimestamp' are indeed irrelevant in the process
of fingerprinting the entry. A default static set of ignored attribute is
built when toByteArray method is called, only if no custom
set is previously defined. To define a custom set, you can use
buildValidIgnoredAttributesForNormalization to build a valid
HashSet, then pass it to every entry by calling
setIgnoredAttributesForNormalization BEFORE calling
getHash.
reCompute - : true to re-compute it, false to
get it as-issetIgnoredAttributesForNormalization,
MessageDigestpublic byte[] getHash(boolean reCompute,
java.lang.String algorithm)
reCompute==true.
WARNING: if reCompute=false and hash has not been computed yet, or entry has changed since, the hash returned will not be accurate -> null or wrong.
Building of a consistent hashkey relies on the possibility to get a
unique and relevant representation of the entry. getHash
functions takes the unique Byte representation built by
toByteArray(normalize=true) and pass it to a hashing
function (default : MD5). In order to normalize an entry, some attributes
must be ignored. Server attributes, such as
'cacheCreateTimestamp' are indeed irrelevant in the process
of fingerprinting the entry. A default static set of ignored attribute is
built when toByteArray method is called, only if no custom
set is previously defined. To define a custom set, you can use
buildValidIgnoredAttributesForNormalization to build a valid
HashSet, then pass it to every entry by calling
setIgnoredAttributesForNormalization BEFORE calling
getHash.
reCompute - : true to re-compute it, false to
get it as-isalgorithm - : the name of the algorithm requested, use MessageDigest.
"MD5" or "SHA-256" are recommended. In case of
NoSuchAlgorithmException, this method will use MD5 instead.setIgnoredAttributesForNormalization,
MessageDigestpublic static int compare(LDAPEntry e1, LDAPEntry e2)
compare(e1,e2)==0 is equivalent to
e1.equals(e2).
Comparison is based on content hashing. Efficient sorting is achieved if every entry has pre-computed hash.
com.rli.slapd.server.LDAPEntry.getHash()public static LDAPModification[] compareAttributes(LDAPEntry oldInstance, LDAPEntry newInstance)
compareAttributes(LDAPEntry, LDAPEntry, boolean) to force ignoreCase.
Returns an Array of LDAPModification that leads from the old state to the
new state of the entry.oldInstance - original state of the entrynewInstance - following state of the entrypublic static LDAPModification[] compareAttributes(LDAPEntry oldInstance, LDAPEntry newInstance, boolean ignoreCase)
compareAttributes(LDAPEntry, LDAPEntry) with the ignoreCase optionpublic int compare(LDAPEntry e2)
e2 - public boolean equals(LDAPEntry e2)
e2 - public void setIgnoredAttributesForNormalization(java.util.Set<java.lang.String> IgnoredAttributesSet)
WARNING: The ignored attributes set MUST contain only lower case, as
lower case representations of attributes names will be directly compared
to the elements of this set. Use
buildValidIgnoredAttributesForNormalization for safety.
public static java.util.Set<java.lang.String> buildValidIgnoredAttributesForNormalization(java.lang.String[] customAttributes,
boolean addDefaults)
HashSet to pass to
setIgnoredAttributesForNormalizationcustomAttributes - array of attributes to be ignoredaddDefaults - set to true to ignore both default and custom
ignoredAttributespublic java.lang.String toString()
LDAPEntry: uid=bjensen, ou=People, o=airius.com; LDAPAttributeSet:
LDAPAttribute {type='cn', values='Barbara Jensen,Babs Jensen'}
LDAPAttribute {type='sn', values='Jensen'}LDAPAttribute {type='givenname',
values='Barbara'}LDAPAttribute {type='objectclass', values='top,person,
organizationalPerson,inetOrgPerson'}LDAPAttribute {type='ou',
values='Product Development,People'}
toString in class java.lang.Objectpublic java.lang.String toOrderedString()
public byte[] toByteArray()
throws java.io.IOException
this object [BPage] into a binary presentation which can
then be decoded by the corresponding decoder
byteArrayToObjectjava.io.IOExceptionpublic byte[] toByteArray(boolean normalize)
throws java.io.IOException
this object [BPage] into a binary presentation which can
then be decoded by the corresponding decoder
byteArrayToObjectnormalize - true to compute a normalized representation of
the entry. Ignores unrelevant/inconsistent attributes defined
by setIgnoredAttributesForNormalization.java.io.IOExceptionsetIgnoredAttributesForNormalizationpublic java.lang.Object byteArrayToObject(byte[] buf,
int offset)
throws java.io.IOException
java.io.IOExceptionpublic static LDAPEntry byteArrayToEntry(byte[] buf) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toLDIF()
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic static void encrypt(LDAPEntry entry, java.util.Collection<java.lang.String> attrNames) throws LDAPException
entry - -- the entryattrNames - -- the Collection of attributes which should be encryptedforceNoSalt - force the cipher text without saltingLDAPExceptionLDAPAttribute.encrypt()public static void encrypt(LDAPEntry entry, java.util.Collection<java.lang.String> attrNames, boolean forceNoSalt) throws LDAPException
LDAPExceptionpublic static void decrypt(LDAPEntry entry, java.util.Collection<java.lang.String> attrNames) throws LDAPException
entry - -- the entryattrNames - -- the Collection of attributes which could be encrypted;
if null, all attributes will be scanned.LDAPExceptionLDAPAttribute.decrypt()public static boolean containsRangedAttribute(LDAPEntry entry, java.lang.String attrName)
entry - The LDAPEntry to be checkedattrName - The name of attribute which may be ranged; null if any attribute name