com.unboundid.ldap.listener
Class InMemoryRequestHandler

java.lang.Object
  extended by com.unboundid.ldap.listener.LDAPListenerRequestHandler
      extended by com.unboundid.ldap.listener.InMemoryRequestHandler

@Mutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class InMemoryRequestHandler
extends LDAPListenerRequestHandler

This class provides an implementation of an LDAP request handler that can be used to store entries in memory and process operations on those entries. It is primarily intended for use in creating a simple embeddable directory server that can be used for testing purposes. It performs only very basic validation, and is not intended to be a fully standards-compliant server.


Constructor Summary
InMemoryRequestHandler(InMemoryDirectoryServerConfig config)
          Creates a new instance of this request handler with an initially-empty data set.
 
Method Summary
 void addEntries(java.util.List<? extends Entry> entries)
          Attempts to add all of the provided entries to the server.
 void addEntry(Entry entry, boolean ignoreNoUserModification)
          Attempts to add the provided entry to the in-memory data set.
 void assertAttributeExists(java.lang.String dn, java.util.Collection<java.lang.String> attributeNames)
          Ensures that the specified entry exists in the directory with all of the specified attributes.
 void assertAttributeMissing(java.lang.String dn, java.util.Collection<java.lang.String> attributeNames)
          Ensures that the specified entry exists in the directory but does not contain any of the specified attributes.
 void assertEntriesExist(java.util.Collection<java.lang.String> dns)
          Ensures that all of the entries with the provided DNs exist in the directory.
 void assertEntryExists(Entry entry)
          Ensures that an entry exists in the directory with the same DN and all attribute values contained in the provided entry.
 void assertEntryExists(java.lang.String dn)
          Ensures that an entry with the provided DN exists in the directory.
 void assertEntryExists(java.lang.String dn, java.lang.String filter)
          Ensures that an entry with the provided DN exists in the directory.
 void assertEntryMissing(java.lang.String dn)
          Ensures that the specified entry does not exist in the directory.
 void assertValueExists(java.lang.String dn, java.lang.String attributeName, java.util.Collection<java.lang.String> attributeValues)
          Ensures that the specified entry exists in the directory with all of the specified values for the given attribute.
 void assertValueMissing(java.lang.String dn, java.lang.String attributeName, java.util.Collection<java.lang.String> attributeValues)
          Ensures that the specified entry exists in the directory but does not contain any of the specified attribute values.
 void clear()
          Removes all entries currently held in the server.
 int countEntries(boolean includeChangeLog)
          Retrieves the number of entries currently held in the server.
 int countEntriesBelow(java.lang.String baseDN)
          Retrieves the number of entries currently held in the server whose DN matches or is subordinate to the provided base DN.
 InMemoryDirectoryServerSnapshot createSnapshot()
          Creates a point-in-time snapshot of the information contained in this in-memory request handler.
 int deleteSubtree(java.lang.String baseDN)
          Removes the entry with the specified DN and any subordinate entries it may have.
 boolean entryExists(Entry entry)
          Indicates whether the specified entry exists in the server.
 boolean entryExists(java.lang.String dn)
          Indicates whether the specified entry exists in the server.
 boolean entryExists(java.lang.String dn, java.lang.String filter)
          Indicates whether the specified entry exists in the server and matches the given filter.
 int exportToLDIF(LDIFWriter ldifWriter, boolean excludeGeneratedAttrs, boolean excludeChangeLog, boolean closeWriter)
          Writes all entries contained in the server to LDIF using the provided writer.
 java.util.Map<DN,byte[]> getAdditionalBindCredentials()
          Retrieves an unmodifiable map containing the defined set of additional bind credentials, mapped from bind DN to password bytes.
 byte[] getAdditionalBindCredentials(DN dn)
          Retrieves the password for the given DN from the set of additional bind credentials.
 DN getAuthenticatedDN()
          Retrieves the DN of the user currently authenticated on the connection associated with this request handler instance.
 java.util.List<DN> getBaseDNs()
          Retrieves a list of the base DNs configured for use by the server.
 LDAPListenerClientConnection getClientConnection()
          Retrieves the client connection associated with this request handler instance.
 java.util.Map<java.lang.String,java.lang.Object> getConnectionState()
          Retrieves a map that may be used to hold state information specific to the connection associated with this request handler instance.
 DN getDNForAuthzID(java.lang.String authzID)
          Attempts to identify the DN of the user referenced by the provided authorization ID string.
 ReadOnlyEntry getEntry(DN dn)
          Retrieves a read-only representation the entry with the specified DN, if it exists.
 ReadOnlyEntry getEntry(java.lang.String dn)
          Retrieves a read-only representation the entry with the specified DN, if it exists.
 java.util.List<java.lang.String> getMissingAttributeNames(java.lang.String dn, java.util.Collection<java.lang.String> attributeNames)
          Retrieves a list containing all of the named attributes which do not exist in the target entry.
 java.util.List<java.lang.String> getMissingAttributeValues(java.lang.String dn, java.lang.String attributeName, java.util.Collection<java.lang.String> attributeValues)
          Retrieves a list of all provided attribute values which are missing from the specified entry.
 java.util.List<java.lang.String> getMissingEntryDNs(java.util.Collection<java.lang.String> dns)
          Retrieves a list containing the DNs of the entries which are missing from the directory server.
 long getProcessingDelayMillis()
          Retrieves the delay in milliseconds that the server should impose before beginning processing for operations.
 Schema getSchema()
          Retrieves the schema that will be used by the server, if any.
 int importFromLDIF(boolean clear, LDIFReader ldifReader)
          Reads entries from the provided LDIF reader and adds them to the server, optionally clearing any existing entries before beginning to add the new entries.
 void modifyEntry(java.lang.String dn, java.util.List<Modification> mods)
          Attempts to apply the provided set of modifications to the specified entry.
 InMemoryRequestHandler newInstance(LDAPListenerClientConnection connection)
          Creates a new instance of this request handler that will be used to process requests read by the provided connection.
 LDAPMessage processAddRequest(int messageID, AddRequestProtocolOp request, java.util.List<Control> controls)
          Attempts to add an entry to the in-memory data set.
 LDAPMessage processBindRequest(int messageID, BindRequestProtocolOp request, java.util.List<Control> controls)
          Attempts to process the provided bind request.
 LDAPMessage processCompareRequest(int messageID, CompareRequestProtocolOp request, java.util.List<Control> controls)
          Attempts to process the provided compare request.
 LDAPMessage processDeleteRequest(int messageID, DeleteRequestProtocolOp request, java.util.List<Control> controls)
          Attempts to process the provided delete request.
 LDAPMessage processExtendedRequest(int messageID, ExtendedRequestProtocolOp request, java.util.List<Control> controls)
          Attempts to process the provided extended request, if an extended operation handler is defined for the given request OID.
 LDAPMessage processModifyDNRequest(int messageID, ModifyDNRequestProtocolOp request, java.util.List<Control> controls)
          Attempts to process the provided modify DN request.
 LDAPMessage processModifyRequest(int messageID, ModifyRequestProtocolOp request, java.util.List<Control> controls)
          Attempts to process the provided modify request.
 LDAPMessage processSearchRequest(int messageID, SearchRequestProtocolOp request, java.util.List<Control> controls)
          Attempts to process the provided search request.
 void restoreSnapshot(InMemoryDirectoryServerSnapshot snapshot)
          Updates the content of this in-memory request handler to match what it was at the time the snapshot was created.
 java.util.List<ReadOnlyEntry> search(java.lang.String baseDN, SearchScope scope, Filter filter)
          Retrieves a list of all entries in the server which match the given search criteria.
 void setAuthenticatedDN(DN authenticatedDN)
          Sets the DN of the user currently authenticated on the connection associated with this request handler instance.
 void setProcessingDelayMillis(long processingDelayMillis)
          Specifies the delay in milliseconds that the server should impose before beginning processing for operations.
 
Methods inherited from class com.unboundid.ldap.listener.LDAPListenerRequestHandler
closeInstance, processAbandonRequest, processUnbindRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InMemoryRequestHandler

public InMemoryRequestHandler(InMemoryDirectoryServerConfig config)
                       throws LDAPException
Creates a new instance of this request handler with an initially-empty data set.

Parameters:
config - The configuration that should be used for the in-memory directory server.
Throws:
LDAPException - If there is a problem with the provided configuration.
Method Detail

newInstance

public InMemoryRequestHandler newInstance(LDAPListenerClientConnection connection)
                                   throws LDAPException
Creates a new instance of this request handler that will be used to process requests read by the provided connection.

Specified by:
newInstance in class LDAPListenerRequestHandler
Parameters:
connection - The connection with which this request handler instance will be associated.
Returns:
The request handler instance that will be used for the provided connection.
Throws:
LDAPException - If the connection should not be accepted.

createSnapshot

public InMemoryDirectoryServerSnapshot createSnapshot()
Creates a point-in-time snapshot of the information contained in this in-memory request handler. If desired, it may be restored using the restoreSnapshot(com.unboundid.ldap.listener.InMemoryDirectoryServerSnapshot) method.

Returns:
The snapshot created based on the current content of this in-memory request handler.

restoreSnapshot

public void restoreSnapshot(InMemoryDirectoryServerSnapshot snapshot)
Updates the content of this in-memory request handler to match what it was at the time the snapshot was created.

Parameters:
snapshot - The snapshot to be restored. It must not be null.

getSchema

public Schema getSchema()
Retrieves the schema that will be used by the server, if any.

Returns:
The schema that will be used by the server, or null if none has been configured.

getBaseDNs

public java.util.List<DN> getBaseDNs()
Retrieves a list of the base DNs configured for use by the server.

Returns:
A list of the base DNs configured for use by the server.

getClientConnection

public LDAPListenerClientConnection getClientConnection()
Retrieves the client connection associated with this request handler instance.

Returns:
The client connection associated with this request handler instance, or null if this instance is not associated with any client connection.

getAuthenticatedDN

public DN getAuthenticatedDN()
Retrieves the DN of the user currently authenticated on the connection associated with this request handler instance.

Returns:
The DN of the user currently authenticated on the connection associated with this request handler instance, or DN#NULL_DN if the connection is unauthenticated or is authenticated as the anonymous user.

setAuthenticatedDN

public void setAuthenticatedDN(DN authenticatedDN)
Sets the DN of the user currently authenticated on the connection associated with this request handler instance.

Parameters:
authenticatedDN - The DN of the user currently authenticated on the connection associated with this request handler. It may be null or DN.NULL_DN to indicate that the connection is unauthenticated.

getAdditionalBindCredentials

public java.util.Map<DN,byte[]> getAdditionalBindCredentials()
Retrieves an unmodifiable map containing the defined set of additional bind credentials, mapped from bind DN to password bytes.

Returns:
An unmodifiable map containing the defined set of additional bind credentials, or an empty map if no additional credentials have been defined.

getAdditionalBindCredentials

public byte[] getAdditionalBindCredentials(DN dn)
Retrieves the password for the given DN from the set of additional bind credentials.

Parameters:
dn - The DN for which to retrieve the corresponding password.
Returns:
The password bytes for the given DN, or null if the additional bind credentials does not include information for the provided DN.

getConnectionState

public java.util.Map<java.lang.String,java.lang.Object> getConnectionState()
Retrieves a map that may be used to hold state information specific to the connection associated with this request handler instance. It may be queried and updated if necessary to store state information that may be needed at multiple different times in the life of a connection (e.g., when processing a multi-stage SASL bind).

Returns:
An updatable map that may be used to hold state information specific to the connection associated with this request handler instance.

getProcessingDelayMillis

public long getProcessingDelayMillis()
Retrieves the delay in milliseconds that the server should impose before beginning processing for operations.

Returns:
The delay in milliseconds that the server should impose before beginning processing for operations, or 0 if there should be no delay inserted when processing operations.

setProcessingDelayMillis

public void setProcessingDelayMillis(long processingDelayMillis)
Specifies the delay in milliseconds that the server should impose before beginning processing for operations.

Parameters:
processingDelayMillis - The delay in milliseconds that the server should impose before beginning processing for operations. A value less than or equal to zero may be used to indicate that there should be no delay.

processAddRequest

public LDAPMessage processAddRequest(int messageID,
                                     AddRequestProtocolOp request,
                                     java.util.List<Control> controls)
Attempts to add an entry to the in-memory data set. The attempt will fail if any of the following conditions is true:

Specified by:
processAddRequest in class LDAPListenerRequestHandler
Parameters:
messageID - The message ID of the LDAP message containing the add request.
request - The add request that was included in the LDAP message that was received.
controls - The set of controls included in the LDAP message. It may be empty if there were no controls, but will not be null.
Returns:
The LDAPMessage containing the response to send to the client. The protocol op in the LDAPMessage must be an AddResponseProtocolOp.

processBindRequest

public LDAPMessage processBindRequest(int messageID,
                                      BindRequestProtocolOp request,
                                      java.util.List<Control> controls)
Attempts to process the provided bind request. The attempt will fail if any of the following conditions is true:

Specified by:
processBindRequest in class LDAPListenerRequestHandler
Parameters:
messageID - The message ID of the LDAP message containing the bind request.
request - The bind request that was included in the LDAP message that was received.
controls - The set of controls included in the LDAP message. It may be empty if there were no controls, but will not be null.
Returns:
The LDAPMessage containing the response to send to the client. The protocol op in the LDAPMessage must be a BindResponseProtocolOp.

processCompareRequest

public LDAPMessage processCompareRequest(int messageID,
                                         CompareRequestProtocolOp request,
                                         java.util.List<Control> controls)
Attempts to process the provided compare request. The attempt will fail if any of the following conditions is true:

Specified by:
processCompareRequest in class LDAPListenerRequestHandler
Parameters:
messageID - The message ID of the LDAP message containing the compare request.
request - The compare request that was included in the LDAP message that was received.
controls - The set of controls included in the LDAP message. It may be empty if there were no controls, but will not be null.
Returns:
The LDAPMessage containing the response to send to the client. The protocol op in the LDAPMessage must be a CompareResponseProtocolOp.

processDeleteRequest

public LDAPMessage processDeleteRequest(int messageID,
                                        DeleteRequestProtocolOp request,
                                        java.util.List<Control> controls)
Attempts to process the provided delete request. The attempt will fail if any of the following conditions is true:

Specified by:
processDeleteRequest in class LDAPListenerRequestHandler
Parameters:
messageID - The message ID of the LDAP message containing the delete request.
request - The delete request that was included in the LDAP message that was received.
controls - The set of controls included in the LDAP message. It may be empty if there were no controls, but will not be null.
Returns:
The LDAPMessage containing the response to send to the client. The protocol op in the LDAPMessage must be a DeleteResponseProtocolOp.

processExtendedRequest

public LDAPMessage processExtendedRequest(int messageID,
                                          ExtendedRequestProtocolOp request,
                                          java.util.List<Control> controls)
Attempts to process the provided extended request, if an extended operation handler is defined for the given request OID.

Specified by:
processExtendedRequest in class LDAPListenerRequestHandler
Parameters:
messageID - The message ID of the LDAP message containing the extended request.
request - The extended request that was included in the LDAP message that was received.
controls - The set of controls included in the LDAP message. It may be empty if there were no controls, but will not be null.
Returns:
The LDAPMessage containing the response to send to the client. The protocol op in the LDAPMessage must be an ExtendedResponseProtocolOp.

processModifyRequest

public LDAPMessage processModifyRequest(int messageID,
                                        ModifyRequestProtocolOp request,
                                        java.util.List<Control> controls)
Attempts to process the provided modify request. The attempt will fail if any of the following conditions is true:

Specified by:
processModifyRequest in class LDAPListenerRequestHandler
Parameters:
messageID - The message ID of the LDAP message containing the modify request.
request - The modify request that was included in the LDAP message that was received.
controls - The set of controls included in the LDAP message. It may be empty if there were no controls, but will not be null.
Returns:
The LDAPMessage containing the response to send to the client. The protocol op in the LDAPMessage must be an ModifyResponseProtocolOp.

processModifyDNRequest

public LDAPMessage processModifyDNRequest(int messageID,
                                          ModifyDNRequestProtocolOp request,
                                          java.util.List<Control> controls)
Attempts to process the provided modify DN request. The attempt will fail if any of the following conditions is true:

Specified by:
processModifyDNRequest in class LDAPListenerRequestHandler
Parameters:
messageID - The message ID of the LDAP message containing the modify DN request.
request - The modify DN request that was included in the LDAP message that was received.
controls - The set of controls included in the LDAP message. It may be empty if there were no controls, but will not be null.
Returns:
The LDAPMessage containing the response to send to the client. The protocol op in the LDAPMessage must be an ModifyDNResponseProtocolOp.

processSearchRequest

public LDAPMessage processSearchRequest(int messageID,
                                        SearchRequestProtocolOp request,
                                        java.util.List<Control> controls)
Attempts to process the provided search request. The attempt will fail if any of the following conditions is true:

Specified by:
processSearchRequest in class LDAPListenerRequestHandler
Parameters:
messageID - The message ID of the LDAP message containing the search request.
request - The search request that was included in the LDAP message that was received.
controls - The set of controls included in the LDAP message. It may be empty if there were no controls, but will not be null.
Returns:
The LDAPMessage containing the response to send to the client. The protocol op in the LDAPMessage must be an SearchResultDoneProtocolOp.

countEntries

public int countEntries(boolean includeChangeLog)
Retrieves the number of entries currently held in the server.

Parameters:
includeChangeLog - Indicates whether to include entries that are part of the changelog in the count.
Returns:
The number of entries currently held in the server.

countEntriesBelow

public int countEntriesBelow(java.lang.String baseDN)
                      throws LDAPException
Retrieves the number of entries currently held in the server whose DN matches or is subordinate to the provided base DN.

Parameters:
baseDN - The base DN to use for the determination.
Returns:
The number of entries currently held in the server whose DN matches or is subordinate to the provided base DN.
Throws:
LDAPException - If the provided string cannot be parsed as a valid DN.

clear

public void clear()
Removes all entries currently held in the server. If a changelog is enabled, then all changelog entries will also be cleared but the base "cn=changelog" entry will be retained.


importFromLDIF

public int importFromLDIF(boolean clear,
                          LDIFReader ldifReader)
                   throws LDAPException
Reads entries from the provided LDIF reader and adds them to the server, optionally clearing any existing entries before beginning to add the new entries. If an error is encountered while adding entries from LDIF then the server will remain populated with the data it held before the import attempt (even if the clear is given with a value of true).

Parameters:
clear - Indicates whether to remove all existing entries prior to adding entries read from LDIF.
ldifReader - The LDIF reader to use to obtain the entries to be imported.
Returns:
The number of entries read from LDIF and added to the server.
Throws:
LDAPException - If a problem occurs while reading entries or adding them to the server.

exportToLDIF

public int exportToLDIF(LDIFWriter ldifWriter,
                        boolean excludeGeneratedAttrs,
                        boolean excludeChangeLog,
                        boolean closeWriter)
                 throws LDAPException
Writes all entries contained in the server to LDIF using the provided writer.

Parameters:
ldifWriter - The LDIF writer to use when writing the entries. It must not be null.
excludeGeneratedAttrs - Indicates whether to exclude automatically generated operational attributes like entryUUID, entryDN, creatorsName, etc.
excludeChangeLog - Indicates whether to exclude entries contained in the changelog.
closeWriter - Indicates whether the LDIF writer should be closed after all entries have been written.
Returns:
The number of entries written to LDIF.
Throws:
LDAPException - If a problem is encountered while attempting to write an entry to LDIF.

addEntry

public void addEntry(Entry entry,
                     boolean ignoreNoUserModification)
              throws LDAPException
Attempts to add the provided entry to the in-memory data set. The attempt will fail if any of the following conditions is true:

Parameters:
entry - The entry to be added. It must not be null.
ignoreNoUserModification - Indicates whether to ignore constraints normally imposed by the NO-USER-MODIFICATION element in attribute type definitions.
Throws:
LDAPException - If a problem occurs while attempting to add the provided entry.

addEntries

public void addEntries(java.util.List<? extends Entry> entries)
                throws LDAPException
Attempts to add all of the provided entries to the server. If an error is encountered during processing, then the contents of the server will be the same as they were before this method was called.

Parameters:
entries - The collection of entries to be added.
Throws:
LDAPException - If a problem was encountered while attempting to add any of the entries to the server.

deleteSubtree

public int deleteSubtree(java.lang.String baseDN)
                  throws LDAPException
Removes the entry with the specified DN and any subordinate entries it may have.

Parameters:
baseDN - The DN of the entry to be deleted. It must not be null or represent the null DN.
Returns:
The number of entries actually removed, or zero if the specified base DN does not represent an entry in the server.
Throws:
LDAPException - If the provided base DN is not a valid DN, or is the DN of an entry that cannot be deleted (e.g., the null DN).

modifyEntry

public void modifyEntry(java.lang.String dn,
                        java.util.List<Modification> mods)
                 throws LDAPException
Attempts to apply the provided set of modifications to the specified entry. The attempt will fail if any of the following conditions is true:

Parameters:
dn - The DN of the entry to be modified.
mods - The set of modifications to be applied to the entry.
Throws:
LDAPException - If a problem is encountered while attempting to update the specified entry.

getEntry

public ReadOnlyEntry getEntry(java.lang.String dn)
                       throws LDAPException
Retrieves a read-only representation the entry with the specified DN, if it exists.

Parameters:
dn - The DN of the entry to retrieve.
Returns:
The requested entry, or null if no entry exists with the given DN.
Throws:
LDAPException - If the provided DN is malformed.

getEntry

public ReadOnlyEntry getEntry(DN dn)
Retrieves a read-only representation the entry with the specified DN, if it exists.

Parameters:
dn - The DN of the entry to retrieve.
Returns:
The requested entry, or null if no entry exists with the given DN.

search

public java.util.List<ReadOnlyEntry> search(java.lang.String baseDN,
                                            SearchScope scope,
                                            Filter filter)
                                     throws LDAPException
Retrieves a list of all entries in the server which match the given search criteria.

Parameters:
baseDN - The base DN to use for the search. It must not be null.
scope - The scope to use for the search. It must not be null.
filter - The filter to use for the search. It must not be null.
Returns:
A list of the entries that matched the provided search criteria.
Throws:
LDAPException - If a problem is encountered while performing the search.

getDNForAuthzID

public DN getDNForAuthzID(java.lang.String authzID)
                   throws LDAPException
Attempts to identify the DN of the user referenced by the provided authorization ID string. It may be "dn:" followed by the target DN, or "u:" followed by the value of the uid attribute in the entry. If it uses the "dn:" form, then it may reference the DN of a regular entry or a DN in the configured set of additional bind credentials.

Parameters:
authzID - The authorization ID to resolve to a user DN.
Returns:
The DN identified for the provided authorization ID.
Throws:
LDAPException - If a problem prevents resolving the authorization ID to a user DN.

entryExists

public boolean entryExists(java.lang.String dn)
                    throws LDAPException
Indicates whether the specified entry exists in the server.

Parameters:
dn - The DN of the entry for which to make the determination.
Returns:
true if the entry exists, or false if not.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.

entryExists

public boolean entryExists(java.lang.String dn,
                           java.lang.String filter)
                    throws LDAPException
Indicates whether the specified entry exists in the server and matches the given filter.

Parameters:
dn - The DN of the entry for which to make the determination.
filter - The filter the entry is expected to match.
Returns:
true if the entry exists and matches the specified filter, or false if not.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.

entryExists

public boolean entryExists(Entry entry)
                    throws LDAPException
Indicates whether the specified entry exists in the server. This will return true only if the target entry exists and contains all values for all attributes of the provided entry. The entry will be allowed to have attribute values not included in the provided entry.

Parameters:
entry - The entry to compare against the directory server.
Returns:
true if the entry exists in the server and is a superset of the provided entry, or false if not.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.

assertEntryExists

public void assertEntryExists(java.lang.String dn)
                       throws LDAPException,
                              java.lang.AssertionError
Ensures that an entry with the provided DN exists in the directory.

Parameters:
dn - The DN of the entry for which to make the determination.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If the target entry does not exist.

assertEntryExists

public void assertEntryExists(java.lang.String dn,
                              java.lang.String filter)
                       throws LDAPException,
                              java.lang.AssertionError
Ensures that an entry with the provided DN exists in the directory.

Parameters:
dn - The DN of the entry for which to make the determination.
filter - A filter that the target entry must match.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If the target entry does not exist or does not match the provided filter.

assertEntryExists

public void assertEntryExists(Entry entry)
                       throws LDAPException,
                              java.lang.AssertionError
Ensures that an entry exists in the directory with the same DN and all attribute values contained in the provided entry. The server entry may contain additional attributes and/or attribute values not included in the provided entry.

Parameters:
entry - The entry expected to be present in the directory server.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If the target entry does not exist or does not match the provided filter.

getMissingEntryDNs

public java.util.List<java.lang.String> getMissingEntryDNs(java.util.Collection<java.lang.String> dns)
                                                    throws LDAPException
Retrieves a list containing the DNs of the entries which are missing from the directory server.

Parameters:
dns - The DNs of the entries to try to find in the server.
Returns:
A list containing all of the provided DNs that were not found in the server, or an empty list if all entries were found.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.

assertEntriesExist

public void assertEntriesExist(java.util.Collection<java.lang.String> dns)
                        throws LDAPException,
                               java.lang.AssertionError
Ensures that all of the entries with the provided DNs exist in the directory.

Parameters:
dns - The DNs of the entries for which to make the determination.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If any of the target entries does not exist.

getMissingAttributeNames

public java.util.List<java.lang.String> getMissingAttributeNames(java.lang.String dn,
                                                                 java.util.Collection<java.lang.String> attributeNames)
                                                          throws LDAPException
Retrieves a list containing all of the named attributes which do not exist in the target entry.

Parameters:
dn - The DN of the entry to examine.
attributeNames - The names of the attributes expected to be present in the target entry.
Returns:
A list containing the names of the attributes which were not present in the target entry, an empty list if all specified attributes were found in the entry, or null if the target entry does not exist.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.

assertAttributeExists

public void assertAttributeExists(java.lang.String dn,
                                  java.util.Collection<java.lang.String> attributeNames)
                           throws LDAPException,
                                  java.lang.AssertionError
Ensures that the specified entry exists in the directory with all of the specified attributes.

Parameters:
dn - The DN of the entry to examine.
attributeNames - The names of the attributes that are expected to be present in the provided entry.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If the target entry does not exist or does not contain all of the specified attributes.

getMissingAttributeValues

public java.util.List<java.lang.String> getMissingAttributeValues(java.lang.String dn,
                                                                  java.lang.String attributeName,
                                                                  java.util.Collection<java.lang.String> attributeValues)
                                                           throws LDAPException
Retrieves a list of all provided attribute values which are missing from the specified entry. The target attribute may or may not contain additional values.

Parameters:
dn - The DN of the entry to examine.
attributeName - The attribute expected to be present in the target entry with the given values.
attributeValues - The values expected to be present in the target entry.
Returns:
A list containing all of the provided values which were not found in the entry, an empty list if all provided attribute values were found, or null if the target entry does not exist.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.

assertValueExists

public void assertValueExists(java.lang.String dn,
                              java.lang.String attributeName,
                              java.util.Collection<java.lang.String> attributeValues)
                       throws LDAPException,
                              java.lang.AssertionError
Ensures that the specified entry exists in the directory with all of the specified values for the given attribute. The attribute may or may not contain additional values.

Parameters:
dn - The DN of the entry to examine.
attributeName - The name of the attribute to examine.
attributeValues - The set of values which must exist for the given attribute.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If the target entry does not exist, does not contain the specified attribute, or that attribute does not have all of the specified values.

assertEntryMissing

public void assertEntryMissing(java.lang.String dn)
                        throws LDAPException,
                               java.lang.AssertionError
Ensures that the specified entry does not exist in the directory.

Parameters:
dn - The DN of the entry expected to be missing.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If the target entry is found in the server.

assertAttributeMissing

public void assertAttributeMissing(java.lang.String dn,
                                   java.util.Collection<java.lang.String> attributeNames)
                            throws LDAPException,
                                   java.lang.AssertionError
Ensures that the specified entry exists in the directory but does not contain any of the specified attributes.

Parameters:
dn - The DN of the entry expected to be present.
attributeNames - The names of the attributes expected to be missing from the entry.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If the target entry is missing from the server, or if it contains any of the target attributes.

assertValueMissing

public void assertValueMissing(java.lang.String dn,
                               java.lang.String attributeName,
                               java.util.Collection<java.lang.String> attributeValues)
                        throws LDAPException,
                               java.lang.AssertionError
Ensures that the specified entry exists in the directory but does not contain any of the specified attribute values.

Parameters:
dn - The DN of the entry expected to be present.
attributeName - The name of the attribute to examine.
attributeValues - The values expected to be missing from the target entry.
Throws:
LDAPException - If a problem is encountered while trying to communicate with the directory server.
java.lang.AssertionError - If the target entry is missing from the server, or if it contains any of the target attribute values.