org.apache.directory.ldap.client.api
Class LdapNetworkConnection

java.lang.Object
  extended by org.apache.mina.core.service.IoHandlerAdapter
      extended by org.apache.directory.ldap.client.api.AbstractLdapConnection
          extended by org.apache.directory.ldap.client.api.LdapNetworkConnection
All Implemented Interfaces:
LdapAsyncConnection, LdapConnection, org.apache.mina.core.service.IoHandler

public class LdapNetworkConnection
extends AbstractLdapConnection
implements LdapAsyncConnection

This class is the base for every operations sent or received to and from a LDAP server. A connection instance is necessary to send requests to the server. The connection is valid until either the client closes it, the server closes it or the client does an unbind.

Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.ldap.client.api.AbstractLdapConnection
codec, messageId, schemaManager
 
Constructor Summary
LdapNetworkConnection()
          Create a new instance of a LdapConnection on localhost, port 389.
LdapNetworkConnection(boolean useSsl)
          Create a new instance of a LdapConnection on localhost, port 389 if the SSL flag is off, or 636 otherwise.
LdapNetworkConnection(LdapConnectionConfig config)
          Creates a new instance of LdapConnection with the given connection configuration.
LdapNetworkConnection(String server)
          Create a new instance of a LdapConnection on a given server, using the default port (389).
LdapNetworkConnection(String server, boolean useSsl)
          Create a new instance of a LdapConnection on a given server, using the default port (389) if the SSL flag is off, or 636 otherwise.
LdapNetworkConnection(String server, int port)
          Create a new instance of a LdapConnection on a given server and a given port.
LdapNetworkConnection(String server, int port, boolean useSsl)
          Create a new instance of a LdapConnection on a given server, and a give port.
 
Method Summary
 void abandon(org.apache.directory.api.ldap.model.message.AbandonRequest abandonRequest)
          An abandon request essentially with the request message ID of the operation to be canceled and/or potentially some controls and timeout (the controls and timeout are not mandatory).
 void abandon(int messageId)
          Abandons a request submitted to the server for performing a particular operation The abandonRequest is always non-blocking, because no response is expected
 org.apache.directory.api.ldap.model.message.AddResponse add(org.apache.directory.api.ldap.model.message.AddRequest addRequest)
          Add an entry present in the AddRequest to the server.
 void add(org.apache.directory.api.ldap.model.entry.Entry entry)
          Add an entry to the server.
 AddFuture addAsync(org.apache.directory.api.ldap.model.message.AddRequest addRequest)
          Add an entry present in the AddRequest to the server.
 AddFuture addAsync(org.apache.directory.api.ldap.model.entry.Entry entry)
          Add an entry to the server asynchronously.
 void addConnectionClosedEventListener(ConnectionClosedEventListener ccListener)
          Adds the connection closed event listener.
 void addSchema(File schemaFile)
          parses the given schema file present in OpenLDAP schema format and adds all the SchemaObjects present in it to the SchemaManager
 void addSchema(String schemaFileName)
           
 void anonymousBind()
          Anonymous Bind on a server.
 BindFuture anonymousBindAsync()
          Anonymous asynchronous Bind on a server.
 void bind()
          Bind on a server, using the LdapConnectionConfig informations
 org.apache.directory.api.ldap.model.message.BindResponse bind(org.apache.directory.api.ldap.model.message.BindRequest bindRequest)
          Bind to the server using a BindRequest object.
 org.apache.directory.api.ldap.model.message.BindResponse bind(CramMd5Request request)
          Bind to the server using a CramMd5Request object.
 org.apache.directory.api.ldap.model.message.BindResponse bind(DigestMd5Request request)
          Bind to the server using a DigestMd5Request object.
 org.apache.directory.api.ldap.model.message.BindResponse bind(GssApiRequest request)
          Bind to the server using a GssApiRequest object.
 BindFuture bindAsync()
          Asynchronous Bind on a server, using the LdapConnectionConfig informations.
 BindFuture bindAsync(org.apache.directory.api.ldap.model.message.BindRequest bindRequest)
          Do an asynchronous bind, based on a BindRequest.
 BindFuture bindAsync(CramMd5Request request)
          Do an asynchronous bind, based on a CramMd5Request.
 BindFuture bindAsync(DigestMd5Request request)
          Do an asynchronous bind, based on a DigestMd5Request.
 BindFuture bindAsync(org.apache.directory.api.ldap.model.name.Dn name)
          Asynchronous unauthenticated authentication Bind on a server.
 BindFuture bindAsync(org.apache.directory.api.ldap.model.name.Dn name, String credentials)
          Simple asynchronous Bind on a server.
 BindFuture bindAsync(GssApiRequest request)
          Do an asynchronous bind, based on a GssApiRequest.
 BindFuture bindAsync(String name)
          Asynchronous unauthenticated authentication bind
 BindFuture bindAsync(String name, String credentials)
          Simple asynchronous Bind on a server.
 boolean close()
          Disconnect from the remote LDAP server
 org.apache.directory.api.ldap.model.message.CompareResponse compare(org.apache.directory.api.ldap.model.message.CompareRequest compareRequest)
          Compares an entry's attribute's value with that of the given value.
 boolean compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, byte[] value)
          Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.
 boolean compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, String value)
          Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.
 boolean compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, org.apache.directory.api.ldap.model.entry.Value<?> value)
          Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.
 boolean compare(String dn, String attributeName, byte[] value)
          Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.
 boolean compare(String dn, String attributeName, String value)
          Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.
 boolean compare(String dn, String attributeName, org.apache.directory.api.ldap.model.entry.Value<?> value)
          Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.
 CompareFuture compareAsync(org.apache.directory.api.ldap.model.message.CompareRequest compareRequest)
          Asynchronously compares an entry's attribute's value with that of the given value
 boolean connect()
          Connect to the remote LDAP server.
 org.apache.directory.api.ldap.model.message.DeleteResponse delete(org.apache.directory.api.ldap.model.message.DeleteRequest deleteRequest)
          Performs a delete operation based on the delete request object.
 void delete(org.apache.directory.api.ldap.model.name.Dn dn)
          Deletes the entry with the given Dn.
 void delete(String dn)
          Deletes the entry with the given Dn.
 DeleteFuture deleteAsync(org.apache.directory.api.ldap.model.message.DeleteRequest deleteRequest)
          Performs an asynchronous delete operation based on the delete request object.
 void deleteTree(org.apache.directory.api.ldap.model.name.Dn dn)
          deletes the entry with the given Dn, and all its children
 void deleteTree(String dn)
          deletes the entry with the given Dn, and all its children
 boolean doesFutureExistFor(int messageId)
          Checks if there is a ResponseFuture associated with the given message ID.
 void exceptionCaught(org.apache.mina.core.session.IoSession session, Throwable cause)
          Handle the exception we got.
 boolean exists(org.apache.directory.api.ldap.model.name.Dn dn)
          Tells if an Entry exists in the server.
 boolean exists(String dn)
          Tells if an Entry exists in the server.
 org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.ldap.model.message.ExtendedRequest extendedRequest)
          Performs an extended operation based on the Extended request object.
 org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.asn1.util.Oid oid)
          Sends a extended operation request to the server with the given OID and no value.
 org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.asn1.util.Oid oid, byte[] value)
          Sends a extended operation request to the server with the given OID and value.
 org.apache.directory.api.ldap.model.message.ExtendedResponse extended(String oid)
          Sends a extended operation request to the server with the given OID and no value.
 org.apache.directory.api.ldap.model.message.ExtendedResponse extended(String oid, byte[] value)
          Sends a extended operation request to the server with the given OID and value.
 ExtendedFuture extendedAsync(org.apache.directory.api.ldap.model.message.ExtendedRequest extendedRequest)
          Asynchronously requests the server to perform an extended operation based on the given request.
 org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector getBinaryAttributeDetector()
          
 org.apache.directory.api.ldap.codec.api.LdapApiService getCodecService()
          Gets the LDAP CODEC service responsible for encoding and decoding messages.
 LdapConnectionConfig getConfig()
          gives the configuration information of the connection
 org.apache.directory.api.ldap.model.entry.Entry getRootDse()
          Get back the RooDSE from the connected server.
 org.apache.directory.api.ldap.model.entry.Entry getRootDse(String... attributes)
          Get back the RooDSE from the connected server.
 org.apache.directory.api.ldap.model.schema.SchemaManager getSchemaManager()
          
 List<String> getSupportedControls()
          Get the Controls supported by server.
 boolean isAuthenticated()
          Check if we are authenticated
 boolean isConnected()
          Check if we are connected
 boolean isControlSupported(String controlOID)
          Checks if a control with the given OID is supported.
 void loadSchema()
          Loads all the default schemas that are bundled with the API.

Note: This method enables all schemas prior to loading
 void loadSchema(org.apache.directory.api.ldap.model.schema.registries.SchemaLoader loader)
          loads schema using the specified schema loader
 org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn)
          Searches for an entry having the given Dn.
 org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn, org.apache.directory.api.ldap.model.message.Control[] controls, String... attributes)
          Searches for an entry having the given Dn.
 org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn, String... attributes)
          Searches for an entry having the given Dn.
 org.apache.directory.api.ldap.model.entry.Entry lookup(String dn)
          Searches for an entry having the given Dn.
 org.apache.directory.api.ldap.model.entry.Entry lookup(String dn, org.apache.directory.api.ldap.model.message.Control[] controls, String... attributes)
          Searches for an entry having the given Dn.
 org.apache.directory.api.ldap.model.entry.Entry lookup(String dn, String... attributes)
          Searches for an entry having the given Dn.
 void messageReceived(org.apache.mina.core.session.IoSession session, Object message)
          Handle the incoming LDAP messages.
 void modify(org.apache.directory.api.ldap.model.name.Dn dn, org.apache.directory.api.ldap.model.entry.Modification... modifications)
          Applies all the modifications to the entry specified by its Dn.
 void modify(org.apache.directory.api.ldap.model.entry.Entry entry, org.apache.directory.api.ldap.model.entry.ModificationOperation modOp)
          Modifies all the attributes present in the entry by applying the same operation.
 org.apache.directory.api.ldap.model.message.ModifyResponse modify(org.apache.directory.api.ldap.model.message.ModifyRequest modRequest)
          Performs an modify operation based on the modifications present in the ModifyRequest.
 void modify(String dn, org.apache.directory.api.ldap.model.entry.Modification... modifications)
          Applies all the modifications to the entry specified by its Dn.
 ModifyFuture modifyAsync(org.apache.directory.api.ldap.model.message.ModifyRequest modRequest)
          Performs an asynchronous modify operation based on the modifications present in the ModifyRequest.
 org.apache.directory.api.ldap.model.message.ModifyDnResponse modifyDn(org.apache.directory.api.ldap.model.message.ModifyDnRequest modDnRequest)
          Performs the modifyDn operation based on the given ModifyDnRequest.
 ModifyDnFuture modifyDnAsync(org.apache.directory.api.ldap.model.message.ModifyDnRequest modDnRequest)
          Performs the modifyDn operation based on the given ModifyDnRequest.
 void move(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newSuperiorDn)
          Moves the given entry Dn under the new superior Dn.
 void move(String entryDn, String newSuperiorDn)
          Moves the given entry Dn under the new superior Dn.
 void moveAndRename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newDn)
          Moves and renames the given entryDn.
 void moveAndRename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newDn, boolean deleteOldRdn)
          Moves and renames the given entryDn.
 void moveAndRename(String entryDn, String newDn)
          Moves and renames the given entryDn.The old Rdn will be deleted
 void moveAndRename(String entryDn, String newDn, boolean deleteOldRdn)
          Moves and renames the given entryDn.
 void rename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Rdn newRdn)
          Renames the given entryDn with new Rdn and deletes the old Rdn.
 void rename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Rdn newRdn, boolean deleteOldRdn)
          Renames the given entryDn with new Rdn and deletes the old Rdn if deleteOldRdn is set to true.
 void rename(String entryDn, String newRdn)
          Renames the given entryDn with new Rdn and deletes the old Rdn.
 void rename(String entryDn, String newRdn, boolean deleteOldRdn)
          Renames the given entryDn with new Rdn and deletes the old Rdn if deleteOldRdn is set to true.
 org.apache.directory.api.ldap.model.cursor.EntryCursor search(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
          Do a search, on the base object, using the given filter.
 org.apache.directory.api.ldap.model.cursor.SearchCursor search(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
          Performs search in a synchronous mode.
 org.apache.directory.api.ldap.model.cursor.EntryCursor search(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
          Do a search, on the base object, using the given filter.
 SearchFuture searchAsync(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
          Do an asynchronous search, on the base object, using the given filter.
 SearchFuture searchAsync(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
          Do a search, on the base object, using the given filter.
 SearchFuture searchAsync(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
          Do an asynchronous search, on the base object, using the given filter.
 void sessionClosed(org.apache.mina.core.session.IoSession session)
          
 void sessionCreated(org.apache.mina.core.session.IoSession session)
          This method is called when a new session is created.
 void setBinaryAttributeDetector(org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector binaryAttributeDetector)
          Sets the object responsible for the detection of binary attributes
 void setConnector(org.apache.mina.core.service.IoConnector connector)
          Set the connector to use.
 void setTimeOut(long timeout)
          Set the timeOut for the responses.
 void startTls()
          Sends the StartTLS extended request to server and adds a security layer upon receiving a response with successful result.
 void unBind()
          UnBind from a server.
 
Methods inherited from class org.apache.directory.ldap.client.api.AbstractLdapConnection
bind, bind, bind, bind, createBindRequest
 
Methods inherited from class org.apache.mina.core.service.IoHandlerAdapter
messageSent, sessionIdle, sessionOpened
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.ldap.client.api.LdapConnection
bind, bind, bind, bind
 

Constructor Detail

LdapNetworkConnection

public LdapNetworkConnection()
Create a new instance of a LdapConnection on localhost, port 389.


LdapNetworkConnection

public LdapNetworkConnection(LdapConnectionConfig config)
Creates a new instance of LdapConnection with the given connection configuration.

Parameters:
config - the configuration of the LdapConnection

LdapNetworkConnection

public LdapNetworkConnection(boolean useSsl)
Create a new instance of a LdapConnection on localhost, port 389 if the SSL flag is off, or 636 otherwise.

Parameters:
useSsl - A flag to tell if it's a SSL connection or not.

LdapNetworkConnection

public LdapNetworkConnection(String server)
Create a new instance of a LdapConnection on a given server, using the default port (389).

Parameters:
server - The server we want to be connected to. If null or empty, we will default to LocalHost.

LdapNetworkConnection

public LdapNetworkConnection(String server,
                             boolean useSsl)
Create a new instance of a LdapConnection on a given server, using the default port (389) if the SSL flag is off, or 636 otherwise.

Parameters:
server - The server we want to be connected to. If null or empty, we will default to LocalHost.
useSsl - A flag to tell if it's a SSL connection or not.

LdapNetworkConnection

public LdapNetworkConnection(String server,
                             int port)
Create a new instance of a LdapConnection on a given server and a given port. We don't use ssl.

Parameters:
server - The server we want to be connected to
port - The port the server is listening to

LdapNetworkConnection

public LdapNetworkConnection(String server,
                             int port,
                             boolean useSsl)
Create a new instance of a LdapConnection on a given server, and a give port. We set the SSL flag accordingly to the last parameter.

Parameters:
server - The server we want to be connected to. If null or empty, we will default to LocalHost.
port - The port the server is listening to
useSsl - A flag to tell if it's a SSL connection or not.
Method Detail

isConnected

public boolean isConnected()
Check if we are connected

Specified by:
isConnected in interface LdapConnection
Returns:
true if we are connected.

isAuthenticated

public boolean isAuthenticated()
Check if we are authenticated

Specified by:
isAuthenticated in interface LdapConnection
Returns:
true if we are connected.

connect

public boolean connect()
                throws org.apache.directory.api.ldap.model.exception.LdapException,
                       IOException
Connect to the remote LDAP server.

Specified by:
connect in interface LdapConnection
Returns:
true if the connection is established, false otherwise
Throws:
IOException - if an I/O exception occurred
org.apache.directory.api.ldap.model.exception.LdapException

close

public boolean close()
              throws IOException
Disconnect from the remote LDAP server

Specified by:
close in interface LdapConnection
Returns:
true if the connection is closed, false otherwise
Throws:
IOException - if some I/O error occurs

add

public void add(org.apache.directory.api.ldap.model.entry.Entry entry)
         throws org.apache.directory.api.ldap.model.exception.LdapException
Add an entry to the server. This is a blocking add : the user has to wait for the response until the AddResponse is returned.

Specified by:
add in interface LdapConnection
Parameters:
entry - The entry to add
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

addAsync

public AddFuture addAsync(org.apache.directory.api.ldap.model.entry.Entry entry)
                   throws org.apache.directory.api.ldap.model.exception.LdapException
Add an entry to the server asynchronously. This is a non blocking add : the user has to get for the response from the returned Future.

Specified by:
addAsync in interface LdapAsyncConnection
Parameters:
entry - The entry to add
Returns:
the add operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred

add

public org.apache.directory.api.ldap.model.message.AddResponse add(org.apache.directory.api.ldap.model.message.AddRequest addRequest)
                                                            throws org.apache.directory.api.ldap.model.exception.LdapException
Add an entry present in the AddRequest to the server.

Specified by:
add in interface LdapConnection
Parameters:
addRequest - the request object containing an entry and controls(if any)
Returns:
the add operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

addAsync

public AddFuture addAsync(org.apache.directory.api.ldap.model.message.AddRequest addRequest)
                   throws org.apache.directory.api.ldap.model.exception.LdapException
Add an entry present in the AddRequest to the server.

Specified by:
addAsync in interface LdapAsyncConnection
Parameters:
addRequest - the request object containing an entry and controls(if any)
Returns:
the add operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred

abandon

public void abandon(int messageId)
Abandons a request submitted to the server for performing a particular operation The abandonRequest is always non-blocking, because no response is expected

Specified by:
abandon in interface LdapConnection
Parameters:
messageId - the ID of the request message sent to the server

abandon

public void abandon(org.apache.directory.api.ldap.model.message.AbandonRequest abandonRequest)
An abandon request essentially with the request message ID of the operation to be canceled and/or potentially some controls and timeout (the controls and timeout are not mandatory). The abandonRequest is always non-blocking, because no response is expected

Specified by:
abandon in interface LdapConnection
Parameters:
abandonRequest - the abandon operation's request

bind

public void bind()
          throws org.apache.directory.api.ldap.model.exception.LdapException,
                 IOException
Bind on a server, using the LdapConnectionConfig informations

Specified by:
bind in interface LdapConnection
Throws:
IOException - if an I/O exception occurred
org.apache.directory.api.ldap.model.exception.LdapException

anonymousBind

public void anonymousBind()
                   throws org.apache.directory.api.ldap.model.exception.LdapException,
                          IOException
Anonymous Bind on a server.

Specified by:
anonymousBind in interface LdapConnection
Throws:
IOException - if an I/O exception occurred
org.apache.directory.api.ldap.model.exception.LdapException

bindAsync

public BindFuture bindAsync()
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Asynchronous Bind on a server, using the LdapConnectionConfig informations.

Specified by:
bindAsync in interface LdapAsyncConnection
Returns:
the bind operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if some IO error occurred

anonymousBindAsync

public BindFuture anonymousBindAsync()
                              throws org.apache.directory.api.ldap.model.exception.LdapException,
                                     IOException
Anonymous asynchronous Bind on a server.

Specified by:
anonymousBindAsync in interface LdapAsyncConnection
Returns:
the bind operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if some IO error occurred

bindAsync

public BindFuture bindAsync(String name)
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Asynchronous unauthenticated authentication bind

Parameters:
name - The name we use to authenticate the user. It must be a valid Dn
Returns:
The BindResponse LdapResponse
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if an I/O exception occurred

bindAsync

public BindFuture bindAsync(String name,
                            String credentials)
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Simple asynchronous Bind on a server.

Specified by:
bindAsync in interface LdapAsyncConnection
Parameters:
name - The name we use to authenticate the user, it must be a valid Dn
credentials - The password, it can't be null
Returns:
the bind operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if some IO error occurred

bindAsync

public BindFuture bindAsync(org.apache.directory.api.ldap.model.name.Dn name)
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Asynchronous unauthenticated authentication Bind on a server.

Parameters:
name - The name we use to authenticate the user. It must be a valid Dn
Returns:
The BindResponse LdapResponse
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if an I/O exception occurred

bindAsync

public BindFuture bindAsync(org.apache.directory.api.ldap.model.name.Dn name,
                            String credentials)
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Simple asynchronous Bind on a server.

Specified by:
bindAsync in interface LdapAsyncConnection
Parameters:
name - The name we use to authenticate the user, it must be a valid Dn
credentials - The password, it can't be null
Returns:
the bind operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if some IO error occurred

bind

public org.apache.directory.api.ldap.model.message.BindResponse bind(org.apache.directory.api.ldap.model.message.BindRequest bindRequest)
                                                              throws org.apache.directory.api.ldap.model.exception.LdapException,
                                                                     IOException
Bind to the server using a BindRequest object.

Specified by:
bind in interface LdapConnection
Parameters:
bindRequest - The BindRequest POJO containing all the needed parameters
Returns:
A LdapResponse containing the result
Throws:
IOException - if an I/O exception occurred
org.apache.directory.api.ldap.model.exception.LdapException

bindAsync

public BindFuture bindAsync(org.apache.directory.api.ldap.model.message.BindRequest bindRequest)
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Do an asynchronous bind, based on a BindRequest.

Specified by:
bindAsync in interface LdapAsyncConnection
Parameters:
bindRequest - The BindRequest to send
Returns:
the bind operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if some IO error occurred

bind

public org.apache.directory.api.ldap.model.message.BindResponse bind(CramMd5Request request)
                                                              throws org.apache.directory.api.ldap.model.exception.LdapException,
                                                                     IOException
Bind to the server using a CramMd5Request object.

Parameters:
request - The CramMd5Request POJO containing all the needed parameters
Returns:
A LdapResponse containing the result
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if an I/O exception occurred

bindAsync

public BindFuture bindAsync(CramMd5Request request)
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Do an asynchronous bind, based on a CramMd5Request.

Parameters:
request - The CramMd5Request POJO containing all the needed parameters
Returns:
The bind operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if an I/O exception occurred

bind

public org.apache.directory.api.ldap.model.message.BindResponse bind(DigestMd5Request request)
                                                              throws org.apache.directory.api.ldap.model.exception.LdapException,
                                                                     IOException
Bind to the server using a DigestMd5Request object.

Parameters:
request - The DigestMd5Request POJO containing all the needed parameters
Returns:
A LdapResponse containing the result
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if an I/O exception occurred

bindAsync

public BindFuture bindAsync(DigestMd5Request request)
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Do an asynchronous bind, based on a DigestMd5Request.

Parameters:
request - The DigestMd5Request POJO containing all the needed parameters
Returns:
The bind operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if an I/O exception occurred

bind

public org.apache.directory.api.ldap.model.message.BindResponse bind(GssApiRequest request)
                                                              throws org.apache.directory.api.ldap.model.exception.LdapException,
                                                                     IOException
Bind to the server using a GssApiRequest object.

Parameters:
request - The GssApiRequest POJO containing all the needed parameters
Returns:
A LdapResponse containing the result
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if an I/O exception occurred

bindAsync

public BindFuture bindAsync(GssApiRequest request)
                     throws org.apache.directory.api.ldap.model.exception.LdapException,
                            IOException
Do an asynchronous bind, based on a GssApiRequest.

Parameters:
request - The GssApiRequest POJO containing all the needed parameters
Returns:
The bind operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
IOException - if an I/O exception occurred

search

public org.apache.directory.api.ldap.model.cursor.EntryCursor search(org.apache.directory.api.ldap.model.name.Dn baseDn,
                                                                     String filter,
                                                                     org.apache.directory.api.ldap.model.message.SearchScope scope,
                                                                     String... attributes)
                                                              throws org.apache.directory.api.ldap.model.exception.LdapException
Do a search, on the base object, using the given filter. The SearchRequest parameters default to : Scope : ONE DerefAlias : ALWAYS SizeLimit : none TimeLimit : none TypesOnly : false Attributes : all the user's attributes. This method is blocking.

Specified by:
search in interface LdapConnection
Parameters:
baseDn - The base for the search. It must be a valid Dn, and can't be emtpy
filter - The filter to use for this search. It can't be empty
scope - The search scope : OBJECT, ONELEVEL or SUBTREE
attributes - The attributes to use for this search
Returns:
An EntryCursor on the result.
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

search

public org.apache.directory.api.ldap.model.cursor.EntryCursor search(String baseDn,
                                                                     String filter,
                                                                     org.apache.directory.api.ldap.model.message.SearchScope scope,
                                                                     String... attributes)
                                                              throws org.apache.directory.api.ldap.model.exception.LdapException
Do a search, on the base object, using the given filter. The SearchRequest parameters default to : Scope : ONE DerefAlias : ALWAYS SizeLimit : none TimeLimit : none TypesOnly : false Attributes : all the user's attributes. This method is blocking.

Specified by:
search in interface LdapConnection
Parameters:
baseDn - The base for the search. It must be a valid Dn, and can't be emtpy
filter - The filter to use for this search. It can't be empty
scope - The search scope : OBJECT, ONELEVEL or SUBTREE
attributes - The attributes to use for this search
Returns:
An EntryCursor on the result.
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

searchAsync

public SearchFuture searchAsync(org.apache.directory.api.ldap.model.name.Dn baseDn,
                                String filter,
                                org.apache.directory.api.ldap.model.message.SearchScope scope,
                                String... attributes)
                         throws org.apache.directory.api.ldap.model.exception.LdapException
Do an asynchronous search, on the base object, using the given filter. The SearchRequest parameters default to :
 Scope : ONE
 DerefAlias : ALWAYS
 SizeLimit : none
 TimeLimit : none
 TypesOnly : false
 Attributes : all the user's attributes.
 This method is blocking.
 

Specified by:
searchAsync in interface LdapAsyncConnection
Parameters:
baseDn - The base for the search, it must be a valid Dn, and can't be empty
filter - The filter to use for this search, it can't be empty
scope - The search scope : OBJECT, ONELEVEL or SUBTREE
attributes - The attributes for this search
Returns:
the search operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred

searchAsync

public SearchFuture searchAsync(String baseDn,
                                String filter,
                                org.apache.directory.api.ldap.model.message.SearchScope scope,
                                String... attributes)
                         throws org.apache.directory.api.ldap.model.exception.LdapException
Do an asynchronous search, on the base object, using the given filter. The SearchRequest parameters default to :
 Scope : ONE
 DerefAlias : ALWAYS
 SizeLimit : none
 TimeLimit : none
 TypesOnly : false
 Attributes : all the user's attributes.
 This method is blocking.
 

Specified by:
searchAsync in interface LdapAsyncConnection
Parameters:
baseDn - The base for the search, it must be a valid Dn, and can't be emtpy
filter - The filter to use for this search, it can't be empty
scope - The search scope : OBJECT, ONELEVEL or SUBTREE
attributes - The attributes for this search
Returns:
the search operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred

searchAsync

public SearchFuture searchAsync(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
                         throws org.apache.directory.api.ldap.model.exception.LdapException
Do a search, on the base object, using the given filter. The SearchRequest parameters default to :
 Scope : ONE
 DerefAlias : ALWAYS
 SizeLimit : none
 TimeLimit : none
 TypesOnly : false
 Attributes : all the user's attributes.
 This method is blocking.
 

Specified by:
searchAsync in interface LdapAsyncConnection
Parameters:
searchRequest - The search request to send to the server
Returns:
the search operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred

search

public org.apache.directory.api.ldap.model.cursor.SearchCursor search(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
                                                               throws org.apache.directory.api.ldap.model.exception.LdapException
Performs search in a synchronous mode.

Specified by:
search in interface LdapConnection
Parameters:
searchRequest - The search configuration
Returns:
a SearchCursor on the result.
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

unBind

public void unBind()
            throws org.apache.directory.api.ldap.model.exception.LdapException
UnBind from a server. This is a request which expect no response.

Specified by:
unBind in interface LdapConnection
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

setConnector

public void setConnector(org.apache.mina.core.service.IoConnector connector)
Set the connector to use.

Parameters:
connector - The connector to use

setTimeOut

public void setTimeOut(long timeout)
Set the timeOut for the responses. We wont wait longer than this value.

Specified by:
setTimeOut in interface LdapConnection
Parameters:
timeout - The timeout, in milliseconds

exceptionCaught

public void exceptionCaught(org.apache.mina.core.session.IoSession session,
                            Throwable cause)
                     throws Exception
Handle the exception we got.

Specified by:
exceptionCaught in interface org.apache.mina.core.service.IoHandler
Overrides:
exceptionCaught in class org.apache.mina.core.service.IoHandlerAdapter
Parameters:
session - The session we got the exception on
cause - The exception cause
Throws:
Exception - The t

messageReceived

public void messageReceived(org.apache.mina.core.session.IoSession session,
                            Object message)
                     throws Exception
Handle the incoming LDAP messages. This is where we feed the cursor for search requests, or call the listener.

Specified by:
messageReceived in interface org.apache.mina.core.service.IoHandler
Overrides:
messageReceived in class org.apache.mina.core.service.IoHandlerAdapter
Parameters:
session - The session that received a message
message - The received message
Throws:
Exception - If there is some error while processing the message

modify

public void modify(org.apache.directory.api.ldap.model.entry.Entry entry,
                   org.apache.directory.api.ldap.model.entry.ModificationOperation modOp)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Modifies all the attributes present in the entry by applying the same operation.

Specified by:
modify in interface LdapConnection
Parameters:
entry - the entry with the attributes to be modified
modOp - the operation to be applied on all the attributes of the above entry
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

modify

public void modify(org.apache.directory.api.ldap.model.name.Dn dn,
                   org.apache.directory.api.ldap.model.entry.Modification... modifications)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Applies all the modifications to the entry specified by its Dn.

Specified by:
modify in interface LdapConnection
Parameters:
dn - The entry's Dn
modifications - The list of modifications to be applied
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

modify

public void modify(String dn,
                   org.apache.directory.api.ldap.model.entry.Modification... modifications)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Applies all the modifications to the entry specified by its Dn.

Specified by:
modify in interface LdapConnection
Parameters:
dn - The entry's Dn
modifications - The list of modifications to be applied
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

modify

public org.apache.directory.api.ldap.model.message.ModifyResponse modify(org.apache.directory.api.ldap.model.message.ModifyRequest modRequest)
                                                                  throws org.apache.directory.api.ldap.model.exception.LdapException
Performs an modify operation based on the modifications present in the ModifyRequest.

Specified by:
modify in interface LdapConnection
Parameters:
modRequest - the request for modify operation
Returns:
the modify operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

modifyAsync

public ModifyFuture modifyAsync(org.apache.directory.api.ldap.model.message.ModifyRequest modRequest)
                         throws org.apache.directory.api.ldap.model.exception.LdapException
Performs an asynchronous modify operation based on the modifications present in the ModifyRequest.

Specified by:
modifyAsync in interface LdapAsyncConnection
Parameters:
modRequest - the request for modify operation
Returns:
the modify operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - in case of modify operation failure or timeout happens

rename

public void rename(String entryDn,
                   String newRdn)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Renames the given entryDn with new Rdn and deletes the old Rdn.

Specified by:
rename in interface LdapConnection
Parameters:
entryDn - the target Dn
newRdn - new Rdn for the target Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.rename(String, String, boolean)

rename

public void rename(org.apache.directory.api.ldap.model.name.Dn entryDn,
                   org.apache.directory.api.ldap.model.name.Rdn newRdn)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Renames the given entryDn with new Rdn and deletes the old Rdn.

Specified by:
rename in interface LdapConnection
Parameters:
entryDn - the target Dn
newRdn - new Rdn for the target Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.rename(org.apache.directory.api.ldap.model.name.Dn, org.apache.directory.api.ldap.model.name.Rdn, boolean)

rename

public void rename(String entryDn,
                   String newRdn,
                   boolean deleteOldRdn)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Renames the given entryDn with new Rdn and deletes the old Rdn if deleteOldRdn is set to true.

Specified by:
rename in interface LdapConnection
Parameters:
entryDn - the target Dn
newRdn - new Rdn for the target Dn
deleteOldRdn - flag to indicate whether to delete the old Rdn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.rename(org.apache.directory.api.ldap.model.name.Dn, org.apache.directory.api.ldap.model.name.Rdn, boolean)

rename

public void rename(org.apache.directory.api.ldap.model.name.Dn entryDn,
                   org.apache.directory.api.ldap.model.name.Rdn newRdn,
                   boolean deleteOldRdn)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Renames the given entryDn with new Rdn and deletes the old Rdn if deleteOldRdn is set to true.

Specified by:
rename in interface LdapConnection
Parameters:
entryDn - the target Dn
newRdn - new Rdn for the target Dn
deleteOldRdn - flag to indicate whether to delete the old Rdn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

move

public void move(String entryDn,
                 String newSuperiorDn)
          throws org.apache.directory.api.ldap.model.exception.LdapException
Moves the given entry Dn under the new superior Dn.

Specified by:
move in interface LdapConnection
Parameters:
entryDn - the Dn of the target entry
newSuperiorDn - Dn of the new parent/superior
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.move(org.apache.directory.api.ldap.model.name.Dn, org.apache.directory.api.ldap.model.name.Dn)

move

public void move(org.apache.directory.api.ldap.model.name.Dn entryDn,
                 org.apache.directory.api.ldap.model.name.Dn newSuperiorDn)
          throws org.apache.directory.api.ldap.model.exception.LdapException
Moves the given entry Dn under the new superior Dn.

Specified by:
move in interface LdapConnection
Parameters:
entryDn - the Dn of the target entry
newSuperiorDn - Dn of the new parent/superior
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

moveAndRename

public void moveAndRename(org.apache.directory.api.ldap.model.name.Dn entryDn,
                          org.apache.directory.api.ldap.model.name.Dn newDn)
                   throws org.apache.directory.api.ldap.model.exception.LdapException
Moves and renames the given entryDn. The old Rdn will be deleted.

Specified by:
moveAndRename in interface LdapConnection
Parameters:
entryDn - The original entry Dn
newDn - The new Entry Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.moveAndRename(org.apache.directory.api.ldap.model.name.Dn, org.apache.directory.api.ldap.model.name.Dn, boolean)

moveAndRename

public void moveAndRename(String entryDn,
                          String newDn)
                   throws org.apache.directory.api.ldap.model.exception.LdapException
Moves and renames the given entryDn.The old Rdn will be deleted

Specified by:
moveAndRename in interface LdapConnection
Parameters:
entryDn - The original entry Dn
newDn - The new Entry Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.moveAndRename(org.apache.directory.api.ldap.model.name.Dn, org.apache.directory.api.ldap.model.name.Dn, boolean)

moveAndRename

public void moveAndRename(org.apache.directory.api.ldap.model.name.Dn entryDn,
                          org.apache.directory.api.ldap.model.name.Dn newDn,
                          boolean deleteOldRdn)
                   throws org.apache.directory.api.ldap.model.exception.LdapException
Moves and renames the given entryDn. The old Rdn will be deleted if requested.

Specified by:
moveAndRename in interface LdapConnection
Parameters:
entryDn - The original entry Dn
newDn - The new Entry Dn
deleteOldRdn - Tells if the old Rdn must be removed
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

moveAndRename

public void moveAndRename(String entryDn,
                          String newDn,
                          boolean deleteOldRdn)
                   throws org.apache.directory.api.ldap.model.exception.LdapException
Moves and renames the given entryDn. The old Rdn will be deleted if requested.

Specified by:
moveAndRename in interface LdapConnection
Parameters:
entryDn - The original entry Dn
newDn - The new Entry Dn
deleteOldRdn - Tells if the old Rdn must be removed
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

modifyDn

public org.apache.directory.api.ldap.model.message.ModifyDnResponse modifyDn(org.apache.directory.api.ldap.model.message.ModifyDnRequest modDnRequest)
                                                                      throws org.apache.directory.api.ldap.model.exception.LdapException
Performs the modifyDn operation based on the given ModifyDnRequest.

Specified by:
modifyDn in interface LdapConnection
Parameters:
modDnRequest - the request
Returns:
modifyDn operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

modifyDnAsync

public ModifyDnFuture modifyDnAsync(org.apache.directory.api.ldap.model.message.ModifyDnRequest modDnRequest)
                             throws org.apache.directory.api.ldap.model.exception.LdapException
Performs the modifyDn operation based on the given ModifyDnRequest.

Specified by:
modifyDnAsync in interface LdapAsyncConnection
Parameters:
modDnRequest - the request
Returns:
modifyDn operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred

delete

public void delete(String dn)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Deletes the entry with the given Dn.

Specified by:
delete in interface LdapConnection
Parameters:
dn - the target entry's Dn as a String
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

delete

public void delete(org.apache.directory.api.ldap.model.name.Dn dn)
            throws org.apache.directory.api.ldap.model.exception.LdapException
Deletes the entry with the given Dn.

Specified by:
delete in interface LdapConnection
Parameters:
dn - the target entry's Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

deleteTree

public void deleteTree(org.apache.directory.api.ldap.model.name.Dn dn)
                throws org.apache.directory.api.ldap.model.exception.LdapException
deletes the entry with the given Dn, and all its children

Parameters:
dn - the target entry's Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - If the Dn is not valid or if the deletion failed

deleteTree

public void deleteTree(String dn)
                throws org.apache.directory.api.ldap.model.exception.LdapException
deletes the entry with the given Dn, and all its children

Parameters:
dn - the target entry's Dn as a String
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - If the Dn is not valid or if the deletion failed

delete

public org.apache.directory.api.ldap.model.message.DeleteResponse delete(org.apache.directory.api.ldap.model.message.DeleteRequest deleteRequest)
                                                                  throws org.apache.directory.api.ldap.model.exception.LdapException
Performs a delete operation based on the delete request object.

Specified by:
delete in interface LdapConnection
Parameters:
deleteRequest - the delete operation's request
Returns:
delete operation's response, null if a non-null listener value is provided
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

deleteAsync

public DeleteFuture deleteAsync(org.apache.directory.api.ldap.model.message.DeleteRequest deleteRequest)
                         throws org.apache.directory.api.ldap.model.exception.LdapException
Performs an asynchronous delete operation based on the delete request object.

Specified by:
deleteAsync in interface LdapAsyncConnection
Parameters:
deleteRequest - the delete operation's request
Returns:
delete operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - If the Dn is not valid or if the deletion failed

compare

public boolean compare(String dn,
                       String attributeName,
                       String value)
                throws org.apache.directory.api.ldap.model.exception.LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.

Specified by:
compare in interface LdapConnection
Parameters:
dn - the target entry's String Dn
attributeName - the attribute's name
value - a String value with which the target entry's attribute value to be compared with
Returns:
compare operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

compare

public boolean compare(String dn,
                       String attributeName,
                       byte[] value)
                throws org.apache.directory.api.ldap.model.exception.LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.

Specified by:
compare in interface LdapConnection
Parameters:
dn - the target entry's String Dn
attributeName - the attribute's name
value - a byte[] value with which the target entry's attribute value to be compared with
Returns:
compare operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

compare

public boolean compare(String dn,
                       String attributeName,
                       org.apache.directory.api.ldap.model.entry.Value<?> value)
                throws org.apache.directory.api.ldap.model.exception.LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.

Specified by:
compare in interface LdapConnection
Parameters:
dn - the target entry's String Dn
attributeName - the attribute's name
value - a Value value with which the target entry's attribute value to be compared with
Returns:
compare operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

compare

public boolean compare(org.apache.directory.api.ldap.model.name.Dn dn,
                       String attributeName,
                       String value)
                throws org.apache.directory.api.ldap.model.exception.LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.

Specified by:
compare in interface LdapConnection
Parameters:
dn - the target entry's Dn
attributeName - the attribute's name
value - a String value with which the target entry's attribute value to be compared with
Returns:
compare operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

compare

public boolean compare(org.apache.directory.api.ldap.model.name.Dn dn,
                       String attributeName,
                       byte[] value)
                throws org.apache.directory.api.ldap.model.exception.LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.

Specified by:
compare in interface LdapConnection
Parameters:
dn - the target entry's Dn
attributeName - the attribute's name
value - a byte[] value with which the target entry's attribute value to be compared with
Returns:
compare operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

compare

public boolean compare(org.apache.directory.api.ldap.model.name.Dn dn,
                       String attributeName,
                       org.apache.directory.api.ldap.model.entry.Value<?> value)
                throws org.apache.directory.api.ldap.model.exception.LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given Dn.

Specified by:
compare in interface LdapConnection
Parameters:
dn - the target entry's Dn
attributeName - the attribute's name
value - a Value value with which the target entry's attribute value to be compared with
Returns:
compare operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

compare

public org.apache.directory.api.ldap.model.message.CompareResponse compare(org.apache.directory.api.ldap.model.message.CompareRequest compareRequest)
                                                                    throws org.apache.directory.api.ldap.model.exception.LdapException
Compares an entry's attribute's value with that of the given value.

Specified by:
compare in interface LdapConnection
Parameters:
compareRequest - the CompareRequest which contains the target Dn, attribute name and value
Returns:
compare operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

compareAsync

public CompareFuture compareAsync(org.apache.directory.api.ldap.model.message.CompareRequest compareRequest)
                           throws org.apache.directory.api.ldap.model.exception.LdapException
Asynchronously compares an entry's attribute's value with that of the given value

Specified by:
compareAsync in interface LdapAsyncConnection
Parameters:
compareRequest - the CompareRequest which contains the target Dn, attribute name and value
Returns:
compare operation's future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred

extended

public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(String oid)
                                                                      throws org.apache.directory.api.ldap.model.exception.LdapException
Sends a extended operation request to the server with the given OID and no value.

Specified by:
extended in interface LdapConnection
Parameters:
oid - the object identifier of the extended operation
Returns:
extended operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])

extended

public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(String oid,
                                                                             byte[] value)
                                                                      throws org.apache.directory.api.ldap.model.exception.LdapException
Sends a extended operation request to the server with the given OID and value.

Specified by:
extended in interface LdapConnection
Parameters:
oid - the object identifier of the extended operation
value - value to be used by the extended operation, can be a null value
Returns:
extended operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])

extended

public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.asn1.util.Oid oid)
                                                                      throws org.apache.directory.api.ldap.model.exception.LdapException
Sends a extended operation request to the server with the given OID and no value.

Specified by:
extended in interface LdapConnection
Parameters:
oid - the object identifier of the extended operation
Returns:
extended operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])

extended

public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.asn1.util.Oid oid,
                                                                             byte[] value)
                                                                      throws org.apache.directory.api.ldap.model.exception.LdapException
Sends a extended operation request to the server with the given OID and value.

Specified by:
extended in interface LdapConnection
Parameters:
oid - the object identifier of the extended operation
value - value to be used by the extended operation, can be a null value
Returns:
extended operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

extended

public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.ldap.model.message.ExtendedRequest extendedRequest)
                                                                      throws org.apache.directory.api.ldap.model.exception.LdapException
Performs an extended operation based on the Extended request object.

Specified by:
extended in interface LdapConnection
Parameters:
extendedRequest - the extended operation's request
Returns:
Extended operation's response
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

extendedAsync

public ExtendedFuture extendedAsync(org.apache.directory.api.ldap.model.message.ExtendedRequest extendedRequest)
                             throws org.apache.directory.api.ldap.model.exception.LdapException
Asynchronously requests the server to perform an extended operation based on the given request.

Specified by:
extendedAsync in interface LdapAsyncConnection
Parameters:
extendedRequest - the object containing the details of the extended operation to be performed
Returns:
extended operation's Future
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred

exists

public boolean exists(String dn)
               throws org.apache.directory.api.ldap.model.exception.LdapException
Tells if an Entry exists in the server.

Specified by:
exists in interface LdapConnection
Parameters:
dn - The Dn for the entry we want to check the existence
Returns:
true if the entry exists, false otherwise. Note that if the entry exists but if the user does not have the permission to read it, false will also be returned
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

exists

public boolean exists(org.apache.directory.api.ldap.model.name.Dn dn)
               throws org.apache.directory.api.ldap.model.exception.LdapException
Tells if an Entry exists in the server.

Specified by:
exists in interface LdapConnection
Parameters:
dn - The Dn for the entry we want to check the existence
Returns:
true if the entry exists, false otherwise. Note that if the entry exists but if the user does not have the permission to read it, false will also be returned
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

getRootDse

public org.apache.directory.api.ldap.model.entry.Entry getRootDse()
                                                           throws org.apache.directory.api.ldap.model.exception.LdapException
Get back the RooDSE from the connected server. We only return the user attributes.

Specified by:
getRootDse in interface LdapConnection
Returns:
The Entry containing all the information about the rootDSE
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

getRootDse

public org.apache.directory.api.ldap.model.entry.Entry getRootDse(String... attributes)
                                                           throws org.apache.directory.api.ldap.model.exception.LdapException
Get back the RooDSE from the connected server. The user can provide the list of attributes he wants to get back. Sending "*" will return all the user attributes, sending "+" will return all the operational attributes;

Specified by:
getRootDse in interface LdapConnection
Parameters:
attributes - The list of attributes to return
Returns:
The Entry containing all the information about the rootDSE
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

lookup

public org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn)
                                                       throws org.apache.directory.api.ldap.model.exception.LdapException
Searches for an entry having the given Dn.

Specified by:
lookup in interface LdapConnection
Parameters:
dn - the Dn of the entry to be fetched
Returns:
the Entry with the given Dn or null if no entry exists with that Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.lookup(org.apache.directory.api.ldap.model.name.Dn, String...)

lookup

public org.apache.directory.api.ldap.model.entry.Entry lookup(String dn)
                                                       throws org.apache.directory.api.ldap.model.exception.LdapException
Searches for an entry having the given Dn.

Specified by:
lookup in interface LdapConnection
Parameters:
dn - the Dn of the entry to be fetched
Returns:
the Entry with the given Dn or null if no entry exists with that Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.lookup(String, String...)

lookup

public org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn,
                                                              String... attributes)
                                                       throws org.apache.directory.api.ldap.model.exception.LdapException
Searches for an entry having the given Dn.

Specified by:
lookup in interface LdapConnection
Parameters:
dn - the Dn of the entry to be fetched
attributes - the attributes to be returned along with entry
Returns:
the Entry with the given Dn or null if no entry exists with that Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

lookup

public org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn,
                                                              org.apache.directory.api.ldap.model.message.Control[] controls,
                                                              String... attributes)
                                                       throws org.apache.directory.api.ldap.model.exception.LdapException
Searches for an entry having the given Dn.

Specified by:
lookup in interface LdapConnection
Parameters:
dn - the Dn of the entry to be fetched
controls - the controls to use
attributes - the attributes to be returned along with entry
Returns:
the Entry with the given Dn or null if no entry exists with that Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

lookup

public org.apache.directory.api.ldap.model.entry.Entry lookup(String dn,
                                                              String... attributes)
                                                       throws org.apache.directory.api.ldap.model.exception.LdapException
Searches for an entry having the given Dn.

Specified by:
lookup in interface LdapConnection
Parameters:
dn - the Dn of the entry to be fetched
attributes - the attributes to be returned along with entry
Returns:
the Entry with the given Dn or null if no entry exists with that Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.lookup(org.apache.directory.api.ldap.model.name.Dn, String...)

lookup

public org.apache.directory.api.ldap.model.entry.Entry lookup(String dn,
                                                              org.apache.directory.api.ldap.model.message.Control[] controls,
                                                              String... attributes)
                                                       throws org.apache.directory.api.ldap.model.exception.LdapException
Searches for an entry having the given Dn.

Specified by:
lookup in interface LdapConnection
Parameters:
dn - the Dn of the entry to be fetched
controls - the controls to use
attributes - the attributes to be returned along with entry
Returns:
the Entry with the given Dn or null if no entry exists with that Dn
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
LdapConnection.lookup(org.apache.directory.api.ldap.model.name.Dn, String...)

isControlSupported

public boolean isControlSupported(String controlOID)
                           throws org.apache.directory.api.ldap.model.exception.LdapException
Checks if a control with the given OID is supported.

Specified by:
isControlSupported in interface LdapConnection
Parameters:
controlOID - the OID of the control
Returns:
true if the control is supported, false otherwise
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

getSupportedControls

public List<String> getSupportedControls()
                                  throws org.apache.directory.api.ldap.model.exception.LdapException
Get the Controls supported by server.

Specified by:
getSupportedControls in interface LdapConnection
Returns:
a list of control OIDs supported by server
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

loadSchema

public void loadSchema()
                throws org.apache.directory.api.ldap.model.exception.LdapException
Loads all the default schemas that are bundled with the API.

Note: This method enables all schemas prior to loading

Specified by:
loadSchema in interface LdapConnection
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

loadSchema

public void loadSchema(org.apache.directory.api.ldap.model.schema.registries.SchemaLoader loader)
                throws org.apache.directory.api.ldap.model.exception.LdapException
loads schema using the specified schema loader

Parameters:
loader - the SchemaLoader to be used to load schema
Throws:
org.apache.directory.api.ldap.model.exception.LdapException

addSchema

public void addSchema(File schemaFile)
               throws org.apache.directory.api.ldap.model.exception.LdapException
parses the given schema file present in OpenLDAP schema format and adds all the SchemaObjects present in it to the SchemaManager

Parameters:
schemaFile - the schema file in OpenLDAP schema format
Throws:
org.apache.directory.api.ldap.model.exception.LdapException - in case of any errors while parsing

addSchema

public void addSchema(String schemaFileName)
               throws org.apache.directory.api.ldap.model.exception.LdapException
Throws:
org.apache.directory.api.ldap.model.exception.LdapException
See Also:
addSchema(File)

getCodecService

public org.apache.directory.api.ldap.codec.api.LdapApiService getCodecService()
Gets the LDAP CODEC service responsible for encoding and decoding messages.

Specified by:
getCodecService in interface LdapConnection
Returns:
The LDAP CODEC service.

getSchemaManager

public org.apache.directory.api.ldap.model.schema.SchemaManager getSchemaManager()

Specified by:
getSchemaManager in interface LdapConnection
Returns:
The SchemaManager associated with this LdapConection if any

getConfig

public LdapConnectionConfig getConfig()
gives the configuration information of the connection

Specified by:
getConfig in interface LdapAsyncConnection
Returns:
the configuration of the connection

doesFutureExistFor

public boolean doesFutureExistFor(int messageId)
Checks if there is a ResponseFuture associated with the given message ID.

Specified by:
doesFutureExistFor in interface LdapConnection
Parameters:
messageId - ID of the request
Returns:
true if there is a non-null future exists, false otherwise

addConnectionClosedEventListener

public void addConnectionClosedEventListener(ConnectionClosedEventListener ccListener)
Adds the connection closed event listener.

Parameters:
ccListener - the connection closed listener

sessionCreated

public void sessionCreated(org.apache.mina.core.session.IoSession session)
                    throws Exception
This method is called when a new session is created. We will store some informations that the session will need to process incoming requests.

Specified by:
sessionCreated in interface org.apache.mina.core.service.IoHandler
Overrides:
sessionCreated in class org.apache.mina.core.service.IoHandlerAdapter
Parameters:
session - the newly created session
Throws:
Exception

sessionClosed

public void sessionClosed(org.apache.mina.core.session.IoSession session)
                   throws Exception

Specified by:
sessionClosed in interface org.apache.mina.core.service.IoHandler
Overrides:
sessionClosed in class org.apache.mina.core.service.IoHandlerAdapter
Throws:
Exception

startTls

public void startTls()
              throws org.apache.directory.api.ldap.model.exception.LdapException
Sends the StartTLS extended request to server and adds a security layer upon receiving a response with successful result. Note that we will use the default LDAP connection.

Throws:
org.apache.directory.api.ldap.model.exception.LdapException

getBinaryAttributeDetector

public org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector getBinaryAttributeDetector()

Specified by:
getBinaryAttributeDetector in interface LdapConnection
Returns:
the object responsible for the detection of binary attributes

setBinaryAttributeDetector

public void setBinaryAttributeDetector(org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector binaryAttributeDetector)
Sets the object responsible for the detection of binary attributes

Specified by:
setBinaryAttributeDetector in interface LdapConnection


Copyright © 2009-2013 The Apache Software Foundation. All Rights Reserved.