@Mutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class InMemoryDirectoryServer extends java.lang.Object implements FullLDAPInterface
FullLDAPInterface
interface, which means that
in many cases it can be used as a drop-in replacement for an
LDAPConnection
.InMemoryDirectoryServerConfig
object with the desired
settings. Then use that configuration object to initialize the directory
server instance, and call the startListening()
method to start
accepting connections from LDAP clients. The getConnection()
and
getConnectionPool(int)
methods may be used to obtain connections to the
server and you can also manually create connections using the information
obtained via the getListenAddress()
, getListenPort()
, and
getClientSocketFactory()
methods. When the server is no longer
needed, the shutDown(boolean)
method should be used to stop the server. Any
number of in-memory directory server instances can be created and running in
a single JVM at any time, and many of the methods provided in this class can
be used without the server running if operations are to be performed using
only method calls rather than via LDAP clients.
// Create a base configuration for the server. InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=com"); config.addAdditionalBindCredentials("cn=Directory Manager", "password"); // Update the configuration to support LDAP (with StartTLS) and LDAPS // listeners. final SSLUtil serverSSLUtil = new SSLUtil( new KeyStoreKeyManager(serverKeyStorePath, serverKeyStorePIN, "JKS", "server-cert"), new TrustStoreTrustManager(serverTrustStorePath)); final SSLUtil clientSSLUtil = new SSLUtil( new TrustStoreTrustManager(clientTrustStorePath)); config.setListenerConfigs( InMemoryListenerConfig.createLDAPConfig("LDAP", // Listener name null, // Listen address. (null = listen on all interfaces) 0, // Listen port (0 = automatically choose an available port) serverSSLUtil.createSSLSocketFactory()), // StartTLS factory InMemoryListenerConfig.createLDAPSConfig("LDAPS", // Listener name null, // Listen address. (null = listen on all interfaces) 0, // Listen port (0 = automatically choose an available port) serverSSLUtil.createSSLServerSocketFactory(), // Server factory clientSSLUtil.createSSLSocketFactory())); // Client factory // Create and start the server instance and populate it with an initial set // of data from an LDIF file. InMemoryDirectoryServer server = new InMemoryDirectoryServer(config); server.importFromLDIF(true, ldifFilePath); // Start the server so it will accept client connections. server.startListening(); // Get an unencrypted connection to the server's LDAP listener, then use // StartTLS to secure that connection. Make sure the connection is usable // by retrieving the server root DSE. LDAPConnection connection = server.getConnection("LDAP"); connection.processExtendedOperation(new StartTLSExtendedRequest( clientSSLUtil.createSSLContext())); LDAPTestUtils.assertEntryExists(connection, ""); connection.close(); // Establish an SSL-based connection to the LDAPS listener, and make sure // that connection is also usable. connection = server.getConnection("LDAPS"); LDAPTestUtils.assertEntryExists(connection, ""); connection.close(); // Shut down the server so that it will no longer accept client // connections, and close all existing connections. server.shutDown(true);
Constructor and Description |
---|
InMemoryDirectoryServer(InMemoryDirectoryServerConfig cfg)
Creates a new instance of an in-memory directory server with the provided
configuration.
|
InMemoryDirectoryServer(java.lang.String... baseDNs)
Creates a very simple instance of an in-memory directory server with the
specified set of base DNs.
|
Modifier and Type | Method and Description |
---|---|
LDAPResult |
add(AddRequest addRequest)
Processes the provided add request.
|
LDAPResult |
add(Entry entry)
Processes an add operation with the provided information.
|
LDAPResult |
add(ReadOnlyAddRequest addRequest)
Processes the provided add request.
|
LDAPResult |
add(java.lang.String... ldifLines)
Processes an add operation with the provided information.
|
LDAPResult |
add(java.lang.String dn,
Attribute... attributes)
Processes an add operation with the provided information.
|
LDAPResult |
add(java.lang.String dn,
java.util.Collection<Attribute> attributes)
Processes an add operation with the provided information.
|
void |
addEntries(Entry... entries)
Attempts to add all of the provided entries to the server.
|
void |
addEntries(java.util.List<? extends Entry> entries)
Attempts to add all of the provided entries to the server.
|
void |
addEntries(java.lang.String... ldifEntryLines)
Attempts to add a set of entries provided in LDIF form in which each
element of the provided array is a line of the LDIF representation, with
empty strings as separators between entries (as you would have for blank
lines in an LDIF file).
|
int |
applyChangesFromLDIF(java.io.File ldifFile)
Reads LDIF change records from the specified LDIF file and applies them
to the data in the server.
|
int |
applyChangesFromLDIF(LDIFReader reader)
Reads LDIF change records from the provided LDIF reader file and applies
them to the data in the server.
|
int |
applyChangesFromLDIF(java.lang.String path)
Reads LDIF change records from the specified LDIF file and applies them
to the data in the server.
|
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 |
assertAttributeExists(java.lang.String dn,
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 |
assertAttributeMissing(java.lang.String dn,
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 |
assertEntriesExist(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 |
assertValueExists(java.lang.String dn,
java.lang.String attributeName,
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 |
assertValueMissing(java.lang.String dn,
java.lang.String attributeName,
java.lang.String... attributeValues)
Ensures that the specified entry exists in the directory but does not
contain any of the specified attribute values.
|
BindResult |
bind(BindRequest bindRequest)
Processes the provided bind request.
|
BindResult |
bind(java.lang.String bindDN,
java.lang.String password)
Processes a simple bind request with the provided DN and password.
|
void |
clear()
Removes all entries currently held in the server.
|
void |
close()
Closes the associated interface and frees any resources associated with it.
|
void |
closeAllConnections(boolean sendNoticeOfDisconnection)
Closes all connections that are currently established to the server.
|
CompareResult |
compare(CompareRequest compareRequest)
Processes the provided compare request.
|
CompareResult |
compare(ReadOnlyCompareRequest compareRequest)
Processes the provided compare request.
|
CompareResult |
compare(java.lang.String dn,
java.lang.String attributeName,
java.lang.String assertionValue)
Processes a compare operation with the provided information.
|
int |
countEntries()
Retrieves the number of entries currently held in the server.
|
int |
countEntries(boolean includeChangeLog)
Retrieves the number of entries currently held in the server, optionally
including those entries which are part of the changelog.
|
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 directory server instance.
|
LDAPResult |
delete(DeleteRequest deleteRequest)
Processes the provided delete request.
|
LDAPResult |
delete(ReadOnlyDeleteRequest deleteRequest)
Processes the provided delete request.
|
LDAPResult |
delete(java.lang.String dn)
Deletes the entry with the specified DN.
|
int |
deleteSubtree(java.lang.String baseDN)
Attempts to delete the specified entry and all entries below it from the
server.
|
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 the current contents of the server in LDIF form using the provided
LDIF writer.
|
int |
exportToLDIF(java.lang.String path,
boolean excludeGeneratedAttrs,
boolean excludeChangeLog)
Writes the current contents of the server in LDIF form to the specified
file.
|
java.util.List<InMemoryPasswordEncoder> |
getAllPasswordEncoders()
Retrieves a list of all password encoders configured for the server.
|
java.util.List<DN> |
getBaseDNs()
Retrieves the list of base DNs configured for use by the server.
|
javax.net.SocketFactory |
getClientSocketFactory()
Retrieves the configured client socket factory for the first active
listener.
|
javax.net.SocketFactory |
getClientSocketFactory(java.lang.String listenerName)
Retrieves the configured client socket factory for the specified listener,
if available.
|
ReadOnlyInMemoryDirectoryServerConfig |
getConfig()
Retrieves a read-only representation of the configuration used to create
this in-memory directory server instance.
|
LDAPConnection |
getConnection()
Attempts to establish a client connection to the server.
|
LDAPConnection |
getConnection(LDAPConnectionOptions options)
Attempts to establish a client connection to the server.
|
LDAPConnection |
getConnection(java.lang.String listenerName)
Attempts to establish a client connection to the specified listener.
|
LDAPConnection |
getConnection(java.lang.String listenerName,
LDAPConnectionOptions options)
Attempts to establish a client connection to the specified listener.
|
LDAPConnectionPool |
getConnectionPool(int maxConnections)
Attempts to establish a connection pool to the server with the specified
maximum number of connections.
|
LDAPConnectionPool |
getConnectionPool(java.lang.String listenerName,
LDAPConnectionOptions options,
int initialConnections,
int maxConnections)
Attempts to establish a connection pool to the server with the provided
settings.
|
SearchResultEntry |
getEntry(java.lang.String dn)
Retrieves the entry with the specified DN.
|
SearchResultEntry |
getEntry(java.lang.String dn,
java.lang.String... attributes)
Retrieves the entry with the specified DN.
|
java.net.InetAddress |
getListenAddress()
Retrieves the configured listen address for the first active listener, if
defined.
|
java.net.InetAddress |
getListenAddress(java.lang.String listenerName)
Retrieves the configured listen address for the specified listener, if
defined.
|
int |
getListenPort()
Retrieves the configured listen port for the first active listener.
|
int |
getListenPort(java.lang.String listenerName)
Retrieves the configured listen port for the specified listener, if
available.
|
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> |
getMissingAttributeNames(java.lang.String dn,
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> |
getMissingAttributeValues(java.lang.String dn,
java.lang.String attributeName,
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.
|
java.util.List<java.lang.String> |
getMissingEntryDNs(java.lang.String... dns)
Retrieves a list containing the DNs of the entries which are missing from
the directory server.
|
java.util.List<java.lang.String> |
getPasswordAttributes()
Retrieves the configured list of password attributes.
|
java.util.List<InMemoryDirectoryServerPassword> |
getPasswordsInEntry(Entry entry,
ASN1OctetString clearPasswordToMatch)
Retrieves a list of the passwords contained in the provided entry.
|
InMemoryPasswordEncoder |
getPrimaryPasswordEncoder()
Retrieves the primary password encoder that has been configured for the
server.
|
long |
getProcessingDelayMillis()
Retrieves the delay in milliseconds that the server should impose before
beginning processing for operations.
|
RootDSE |
getRootDSE()
Retrieves the directory server root DSE.
|
Schema |
getSchema()
Retrieves the directory server schema definitions, using the subschema
subentry DN contained in the server's root DSE.
|
Schema |
getSchema(java.lang.String entryDN)
Retrieves the directory server schema definitions that govern the specified
entry.
|
int |
importFromLDIF(boolean clear,
java.io.File ldifFile)
Reads entries from the specified LDIF file and adds them to the server,
optionally clearing any existing entries before beginning to add the new
entries.
|
int |
importFromLDIF(boolean clear,
LDIFReader reader)
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.
|
int |
importFromLDIF(boolean clear,
java.lang.String path)
Reads entries from the specified LDIF file and adds them to the server,
optionally clearing any existing entries before beginning to add the new
entries.
|
LDAPResult |
modify(ModifyRequest modifyRequest)
Processes the provided modify request.
|
LDAPResult |
modify(ReadOnlyModifyRequest modifyRequest)
Processes the provided modify request.
|
LDAPResult |
modify(java.lang.String... ldifModificationLines)
Processes a modify request from the provided LDIF representation of the
changes.
|
LDAPResult |
modify(java.lang.String dn,
java.util.List<Modification> mods)
Applies the provided set of modifications to the specified entry.
|
LDAPResult |
modify(java.lang.String dn,
Modification... mods)
Applies the provided set of modifications to the specified entry.
|
LDAPResult |
modify(java.lang.String dn,
Modification mod)
Applies the provided modification to the specified entry.
|
LDAPResult |
modifyDN(ModifyDNRequest modifyDNRequest)
Processes the provided modify DN request.
|
LDAPResult |
modifyDN(ReadOnlyModifyDNRequest modifyDNRequest)
Processes the provided modify DN request.
|
LDAPResult |
modifyDN(java.lang.String dn,
java.lang.String newRDN,
boolean deleteOldRDN)
Performs a modify DN operation with the provided information.
|
LDAPResult |
modifyDN(java.lang.String dn,
java.lang.String newRDN,
boolean deleteOldRDN,
java.lang.String newSuperiorDN)
Performs a modify DN operation with the provided information.
|
ExtendedResult |
processExtendedOperation(ExtendedRequest extendedRequest)
Processes the provided extended request.
|
ExtendedResult |
processExtendedOperation(java.lang.String requestOID)
Processes an extended request with the provided request OID.
|
ExtendedResult |
processExtendedOperation(java.lang.String requestOID,
ASN1OctetString requestValue)
Processes an extended request with the provided request OID and value.
|
void |
restartListener(java.lang.String listenerName)
Attempts to restart the specified listener.
|
void |
restartServer()
Attempts to restart all listeners defined in the server.
|
void |
restoreSnapshot(InMemoryDirectoryServerSnapshot snapshot)
Restores the this in-memory directory server instance to match the content
it held at the time the snapshot was created.
|
SearchResult |
search(ReadOnlySearchRequest searchRequest)
Processes the provided search request.
|
SearchResult |
search(SearchRequest searchRequest)
Processes the provided search request.
|
SearchResult |
search(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(java.lang.String baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(java.lang.String baseDN,
SearchScope scope,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResultEntry |
searchForEntry(ReadOnlySearchRequest searchRequest)
Processes the provided search request.
|
SearchResultEntry |
searchForEntry(SearchRequest searchRequest)
Processes the provided search request.
|
SearchResultEntry |
searchForEntry(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResultEntry |
searchForEntry(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResultEntry |
searchForEntry(java.lang.String baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResultEntry |
searchForEntry(java.lang.String baseDN,
SearchScope scope,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
void |
setProcessingDelayMillis(long processingDelayMillis)
Specifies the delay in milliseconds that the server should impose before
beginning processing for operations.
|
void |
shutDown(boolean closeExistingConnections)
Shuts down all configured listeners.
|
void |
shutDown(java.lang.String listenerName,
boolean closeExistingConnections)
Shuts down the specified listener.
|
void |
startListening()
Attempts to start listening for client connections on all configured
listeners.
|
void |
startListening(java.lang.String listenerName)
Attempts to start listening for client connections on the specified
listener.
|
public InMemoryDirectoryServer(@NotNull java.lang.String... baseDNs) throws LDAPException
baseDNs
- The base DNs to use for the server. It must not be
null
or empty.LDAPException
- If a problem occurs while attempting to initialize
the server.public InMemoryDirectoryServer(@NotNull InMemoryDirectoryServerConfig cfg) throws LDAPException
cfg
- The configuration to use for the server. It must not be
null
.LDAPException
- If a problem occurs while trying to initialize the
directory server with the provided configuration.public void startListening() throws LDAPException
LDAPException
- If a problem occurs while attempting to create any
of the configured listeners. Even if an exception
is thrown, then as many listeners as possible will
be started.public void startListening(@NotNull java.lang.String listenerName) throws LDAPException
listenerName
- The name of the listener to be started. It must not
be null
.LDAPException
- If a problem occurs while attempting to start the
requested listener.public void close()
close
in interface FullLDAPInterface
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void closeAllConnections(boolean sendNoticeOfDisconnection)
sendNoticeOfDisconnection
- Indicates whether to send the client a
notice of disconnection unsolicited
notification before closing the
connection.public void shutDown(boolean closeExistingConnections)
closeExistingConnections
- Indicates whether to close all existing
connections, or merely to stop accepting
new connections.public void shutDown(@NotNull java.lang.String listenerName, boolean closeExistingConnections)
listenerName
- The name of the listener to be shut down.
It must not be null
.closeExistingConnections
- Indicates whether to close all existing
connections, or merely to stop accepting
new connections.public void restartServer() throws LDAPException
LDAPException
- If a problem occurs while attempting to restart any
of the listeners. Even if an exception is thrown,
as many listeners as possible will be started.public void restartListener(@NotNull java.lang.String listenerName) throws LDAPException
listenerName
- The name of the listener to be restarted. It must
not be null
.LDAPException
- If a problem occurs while attempting to restart the
specified listener.@NotNull public ReadOnlyInMemoryDirectoryServerConfig getConfig()
@NotNull public InMemoryDirectoryServerSnapshot createSnapshot()
restoreSnapshot(com.unboundid.ldap.listener.InMemoryDirectoryServerSnapshot)
method.
public void restoreSnapshot(@NotNull InMemoryDirectoryServerSnapshot snapshot)
snapshot
- The snapshot to be restored. It must not be
null
.@NotNull public java.util.List<DN> getBaseDNs()
@NotNull public LDAPConnection getConnection() throws LDAPException
LDAPException
- If a problem is encountered while attempting to
create the connection.@NotNull public LDAPConnection getConnection(@Nullable LDAPConnectionOptions options) throws LDAPException
options
- The connection options to use when creating the
connection. It may be null
if a default set of
options should be used.LDAPException
- If a problem is encountered while attempting to
create the connection.@NotNull public LDAPConnection getConnection(@Nullable java.lang.String listenerName) throws LDAPException
listenerName
- The name of the listener to which to establish the
connection. It may be null
if a connection
should be established to the first available
listener.LDAPException
- If a problem is encountered while attempting to
create the connection.@NotNull public LDAPConnection getConnection(@Nullable java.lang.String listenerName, @Nullable LDAPConnectionOptions options) throws LDAPException
listenerName
- The name of the listener to which to establish the
connection. It may be null
if a connection
should be established to the first available
listener.options
- The set of LDAP connection options to use for the
connection that is created.LDAPException
- If a problem is encountered while attempting to
create the connection.@NotNull public LDAPConnectionPool getConnectionPool(int maxConnections) throws LDAPException
maxConnections
- The maximum number of connections to maintain in
the connection pool. It must be greater than or
equal to one.LDAPException
- If a problem occurs while attempting to create the
connection pool.@NotNull public LDAPConnectionPool getConnectionPool(@Nullable java.lang.String listenerName, @Nullable LDAPConnectionOptions options, int initialConnections, int maxConnections) throws LDAPException
listenerName
- The name of the listener to which the
connections should be established.options
- The connection options to use when creating
connections for use in the pool. It may be
null
if a default set of options should
be used.initialConnections
- The initial number of connections to establish
in the connection pool. It must be greater
than or equal to one.maxConnections
- The maximum number of connections to maintain
in the connection pool. It must be greater
than or equal to the initial number of
connections.LDAPException
- If a problem occurs while attempting to create the
connection pool.@Nullable public java.net.InetAddress getListenAddress()
null
if that listener does not have an
explicitly-configured listen address or there are no active
listeners.@Nullable public java.net.InetAddress getListenAddress(@Nullable java.lang.String listenerName)
listenerName
- The name of the listener for which to retrieve the
listen address. It may be null
in order to
obtain the listen address for the first active
listener.null
if there is no such listener or the listener does not
have an explicitly-configured listen address.public int getListenPort()
public int getListenPort(@Nullable java.lang.String listenerName)
listenerName
- The name of the listener for which to retrieve the
listen port. It may be null
in order to
obtain the listen port for the first active
listener.@Nullable public javax.net.SocketFactory getClientSocketFactory()
null
if that listener does not have an
explicitly-configured socket factory or there are no active
listeners.@Nullable public javax.net.SocketFactory getClientSocketFactory(@Nullable java.lang.String listenerName)
listenerName
- The name of the listener for which to retrieve the
client socket factory. It may be null
in
order to obtain the client socket factory for the
first active listener.null
if there is no such listener or that listener does
not have an explicitly-configured client socket factory.public long getProcessingDelayMillis()
public void setProcessingDelayMillis(long processingDelayMillis)
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.public int countEntries()
public int countEntries(boolean includeChangeLog)
includeChangeLog
- Indicates whether to include entries that are
part of the changelog in the count.public int countEntriesBelow(@NotNull java.lang.String baseDN) throws LDAPException
baseDN
- The base DN to use for the determination.LDAPException
- If the provided string cannot be parsed as a valid
DN.public void clear()
public int importFromLDIF(boolean clear, @NotNull java.lang.String path) throws LDAPException
clear
is given with a value of true
).
clear
- Indicates whether to remove all existing entries prior to
adding entries read from LDIF.path
- The path to the LDIF file from which the entries should be
read. It must not be null
.LDAPException
- If a problem occurs while reading entries or adding
them to the server.public int importFromLDIF(boolean clear, @NotNull java.io.File ldifFile) throws LDAPException
clear
is given with a value of true
).
clear
- Indicates whether to remove all existing entries prior to
adding entries read from LDIF.ldifFile
- The LDIF file from which the entries should be read. It
must not be null
.LDAPException
- If a problem occurs while reading entries or adding
them to the server.public int importFromLDIF(boolean clear, @NotNull LDIFReader reader) throws LDAPException
clear
is given with a value of true
).
clear
- Indicates whether to remove all existing entries prior to
adding entries read from LDIF.reader
- The LDIF reader to use to obtain the entries to be
imported.LDAPException
- If a problem occurs while reading entries or adding
them to the server.public int exportToLDIF(@NotNull java.lang.String path, boolean excludeGeneratedAttrs, boolean excludeChangeLog) throws LDAPException
path
- The path of the file to which the LDIF
entries should be written.excludeGeneratedAttrs
- Indicates whether to exclude automatically
generated operational attributes like
entryUUID, entryDN, creatorsName, etc.excludeChangeLog
- Indicates whether to exclude entries
contained in the changelog.LDAPException
- If a problem occurs while writing entries to LDIF.public int exportToLDIF(@NotNull LDIFWriter ldifWriter, boolean excludeGeneratedAttrs, boolean excludeChangeLog, boolean closeWriter) throws LDAPException
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.LDAPException
- If a problem occurs while writing entries to LDIF.public int applyChangesFromLDIF(@NotNull java.lang.String path) throws LDAPException
path
- The path to the LDIF file from which the LDIF change
records should be read. It must not be null
.LDAPException
- If a problem occurs while reading change records
or applying them to the server.public int applyChangesFromLDIF(@NotNull java.io.File ldifFile) throws LDAPException
ldifFile
- The LDIF file from which the LDIF change records should
be read. It must not be null
.LDAPException
- If a problem occurs while reading change records
or applying them to the server.public int applyChangesFromLDIF(@NotNull LDIFReader reader) throws LDAPException
reader
- The LDIF reader to use to obtain the change records to be
applied.LDAPException
- If a problem occurs while reading change records
or applying them to the server.@Nullable public RootDSE getRootDSE() throws LDAPException
getRootDSE
in interface LDAPInterface
null
if it is not
available.LDAPException
- If a problem occurs while attempting to retrieve
the server root DSE.@Nullable public Schema getSchema() throws LDAPException
getSchema
in interface LDAPInterface
null
if the
schema information could not be retrieved (e.g, the client does
not have permission to read the server schema).LDAPException
- If a problem occurs while attempting to retrieve
the server schema.@Nullable public Schema getSchema(@Nullable java.lang.String entryDN) throws LDAPException
getSchema
in interface LDAPInterface
entryDN
- The DN of the entry for which to retrieve the associated
schema definitions. It may be null
or an empty
string if the subschemaSubentry attribute should be
retrieved from the server's root DSE.null
if the
schema information could not be retrieved (e.g, the client does
not have permission to read the server schema).LDAPException
- If a problem occurs while attempting to retrieve
the server schema.@Nullable public SearchResultEntry getEntry(@NotNull java.lang.String dn) throws LDAPException
getEntry
in interface LDAPInterface
dn
- The DN of the entry to retrieve. It must not be null
.null
if the target entry does not
exist or no entry was returned (e.g., if the authenticated user
does not have permission to read the target entry).LDAPException
- If a problem occurs while sending the request or
reading the response.@Nullable public SearchResultEntry getEntry(@NotNull java.lang.String dn, @Nullable java.lang.String... attributes) throws LDAPException
getEntry
in interface LDAPInterface
dn
- The DN of the entry to retrieve. It must not be
null
.attributes
- The set of attributes to request for the target entry.
If it is null
, then all user attributes will be
requested.null
if the target entry does not
exist or no entry was returned (e.g., if the authenticated user
does not have permission to read the target entry).LDAPException
- If a problem occurs while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull java.lang.String dn, @NotNull Attribute... attributes) throws LDAPException
add
in interface LDAPInterface
dn
- The DN of the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull java.lang.String dn, @NotNull java.util.Collection<Attribute> attributes) throws LDAPException
add
in interface LDAPInterface
dn
- The DN of the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull Entry entry) throws LDAPException
add
in interface LDAPInterface
entry
- The entry to add. It must not be null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull java.lang.String... ldifLines) throws LDIFException, LDAPException
add
in interface LDAPInterface
ldifLines
- The lines that comprise an LDIF representation of the
entry to add. It must not be empty or null
.LDIFException
- If the provided entry lines cannot be decoded as an
entry in LDIF form.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull AddRequest addRequest) throws LDAPException
add
in interface LDAPInterface
addRequest
- The add request to be processed. It must not be
null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull ReadOnlyAddRequest addRequest) throws LDAPException
add
in interface LDAPInterface
addRequest
- The add request to be processed. It must not be
null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.public void addEntries(@NotNull Entry... entries) throws LDAPException
entries
- The entries to be added to the server.LDAPException
- If a problem is encountered while attempting to add
any of the provided entries.public void addEntries(@NotNull java.util.List<? extends Entry> entries) throws LDAPException
entries
- The entries to be added to the server.LDAPException
- If a problem is encountered while attempting to add
any of the provided entries.public void addEntries(@NotNull java.lang.String... ldifEntryLines) throws LDAPException
ldifEntryLines
- The lines comprising the LDIF representation of the
entries to be added.LDAPException
- If a problem is encountered while attempting to add
any of the provided entries.@NotNull public BindResult bind(@Nullable java.lang.String bindDN, @Nullable java.lang.String password) throws LDAPException
bind
in interface FullLDAPInterface
bindDN
- The bind DN for the bind operation.password
- The password for the simple bind operation.LDAPException
- If the server rejects the bind request, or if a
problem occurs while sending the request or reading
the response.@NotNull public BindResult bind(@NotNull BindRequest bindRequest) throws LDAPException
bind
in interface FullLDAPInterface
bindRequest
- The bind request to be processed. It must not be
null
.LDAPException
- If the server rejects the bind request, or if a
problem occurs while sending the request or reading
the response.@NotNull public CompareResult compare(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue) throws LDAPException
compare
in interface LDAPInterface
dn
- The DN of the entry in which to make the
comparison. It must not be null
.attributeName
- The attribute name for which to make the
comparison. It must not be null
.assertionValue
- The assertion value to verify in the target entry.
It must not be null
.LDAPException
- If the server rejects the compare request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public CompareResult compare(@NotNull CompareRequest compareRequest) throws LDAPException
compare
in interface LDAPInterface
compareRequest
- The compare request to be processed. It must not
be null
.LDAPException
- If the server rejects the compare request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public CompareResult compare(@NotNull ReadOnlyCompareRequest compareRequest) throws LDAPException
compare
in interface LDAPInterface
compareRequest
- The compare request to be processed. It must not
be null
.LDAPException
- If the server rejects the compare request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult delete(@NotNull java.lang.String dn) throws LDAPException
delete
in interface LDAPInterface
dn
- The DN of the entry to delete. It must not be null
.LDAPException
- If the server rejects the delete request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult delete(@NotNull DeleteRequest deleteRequest) throws LDAPException
delete
in interface LDAPInterface
deleteRequest
- The delete request to be processed. It must not be
null
.LDAPException
- If the server rejects the delete request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult delete(@NotNull ReadOnlyDeleteRequest deleteRequest) throws LDAPException
delete
in interface LDAPInterface
deleteRequest
- The delete request to be processed. It must not be
null
.LDAPException
- If the server rejects the delete request, or if a
problem is encountered while sending the request or
reading the response.public int deleteSubtree(@NotNull java.lang.String baseDN) throws LDAPException
baseDN
- The DN of the entry to remove, along with all of its
subordinates.LDAPException
- If a problem is encountered while attempting to
remove the entries.@NotNull public ExtendedResult processExtendedOperation(@NotNull java.lang.String requestOID) throws LDAPException
processExtendedOperation
in interface FullLDAPInterface
requestOID
- The OID for the extended request to process. It must
not be null
.LDAPException
- If a problem occurs while sending the request or
reading the response.@NotNull public ExtendedResult processExtendedOperation(@NotNull java.lang.String requestOID, @Nullable ASN1OctetString requestValue) throws LDAPException
processExtendedOperation
in interface FullLDAPInterface
requestOID
- The OID for the extended request to process. It must
not be null
.requestValue
- The encoded value for the extended request to
process. It may be null
if there does not
need to be a value for the requested operation.LDAPException
- If a problem occurs while sending the request or
reading the response.@NotNull public ExtendedResult processExtendedOperation(@NotNull ExtendedRequest extendedRequest) throws LDAPException
processExtendedOperation
in interface FullLDAPInterface
extendedRequest
- The extended request to be processed. It must not
be null
.LDAPException
- If a problem occurs while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull Modification mod) throws LDAPException
modify
in interface LDAPInterface
dn
- The DN of the entry to modify. It must not be null
.mod
- The modification to apply to the target entry. It must not
be null
.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull Modification... mods) throws LDAPException
modify
in interface LDAPInterface
dn
- The DN of the entry to modify. It must not be null
.mods
- The set of modifications to apply to the target entry. It
must not be null
or empty. *LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull java.util.List<Modification> mods) throws LDAPException
modify
in interface LDAPInterface
dn
- The DN of the entry to modify. It must not be null
.mods
- The set of modifications to apply to the target entry. It
must not be null
or empty.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull java.lang.String... ldifModificationLines) throws LDIFException, LDAPException
modify
in interface LDAPInterface
ldifModificationLines
- The lines that comprise an LDIF
representation of a modify change record.
It must not be null
or empty.LDIFException
- If the provided set of lines cannot be parsed as an
LDIF modify change record.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull ModifyRequest modifyRequest) throws LDAPException
modify
in interface LDAPInterface
modifyRequest
- The modify request to be processed. It must not be
null
.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull ReadOnlyModifyRequest modifyRequest) throws LDAPException
modify
in interface LDAPInterface
modifyRequest
- The modify request to be processed. It must not be
null
.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modifyDN(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN) throws LDAPException
modifyDN
in interface LDAPInterface
dn
- The current DN for the entry to rename. It must not
be null
.newRDN
- The new RDN to use for the entry. It must not be
null
.deleteOldRDN
- Indicates whether to delete the current RDN value
from the entry.LDAPException
- If the server rejects the modify DN request, or if
a problem is encountered while sending the request
or reading the response.@NotNull public LDAPResult modifyDN(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN, @Nullable java.lang.String newSuperiorDN) throws LDAPException
modifyDN
in interface LDAPInterface
dn
- The current DN for the entry to rename. It must not
be null
.newRDN
- The new RDN to use for the entry. It must not be
null
.deleteOldRDN
- Indicates whether to delete the current RDN value
from the entry.newSuperiorDN
- The new superior DN for the entry. It may be
null
if the entry is not to be moved below a
new parent.LDAPException
- If the server rejects the modify DN request, or if
a problem is encountered while sending the request
or reading the response.@NotNull public LDAPResult modifyDN(@NotNull ModifyDNRequest modifyDNRequest) throws LDAPException
modifyDN
in interface LDAPInterface
modifyDNRequest
- The modify DN request to be processed. It must
not be null
.LDAPException
- If the server rejects the modify DN request, or if
a problem is encountered while sending the request
or reading the response.@NotNull public LDAPResult modifyDN(@NotNull ReadOnlyModifyDNRequest modifyDNRequest) throws LDAPException
modifyDN
in interface LDAPInterface
modifyDNRequest
- The modify DN request to be processed. It must
not be null
.LDAPException
- If the server rejects the modify DN request, or if
a problem is encountered while sending the request
or reading the response.@NotNull public SearchResult search(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
SearchResult
object that is returned.
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
search
in interface LDAPInterface
baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.filter
- The string representation of the filter to use to
identify matching entries. It must not be
null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while parsing
the provided filter string, sending the
request, or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
SearchResult
object that is returned.
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
search
in interface LDAPInterface
baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.filter
- The filter to use to identify matching entries. It
must not be null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references (although if a search result listener was provided,
then it will have been used to make any entries and references available,
and they will not be available through the getSearchEntries
and
getSearchReferences
methods).
search
in interface LDAPInterface
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.filter
- The string representation of the filter to
use to identify matching entries. It must
not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while parsing
the provided filter string, sending the
request, or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references (although if a search result listener was provided,
then it will have been used to make any entries and references available,
and they will not be available through the getSearchEntries
and
getSearchReferences
methods).
search
in interface LDAPInterface
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.filter
- The filter to use to identify matching
entries. It must not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
SearchResult
object that is returned.
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
search
in interface LDAPInterface
baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.derefPolicy
- The dereference policy the server should use for any
aliases encountered while processing the search.sizeLimit
- The maximum number of entries that the server should
return for the search. A value of zero indicates that
there should be no limit.timeLimit
- The maximum length of time in seconds that the server
should spend processing this search request. A value
of zero indicates that there should be no limit.typesOnly
- Indicates whether to return only attribute names in
matching entries, or both attribute names and values.filter
- The string representation of the filter to use to
identify matching entries. It must not be
null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while parsing
the provided filter string, sending the
request, or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
SearchResult
object that is returned.
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
search
in interface LDAPInterface
baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.derefPolicy
- The dereference policy the server should use for any
aliases encountered while processing the search.sizeLimit
- The maximum number of entries that the server should
return for the search. A value of zero indicates that
there should be no limit.timeLimit
- The maximum length of time in seconds that the server
should spend processing this search request. A value
of zero indicates that there should be no limit.typesOnly
- Indicates whether to return only attribute names in
matching entries, or both attribute names and values.filter
- The filter to use to identify matching entries. It
must not be null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references (although if a search result listener was provided,
then it will have been used to make any entries and references available,
and they will not be available through the getSearchEntries
and
getSearchReferences
methods).
search
in interface LDAPInterface
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.derefPolicy
- The dereference policy the server should use
for any aliases encountered while processing
the search.sizeLimit
- The maximum number of entries that the server
should return for the search. A value of
zero indicates that there should be no limit.timeLimit
- The maximum length of time in seconds that
the server should spend processing this
search request. A value of zero indicates
that there should be no limit.typesOnly
- Indicates whether to return only attribute
names in matching entries, or both attribute
names and values.filter
- The string representation of the filter to
use to identify matching entries. It must
not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while parsing
the provided filter string, sending the
request, or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references (although if a search result listener was provided,
then it will have been used to make any entries and references available,
and they will not be available through the getSearchEntries
and
getSearchReferences
methods).
search
in interface LDAPInterface
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.derefPolicy
- The dereference policy the server should use
for any aliases encountered while processing
the search.sizeLimit
- The maximum number of entries that the server
should return for the search. A value of
zero indicates that there should be no limit.timeLimit
- The maximum length of time in seconds that
the server should spend processing this
search request. A value of zero indicates
that there should be no limit.typesOnly
- Indicates whether to return only attribute
names in matching entries, or both attribute
names and values.filter
- The filter to use to identify matching
entries. It must not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@NotNull SearchRequest searchRequest) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references (although if a search result listener was provided,
then it will have been used to make any entries and references available,
and they will not be available through the getSearchEntries
and
getSearchReferences
methods).
search
in interface LDAPInterface
searchRequest
- The search request to be processed. It must not be
null
.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@NotNull ReadOnlySearchRequest searchRequest) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references (although if a search result listener was provided,
then it will have been used to make any entries and references available,
and they will not be available through the getSearchEntries
and
getSearchReferences
methods).
search
in interface LDAPInterface
searchRequest
- The search request to be processed. It must not be
null
.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
searchForEntry
in interface LDAPInterface
baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.filter
- The string representation of the filter to use to
identify matching entries. It must not be
null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
searchForEntry
in interface LDAPInterface
baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.filter
- The string representation of the filter to use to
identify matching entries. It must not be
null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int timeLimit, boolean typesOnly, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
searchForEntry
in interface LDAPInterface
baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.derefPolicy
- The dereference policy the server should use for any
aliases encountered while processing the search.timeLimit
- The maximum length of time in seconds that the server
should spend processing this search request. A value
of zero indicates that there should be no limit.typesOnly
- Indicates whether to return only attribute names in
matching entries, or both attribute names and values.filter
- The string representation of the filter to use to
identify matching entries. It must not be
null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
searchForEntry
in interface LDAPInterface
baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.derefPolicy
- The dereference policy the server should use for any
aliases encountered while processing the search.timeLimit
- The maximum length of time in seconds that the server
should spend processing this search request. A value
of zero indicates that there should be no limit.typesOnly
- Indicates whether to return only attribute names in
matching entries, or both attribute names and values.filter
- The filter to use to identify matching entries. It
must not be null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull SearchRequest searchRequest) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
searchForEntry
in interface LDAPInterface
searchRequest
- The search request to be processed. If it is
configured with a search result listener or a size
limit other than one, then the provided request will
be duplicated with the appropriate settings.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull ReadOnlySearchRequest searchRequest) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.
searchForEntry
in interface LDAPInterface
searchRequest
- The search request to be processed. If it is
configured with a search result listener or a size
limit other than one, then the provided request will
be duplicated with the appropriate settings.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public java.util.List<java.lang.String> getPasswordAttributes()
@Nullable public InMemoryPasswordEncoder getPrimaryPasswordEncoder()
@NotNull public java.util.List<InMemoryPasswordEncoder> getAllPasswordEncoders()
@NotNull public java.util.List<InMemoryDirectoryServerPassword> getPasswordsInEntry(@NotNull Entry entry, @Nullable ASN1OctetString clearPasswordToMatch)
entry
- The entry from which to obtain the list of
passwords. It must not be null
.clearPasswordToMatch
- An optional clear-text password that should
match the values that are returned. If this
is null
, then all passwords contained
in the provided entry will be returned. If
this is non-null
, then only passwords
matching the clear-text password will be
returned.public boolean entryExists(@NotNull java.lang.String dn) throws LDAPException
dn
- The DN of the entry for which to make the determination.true
if the entry exists, or false
if not.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public boolean entryExists(@NotNull java.lang.String dn, @NotNull java.lang.String filter) throws LDAPException
dn
- The DN of the entry for which to make the determination.filter
- The filter the entry is expected to match.true
if the entry exists and matches the specified filter,
or false
if not.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public boolean entryExists(@NotNull Entry entry) throws LDAPException
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.
entry
- The entry to compare against the directory server.true
if the entry exists in the server and is a superset
of the provided entry, or false
if not.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public void assertEntryExists(@NotNull java.lang.String dn) throws LDAPException, java.lang.AssertionError
dn
- The DN of the entry for which to make the determination.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry does not exist.public void assertEntryExists(@NotNull java.lang.String dn, @NotNull java.lang.String filter) throws LDAPException, java.lang.AssertionError
dn
- The DN of the entry for which to make the determination.filter
- A filter that the target entry must match.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.public void assertEntryExists(@NotNull Entry entry) throws LDAPException, java.lang.AssertionError
entry
- The entry expected to be present in the directory server.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.@NotNull public java.util.List<java.lang.String> getMissingEntryDNs(@NotNull java.lang.String... dns) throws LDAPException
dns
- The DNs of the entries to try to find in the server.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.@NotNull public java.util.List<java.lang.String> getMissingEntryDNs(@NotNull java.util.Collection<java.lang.String> dns) throws LDAPException
dns
- The DNs of the entries to try to find in the server.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public void assertEntriesExist(@NotNull java.lang.String... dns) throws LDAPException, java.lang.AssertionError
dns
- The DNs of the entries for which to make the determination.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.public void assertEntriesExist(@NotNull java.util.Collection<java.lang.String> dns) throws LDAPException, java.lang.AssertionError
dns
- The DNs of the entries for which to make the determination.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.@Nullable public java.util.List<java.lang.String> getMissingAttributeNames(@NotNull java.lang.String dn, @NotNull java.lang.String... attributeNames) throws LDAPException
dn
- The DN of the entry to examine.attributeNames
- The names of the attributes expected to be present
in the target entry.null
if the target
entry does not exist.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.@Nullable public java.util.List<java.lang.String> getMissingAttributeNames(@NotNull java.lang.String dn, @NotNull java.util.Collection<java.lang.String> attributeNames) throws LDAPException
dn
- The DN of the entry to examine.attributeNames
- The names of the attributes expected to be present
in the target entry.null
if the target
entry does not exist.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public void assertAttributeExists(@NotNull java.lang.String dn, @NotNull java.lang.String... attributeNames) throws LDAPException, java.lang.AssertionError
dn
- The DN of the entry to examine.attributeNames
- The names of the attributes that are expected to be
present in the provided entry.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.public void assertAttributeExists(@NotNull java.lang.String dn, @NotNull java.util.Collection<java.lang.String> attributeNames) throws LDAPException, java.lang.AssertionError
dn
- The DN of the entry to examine.attributeNames
- The names of the attributes that are expected to be
present in the provided entry.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.@Nullable public java.util.List<java.lang.String> getMissingAttributeValues(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String... attributeValues) throws LDAPException
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.null
if the target entry does not exist.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.@Nullable public java.util.List<java.lang.String> getMissingAttributeValues(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.String> attributeValues) throws LDAPException
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.null
if the target entry does not exist.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public void assertValueExists(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String... attributeValues) throws LDAPException, java.lang.AssertionError
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.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.public void assertValueExists(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.String> attributeValues) throws LDAPException, java.lang.AssertionError
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.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.public void assertEntryMissing(@NotNull java.lang.String dn) throws LDAPException, java.lang.AssertionError
dn
- The DN of the entry expected to be missing.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.public void assertAttributeMissing(@NotNull java.lang.String dn, @NotNull java.lang.String... attributeNames) throws LDAPException, java.lang.AssertionError
dn
- The DN of the entry expected to be present.attributeNames
- The names of the attributes expected to be missing
from the entry.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.public void assertAttributeMissing(@NotNull java.lang.String dn, @NotNull java.util.Collection<java.lang.String> attributeNames) throws LDAPException, java.lang.AssertionError
dn
- The DN of the entry expected to be present.attributeNames
- The names of the attributes expected to be missing
from the entry.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.public void assertValueMissing(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String... attributeValues) throws LDAPException, java.lang.AssertionError
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.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.public void assertValueMissing(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.String> attributeValues) throws LDAPException, java.lang.AssertionError
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.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.