Class LdapNetworkConnection
- java.lang.Object
-
- org.apache.mina.core.service.IoHandlerAdapter
-
- org.apache.directory.ldap.client.api.AbstractLdapConnection
-
- org.apache.directory.ldap.client.api.LdapNetworkConnection
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,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
-
-
Constructor Summary
Constructors Constructor Description 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(boolean useSsl, LdapApiService ldapApiService)
Creates a new LdapNetworkConnection instanceLdapNetworkConnection(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, boolean useSsl, LdapApiService ldapApiService)
Creates a new LdapNetworkConnection instanceLdapNetworkConnection(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.LdapNetworkConnection(String server, int port, boolean useSsl, LdapApiService ldapApiService)
Create a new instance of a LdapConnection on a given server and a given port.LdapNetworkConnection(String server, int port, TrustManager... trustManagers)
Create a new instance of a LdapConnection on a given server, and a give port.LdapNetworkConnection(String server, int port, LdapApiService ldapApiService)
Create a new instance of a LdapConnection on a given server and a given port.LdapNetworkConnection(String server, LdapApiService ldapApiService)
Creates a new LdapNetworkConnection instanceLdapNetworkConnection(LdapConnectionConfig config)
Creates a new instance of LdapConnection with the given connection configuration.LdapNetworkConnection(LdapConnectionConfig config, LdapApiService ldapApiService)
Creates a new LdapNetworkConnection instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abandon(int messageId)
Abandons a request submitted to the server for performing a particular operation.void
abandon(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
add(Entry entry)
Add an entry to the server.AddResponse
add(AddRequest addRequest)
Add an entry present in theAddRequest
to the server.AddFuture
addAsync(Entry entry)
Add an entry to the server asynchronously.AddFuture
addAsync(AddRequest addRequest)
Add an entry present in the AddRequest to the server.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 SchemaManagervoid
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 theLdapConnectionConfig
information of this connection.BindResponse
bind(BindRequest bindRequest)
Bind to the server using a bind request object.BindResponse
bind(SaslCramMd5Request request)
Bind to the server using a CramMd5Request object.BindResponse
bind(SaslDigestMd5Request request)
Bind to the server using a DigestMd5Request object.BindResponse
bind(SaslExternalRequest request)
Bind to the server using a SaslExternalRequest object.BindResponse
bind(SaslGssApiRequest request)
Bind to the server using a GssApiRequest object.BindResponse
bind(SaslRequest request)
Bind to the server using a SaslRequest object.BindFuture
bindAsync()
Asynchronous Bind on a server, using the LdapConnectionConfig informations.BindFuture
bindAsync(String name)
Asynchronous unauthenticated authentication bindBindFuture
bindAsync(String name, String credentials)
Simple asynchronous Bind on a server.BindFuture
bindAsync(BindRequest bindRequest)
Do an asynchronous bind, based on a BindRequest.BindFuture
bindAsync(Dn name)
Asynchronous unauthenticated authentication Bind on a server.BindFuture
bindAsync(Dn name, String credentials)
Simple asynchronous Bind on a server.BindFuture
bindAsync(SaslGssApiRequest request)
Do an asynchronous bind, based on a GssApiRequest.BindFuture
bindAsync(SaslRequest request)
Do an asynchronous bind, based on a SaslPlainRequest.BindFuture
bindSasl(SaslRequest saslRequest)
Process the SASL Bind.BindResponse
bindSaslCramMd5(String userName, String credentials)
Bind to the server using the SASL CRAM-MD5 mechanism.BindResponse
bindSaslDigestMd5(String userName, String credentials)
Bind to the server using the SASL DIGEST-MD5 mechanism.BindResponse
bindSaslPlain(String authcid, String credentials)
SASL PLAIN Bind on a server.BindResponse
bindSaslPlain(String authzid, String authcid, String credentials)
SASL PLAIN Bind on a server.void
close()
Disconnect from the remote LDAP server.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 distinguished name.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 distinguished name.boolean
compare(String dn, String attributeName, 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 distinguished name.CompareResponse
compare(CompareRequest compareRequest)
Compares an entry's attribute's value with that of the given value.boolean
compare(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 distinguished name.boolean
compare(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 distinguished name.boolean
compare(Dn dn, String attributeName, 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 distinguished name.CompareFuture
compareAsync(CompareRequest compareRequest)
Asynchronously compares an entry's attribute's value with that of the given valueboolean
connect()
Connect to the remote LDAP server.void
delete(String dn)
Deletes the entry with the given distinguished name.DeleteResponse
delete(DeleteRequest deleteRequest)
Performs a delete operation based on the delete request object.void
delete(Dn dn)
Deletes the entry with the given distinguished name.DeleteFuture
deleteAsync(DeleteRequest deleteRequest)
Performs an asynchronous delete operation based on the delete request object.void
deleteTree(String dn)
deletes the entry with the given Dn, and all its childrenvoid
deleteTree(Dn dn)
deletes the entry with the given Dn, and all its childrenboolean
doesFutureExistFor(int messageId)
Checks if there is a ResponseFuture associated with the given message ID.void
event(org.apache.mina.core.session.IoSession session, org.apache.mina.filter.FilterEvent event)
void
exceptionCaught(org.apache.mina.core.session.IoSession session, Throwable cause)
Handle the exception we got.boolean
exists(String dn)
Tells if an entry exists in the server.boolean
exists(Dn dn)
Tells if an Entry exists in the server.ExtendedResponse
extended(String oid)
Sends a extended operation request to the server with the given OID and no value.ExtendedResponse
extended(String oid, byte[] value)
Sends a extended operation request to the server with the given OID and value.ExtendedResponse
extended(Oid oid)
Sends a extended operation request to the server with the given OID and no value.ExtendedResponse
extended(Oid oid, byte[] value)
Sends a extended operation request to the server with the given OID and value.ExtendedResponse
extended(ExtendedRequest extendedRequest)
Performs an extended operation based on the extended request object.ExtendedFuture
extendedAsync(ExtendedRequest extendedRequest)
Asynchronously requests the server to perform an extended operation based on the given request.BinaryAttributeDetector
getBinaryAttributeDetector()
LdapApiService
getCodecService()
Gets the LDAP CODEC service responsible for encoding and decoding messages.LdapConnectionConfig
getConfig()
gives the configuration information of the connectionEntry
getRootDse()
Get back the RooDSE from the connected server.Entry
getRootDse(String... attributes)
Get back the RooDSE from the connected server.SchemaManager
getSchemaManager()
org.apache.mina.transport.socket.SocketSessionConfig
getSocketSessionConfig()
List<String>
getSupportedControls()
Get the Controls supported by server.long
getTimeout(long connectionTimoutInMS, int searchTimeLimitInSeconds)
Get the largest timeout from the search time limit and the connection timeout.void
inputClosed(org.apache.mina.core.session.IoSession session)
boolean
isAuthenticated()
Check if the connection is authenticated.boolean
isConnected()
Check if the connection is establishedboolean
isControlSupported(String controlOID)
Checks if a control with the given OID is supported.boolean
isRequestCompleted(int messageId)
Checks if a request has been completed, or not.boolean
isSecured()
Tells if the connection is using a secured channelvoid
loadSchema()
Loads all the default schemas that are bundled with the API.
Note: This method enables all schemas prior to loading.void
loadSchema(SchemaLoader loader)
loads schema using the specified schema loadervoid
loadSchemaRelaxed()
Loads all the default schemas that are bundled with the API, in a relaxed mode.
Note: This method enables all schemas prior to loading.
The relaxed mode will allow inconsistencies in the schema.Entry
lookup(String dn)
Searches for an entry having the given distinguished name.Entry
lookup(String dn, String... attributes)
Searches for an entry having the given distinguished name.Entry
lookup(String dn, Control[] controls, String... attributes)
Searches for an entry having the given distinguished name.Entry
lookup(Dn dn)
Searches for an entry having the given distinguished name..Entry
lookup(Dn dn, String... attributes)
Searches for an entry having the given distinguished name.Entry
lookup(Dn dn, Control[] controls, String... attributes)
Searches for an entry having the given distinguished name.void
messageReceived(org.apache.mina.core.session.IoSession session, Object message)
Handle the incoming LDAP messages.void
modify(String dn, Modification... modifications)
Applies all the modifications to the entry specified by its distinguished name.void
modify(Entry entry, ModificationOperation modOp)
Modifies all the attributes present in the entry by applying the same operation.ModifyResponse
modify(ModifyRequest modRequest)
Performs an modify operation based on the modifications present in the modify request.void
modify(Dn dn, Modification... modifications)
Applies all the modifications to the entry specified by its distinguished name.ModifyFuture
modifyAsync(ModifyRequest modRequest)
Performs an asynchronous modify operation based on the modifications present in the ModifyRequest.ModifyDnResponse
modifyDn(ModifyDnRequest modDnRequest)
Performs the modifyDn operation based on the given request object.ModifyDnFuture
modifyDnAsync(ModifyDnRequest modDnRequest)
Performs the modifyDn operation based on the given ModifyDnRequest.void
move(String entryDn, String newSuperiorDn)
Moves the given entry distinguished name under the new superior distinguished name.void
move(Dn entryDn, Dn newSuperiorDn)
Moves the given entry distinguished name under the new superior distinguished name.void
moveAndRename(String entryDn, String newDn)
Moves and renames the given entry distinguished name.void
moveAndRename(String entryDn, String newDn, boolean deleteOldRdn)
Moves and renames the given entryDn.void
moveAndRename(Dn entryDn, Dn newDn)
Moves and renames the given entryDn.void
moveAndRename(Dn entryDn, Dn newDn, boolean deleteOldRdn)
Moves and renames the given entryDn.void
rename(String entryDn, String newRdn)
Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name.void
rename(String entryDn, String newRdn, boolean deleteOldRdn)
Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name if deleteOldRdn is set to true.void
rename(Dn entryDn, Rdn newRdn)
Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name.void
rename(Dn entryDn, Rdn newRdn, boolean deleteOldRdn)
Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name if deleteOldRdn is set to true.EntryCursor
search(String baseDn, String filter, SearchScope scope, String... attributes)
Do a search, on the base object, using the given filter and scope.SearchCursor
search(SearchRequest searchRequest)
Performs search using a search request object.EntryCursor
search(Dn baseDn, String filter, SearchScope scope, String... attributes)
Do a search, on the base object, using the given filter and scope.SearchFuture
searchAsync(String baseDn, String filter, SearchScope scope, String... attributes)
Do an asynchronous search, on the base object, using the given filter.SearchFuture
searchAsync(SearchRequest searchRequest)
Do a search, on the base object, using the given filter.SearchFuture
searchAsync(Dn baseDn, String filter, 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(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
setSchemaManager(SchemaManager schemaManager)
sets a SchemaManager to be used by this connectionvoid
setSocketSessionConfig(org.apache.mina.transport.socket.SocketSessionConfig socketSessionConfig)
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
-
Methods inherited from class org.apache.mina.core.service.IoHandlerAdapter
messageSent, sessionIdle, sessionOpened
-
Methods inherited from class java.lang.Object
equals, 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(LdapConnectionConfig config, LdapApiService ldapApiService)
Creates a new LdapNetworkConnection instance- Parameters:
config
- The configuration to useldapApiService
- The LDAP API Service to use
-
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(boolean useSsl, LdapApiService ldapApiService)
Creates a new LdapNetworkConnection instance- Parameters:
useSsl
- If we are going to create a secure connection or notldapApiService
- The LDAP API Service to use
-
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, LdapApiService ldapApiService)
Creates a new LdapNetworkConnection instance- Parameters:
server
- The server we want to be connected to. If null or empty, we will default to LocalHost.ldapApiService
- The LDAP API Service to use
-
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, boolean useSsl, LdapApiService ldapApiService)
Creates a new LdapNetworkConnection instance- 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.ldapApiService
- The LDAP API Service to use
-
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 toport
- The port the server is listening to
-
LdapNetworkConnection
public LdapNetworkConnection(String server, int port, LdapApiService ldapApiService)
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. If null or empty, we will default to LocalHost.port
- The port the server is listening onldapApiService
- The LDAP API Service to use
-
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 touseSsl
- A flag to tell if it's a SSL connection or not.
-
LdapNetworkConnection
public LdapNetworkConnection(String server, int port, TrustManager... trustManagers)
Create a new instance of a LdapConnection on a given server, and a give port. This SSL connection will use the provided TrustManagers- 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 totrustManagers
- The TrustManager to use
-
LdapNetworkConnection
public LdapNetworkConnection(String server, int port, boolean useSsl, LdapApiService ldapApiService)
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. If null or empty, we will default to LocalHost.port
- The port the server is listening onuseSsl
- A flag to tell if it's a SSL connection or not.ldapApiService
- The LDAP API Service to use
-
-
Method Detail
-
isConnected
public boolean isConnected()
Check if the connection is established- Specified by:
isConnected
in interfaceLdapConnection
- Returns:
true
if the connection is established
-
isAuthenticated
public boolean isAuthenticated()
Check if the connection is authenticated.- Specified by:
isAuthenticated
in interfaceLdapConnection
- Returns:
true
if the connection is authenticated
-
isSecured
public boolean isSecured()
Tells if the connection is using a secured channel- Returns:
- true if the session is using a secured channel
-
getTimeout
public long getTimeout(long connectionTimoutInMS, int searchTimeLimitInSeconds)
Get the largest timeout from the search time limit and the connection timeout.- Parameters:
connectionTimoutInMS
- Connection timeoutsearchTimeLimitInSeconds
- Search timeout- Returns:
- The largest timeout
-
connect
public boolean connect() throws LdapException
Connect to the remote LDAP server.- Specified by:
connect
in interfaceLdapConnection
- Returns:
true
if the connection is established, false otherwise- Throws:
LdapException
- if some error occurred
-
close
public void close()
Disconnect from the remote LDAP server.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceLdapConnection
-
add
public void add(Entry entry) throws LdapException
Add an entry to the server.- Specified by:
add
in interfaceLdapConnection
- Parameters:
entry
- The entry to add- Throws:
LdapException
- if some error occurred
-
addAsync
public AddFuture addAsync(Entry entry) throws 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 interfaceLdapAsyncConnection
- Parameters:
entry
- The entry to add- Returns:
- the add operation's future
- Throws:
LdapException
- if some error occurred
-
add
public AddResponse add(AddRequest addRequest) throws LdapException
Add an entry present in theAddRequest
to the server.- Specified by:
add
in interfaceLdapConnection
- Parameters:
addRequest
- the request object containing an entry and controls (if any)- Returns:
- the add operation's response
- Throws:
LdapException
- if some error occurred
-
addAsync
public AddFuture addAsync(AddRequest addRequest) throws LdapException
Add an entry present in the AddRequest to the server.- Specified by:
addAsync
in interfaceLdapAsyncConnection
- Parameters:
addRequest
- the request object containing an entry and controls(if any)- Returns:
- the add operation's future
- Throws:
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 interfaceLdapConnection
- Parameters:
messageId
- the ID of the request message sent to the server
-
abandon
public void abandon(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 interfaceLdapConnection
- Parameters:
abandonRequest
- the abandon operation's request
-
bind
public void bind() throws LdapException
Bind on a server, using theLdapConnectionConfig
information of this connection.- Specified by:
bind
in interfaceLdapConnection
- Throws:
LdapException
- if some error occurred
-
anonymousBind
public void anonymousBind() throws LdapException
Anonymous bind on a server.- Specified by:
anonymousBind
in interfaceLdapConnection
- Throws:
LdapException
- if some error occurred
-
bindAsync
public BindFuture bindAsync() throws LdapException
Asynchronous Bind on a server, using the LdapConnectionConfig informations.- Specified by:
bindAsync
in interfaceLdapAsyncConnection
- Returns:
- the bind operation's future
- Throws:
LdapException
- if some error occurred
-
anonymousBindAsync
public BindFuture anonymousBindAsync() throws LdapException
Anonymous asynchronous Bind on a server.- Specified by:
anonymousBindAsync
in interfaceLdapAsyncConnection
- Returns:
- the bind operation's future
- Throws:
LdapException
- if some error occurred
-
bindAsync
public BindFuture bindAsync(String name) throws LdapException
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:
LdapException
- if some error occurred
-
bindAsync
public BindFuture bindAsync(String name, String credentials) throws LdapException
Simple asynchronous Bind on a server.- Specified by:
bindAsync
in interfaceLdapAsyncConnection
- Parameters:
name
- The name we use to authenticate the user, it must be a valid Dncredentials
- The password, it can't be null- Returns:
- the bind operation's future
- Throws:
LdapException
- if some error occurred
-
bindAsync
public BindFuture bindAsync(Dn name) throws LdapException
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:
LdapException
- if some error occurred
-
bindAsync
public BindFuture bindAsync(Dn name, String credentials) throws LdapException
Simple asynchronous Bind on a server.- Specified by:
bindAsync
in interfaceLdapAsyncConnection
- Parameters:
name
- The name we use to authenticate the user, it must be a valid Dncredentials
- The password, it can't be null- Returns:
- the bind operation's future
- Throws:
LdapException
- if some error occurred
-
bind
public BindResponse bind(BindRequest bindRequest) throws LdapException
Bind to the server using a bind request object.- Specified by:
bind
in interfaceLdapConnection
- Parameters:
bindRequest
- The bind request object containing all the needed parameters- Returns:
- A
BindResponse
containing the result - Throws:
LdapException
- if some error occurred
-
bindAsync
public BindFuture bindAsync(BindRequest bindRequest) throws LdapException
Do an asynchronous bind, based on a BindRequest.- Specified by:
bindAsync
in interfaceLdapAsyncConnection
- Parameters:
bindRequest
- The BindRequest to send- Returns:
- the bind operation's future
- Throws:
LdapException
- if some error occurred
-
bindSaslPlain
public BindResponse bindSaslPlain(String authcid, String credentials) throws LdapException
SASL PLAIN Bind on a server.- Parameters:
authcid
- The Authentication identitycredentials
- The password. It can't be null- Returns:
- The BindResponse LdapResponse
- Throws:
LdapException
- if some error occurred
-
bindSaslPlain
public BindResponse bindSaslPlain(String authzid, String authcid, String credentials) throws LdapException
SASL PLAIN Bind on a server.- Parameters:
authzid
- The Authorization identityauthcid
- The Authentication identitycredentials
- The password. It can't be null- Returns:
- The BindResponse LdapResponse
- Throws:
LdapException
- if some error occurred
-
bind
public BindResponse bind(SaslRequest request) throws LdapException
Bind to the server using a SaslRequest object.- Specified by:
bind
in interfaceLdapConnection
- Parameters:
request
- The SaslRequest POJO containing all the needed parameters- Returns:
- A LdapResponse containing the result
- Throws:
LdapException
- if some error occurred
-
bindSaslCramMd5
public BindResponse bindSaslCramMd5(String userName, String credentials) throws LdapException
Bind to the server using the SASL CRAM-MD5 mechanism.- Parameters:
userName
- The user namecredentials
- The user credentials- Returns:
- A LdapResponse containing the result
- Throws:
LdapException
- if some error occurred
-
bindSaslDigestMd5
public BindResponse bindSaslDigestMd5(String userName, String credentials) throws LdapException
Bind to the server using the SASL DIGEST-MD5 mechanism.- Parameters:
userName
- The user namecredentials
- The user credentials- Returns:
- A LdapResponse containing the result
- Throws:
LdapException
- if some error occurred
-
bind
public BindResponse bind(SaslCramMd5Request request) throws LdapException
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:
LdapException
- if some error occurred
-
bindAsync
public BindFuture bindAsync(SaslRequest request) throws LdapException
Do an asynchronous bind, based on a SaslPlainRequest.- Parameters:
request
- The SaslPlainRequest POJO containing all the needed parameters- Returns:
- The bind operation's future
- Throws:
LdapException
- if some error occurred
-
bind
public BindResponse bind(SaslDigestMd5Request request) throws LdapException
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:
LdapException
- if some error occurred
-
bind
public BindResponse bind(SaslGssApiRequest request) throws LdapException
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:
LdapException
- if some error occurred
-
bind
public BindResponse bind(SaslExternalRequest request) throws LdapException
Bind to the server using a SaslExternalRequest object.- Parameters:
request
- The SaslExternalRequest POJO containing all the needed parameters- Returns:
- A LdapResponse containing the result
- Throws:
LdapException
- if some error occurred
-
bindAsync
public BindFuture bindAsync(SaslGssApiRequest request) throws LdapException
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:
LdapException
- if some error occurred
-
search
public EntryCursor search(Dn baseDn, String filter, SearchScope scope, String... attributes) throws LdapException
Do a search, on the base object, using the given filter and scope. The SearchRequest parameters default to- DerefAlias : ALWAYS
- SizeLimit : none
- TimeLimit : none
- TypesOnly : false
- Specified by:
search
in interfaceLdapConnection
- Parameters:
baseDn
- The base for the search. It must be a valid distinguished name and can't be emtpyfilter
- The filter to use for this search. It can't be emptyscope
- The search scope : OBJECT, ONELEVEL or SUBTREEattributes
- The attributes to use for this search- Returns:
- An
EntryCursor
on the result. - Throws:
LdapException
- if some error occurred
-
search
public EntryCursor search(String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException
Do a search, on the base object, using the given filter and scope. The SearchRequest parameters default to- DerefAlias : ALWAYS
- SizeLimit : none
- TimeLimit : none
- TypesOnly : false
- Specified by:
search
in interfaceLdapConnection
- Parameters:
baseDn
- The base for the search. It must be a valid distinguished name, and can't be emtpyfilter
- The filter to use for this search. It can't be emptyscope
- The search scope : OBJECT, ONELEVEL or SUBTREEattributes
- The attributes to use for this search- Returns:
- An
EntryCursor
on the result. - Throws:
LdapException
- if some error occurred
-
searchAsync
public SearchFuture searchAsync(Dn baseDn, String filter, SearchScope scope, String... attributes) throws 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 interfaceLdapAsyncConnection
- Parameters:
baseDn
- The base for the search, it must be a valid Dn, and can't be emptyfilter
- The filter to use for this search, it can't be emptyscope
- The search scope : OBJECT, ONELEVEL or SUBTREEattributes
- The attributes for this search- Returns:
- the search operation's future
- Throws:
LdapException
- if some error occurred
-
searchAsync
public SearchFuture searchAsync(String baseDn, String filter, SearchScope scope, String... attributes) throws 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 interfaceLdapAsyncConnection
- Parameters:
baseDn
- The base for the search, it must be a valid Dn, and can't be emtpyfilter
- The filter to use for this search, it can't be emptyscope
- The search scope : OBJECT, ONELEVEL or SUBTREEattributes
- The attributes for this search- Returns:
- the search operation's future
- Throws:
LdapException
- if some error occurred
-
searchAsync
public SearchFuture searchAsync(SearchRequest searchRequest) throws 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 interfaceLdapAsyncConnection
- Parameters:
searchRequest
- The search request to send to the server- Returns:
- the search operation's future
- Throws:
LdapException
- if some error occurred
-
search
public SearchCursor search(SearchRequest searchRequest) throws LdapException
Performs search using a search request object.- Specified by:
search
in interfaceLdapConnection
- Parameters:
searchRequest
- The search request object containing all the needed information- Returns:
- a search cursor on the result.
- Throws:
LdapException
- if some error occurred
-
unBind
public void unBind() throws LdapException
UnBind from a server. This is a request which expects no response.- Specified by:
unBind
in interfaceLdapConnection
- Throws:
LdapException
- if some error occurred
-
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 won't wait longer than this value.- Specified by:
setTimeOut
in interfaceLdapConnection
- 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 interfaceorg.apache.mina.core.service.IoHandler
- Overrides:
exceptionCaught
in classorg.apache.mina.core.service.IoHandlerAdapter
- Parameters:
session
- The session we got the exception oncause
- The exception cause- Throws:
Exception
- If we have had another exception
-
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 interfaceorg.apache.mina.core.service.IoHandler
- Overrides:
messageReceived
in classorg.apache.mina.core.service.IoHandlerAdapter
- Parameters:
session
- The session that received a messagemessage
- The received message- Throws:
Exception
- If there is some error while processing the message
-
modify
public void modify(Entry entry, ModificationOperation modOp) throws LdapException
Modifies all the attributes present in the entry by applying the same operation.- Specified by:
modify
in interfaceLdapConnection
- Parameters:
entry
- the entry with the attributes to be modifiedmodOp
- the operation to be applied on all the attributes of the above entry- Throws:
LdapException
- in case of modify operation failure or timeout happens
-
modify
public void modify(Dn dn, Modification... modifications) throws LdapException
Applies all the modifications to the entry specified by its distinguished name.- Specified by:
modify
in interfaceLdapConnection
- Parameters:
dn
- The entry's distinguished namemodifications
- The list of modifications to be applied- Throws:
LdapException
- in case of modify operation failure or timeout happens
-
modify
public void modify(String dn, Modification... modifications) throws LdapException
Applies all the modifications to the entry specified by its distinguished name.- Specified by:
modify
in interfaceLdapConnection
- Parameters:
dn
- The entry's distinguished name, it must be a valid distinguished name.modifications
- The list of modifications to be applied- Throws:
LdapException
- in case of modify operation failure or timeout happens
-
modify
public ModifyResponse modify(ModifyRequest modRequest) throws LdapException
Performs an modify operation based on the modifications present in the modify request.- Specified by:
modify
in interfaceLdapConnection
- Parameters:
modRequest
- the modify request object- Returns:
- the modify operation's response
- Throws:
LdapException
- in case of modify operation failure or timeout happens
-
modifyAsync
public ModifyFuture modifyAsync(ModifyRequest modRequest) throws LdapException
Performs an asynchronous modify operation based on the modifications present in the ModifyRequest.- Specified by:
modifyAsync
in interfaceLdapAsyncConnection
- Parameters:
modRequest
- the request for modify operation- Returns:
- the modify operation's future
- Throws:
LdapException
- in case of modify operation failure or timeout happens
-
rename
public void rename(String entryDn, String newRdn) throws LdapException
Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name.- Specified by:
rename
in interfaceLdapConnection
- Parameters:
entryDn
- the target distinguished name.newRdn
- new relative distinguished name for the target distinguished name.- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.rename(String, String, boolean)
-
rename
public void rename(Dn entryDn, Rdn newRdn) throws LdapException
Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name.- Specified by:
rename
in interfaceLdapConnection
- Parameters:
entryDn
- the target distinguished name.newRdn
- new relative distinguished name for the target distinguished name.- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.rename(Dn, Rdn, boolean)
-
rename
public void rename(String entryDn, String newRdn, boolean deleteOldRdn) throws LdapException
Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name if deleteOldRdn is set to true.- Specified by:
rename
in interfaceLdapConnection
- Parameters:
entryDn
- the target distinguished name.newRdn
- new relative distinguished name for the target distinguished name.deleteOldRdn
- flag to indicate whether to delete the old relative distinguished name- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.rename(Dn, Rdn, boolean)
-
rename
public void rename(Dn entryDn, Rdn newRdn, boolean deleteOldRdn) throws LdapException
Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name if deleteOldRdn is set to true.- Specified by:
rename
in interfaceLdapConnection
- Parameters:
entryDn
- the target distinguished name.newRdn
- new relative distinguished name for the target distinguished name.deleteOldRdn
- flag to indicate whether to delete the old relative distinguished name- Throws:
LdapException
- if some error occurred
-
move
public void move(String entryDn, String newSuperiorDn) throws LdapException
Moves the given entry distinguished name under the new superior distinguished name.- Specified by:
move
in interfaceLdapConnection
- Parameters:
entryDn
- the distinguished name of the target entrynewSuperiorDn
- distinguished name of the new parent/superior- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.move(Dn, Dn)
-
move
public void move(Dn entryDn, Dn newSuperiorDn) throws LdapException
Moves the given entry distinguished name under the new superior distinguished name.- Specified by:
move
in interfaceLdapConnection
- Parameters:
entryDn
- the distinguished name of the target entrynewSuperiorDn
- distinguished name of the new parent/superior- Throws:
LdapException
- if some error occurred
-
moveAndRename
public void moveAndRename(Dn entryDn, Dn newDn) throws LdapException
Moves and renames the given entryDn. The old relative distinguished name will be deleted.- Specified by:
moveAndRename
in interfaceLdapConnection
- Parameters:
entryDn
- The original entry distinguished name.newDn
- The new entry distinguished name.- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.moveAndRename(Dn, Dn, boolean)
-
moveAndRename
public void moveAndRename(String entryDn, String newDn) throws LdapException
Moves and renames the given entry distinguished name. The old relative distinguished name will be deleted- Specified by:
moveAndRename
in interfaceLdapConnection
- Parameters:
entryDn
- The original entry distinguished name.newDn
- The new entry distinguished name.- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.moveAndRename(Dn, Dn, boolean)
-
moveAndRename
public void moveAndRename(Dn entryDn, Dn newDn, boolean deleteOldRdn) throws LdapException
Moves and renames the given entryDn. The old relative distinguished name will be deleted if requested.- Specified by:
moveAndRename
in interfaceLdapConnection
- Parameters:
entryDn
- The original entry distinguished name.newDn
- The new entry distinguished name.deleteOldRdn
- Tells if the old relative distinguished name must be removed- Throws:
LdapException
- if some error occurred
-
moveAndRename
public void moveAndRename(String entryDn, String newDn, boolean deleteOldRdn) throws LdapException
Moves and renames the given entryDn. The old relative distinguished name will be deleted if requested.- Specified by:
moveAndRename
in interfaceLdapConnection
- Parameters:
entryDn
- The original entry distinguished name.newDn
- The new entry distinguished name.deleteOldRdn
- Tells if the old relative distinguished name must be removed- Throws:
LdapException
- if some error occurred
-
modifyDn
public ModifyDnResponse modifyDn(ModifyDnRequest modDnRequest) throws LdapException
Performs the modifyDn operation based on the given request object.- Specified by:
modifyDn
in interfaceLdapConnection
- Parameters:
modDnRequest
- the request object- Returns:
- modifyDn operation's response
- Throws:
LdapException
- if some error occurred
-
modifyDnAsync
public ModifyDnFuture modifyDnAsync(ModifyDnRequest modDnRequest) throws LdapException
Performs the modifyDn operation based on the given ModifyDnRequest.- Specified by:
modifyDnAsync
in interfaceLdapAsyncConnection
- Parameters:
modDnRequest
- the request- Returns:
- modifyDn operation's future
- Throws:
LdapException
- if some error occurred
-
delete
public void delete(String dn) throws LdapException
Deletes the entry with the given distinguished name.- Specified by:
delete
in interfaceLdapConnection
- Parameters:
dn
- the target entry's distinguished name, it must be a valid distinguished name.- Throws:
LdapException
- If the distinguished name is not valid or if the deletion failed
-
delete
public void delete(Dn dn) throws LdapException
Deletes the entry with the given distinguished name.- Specified by:
delete
in interfaceLdapConnection
- Parameters:
dn
- the target entry's distinguished name- Throws:
LdapException
- If the distinguished name is not valid or if the deletion failed
-
deleteTree
public void deleteTree(Dn dn) throws LdapException
deletes the entry with the given Dn, and all its children- Parameters:
dn
- the target entry's Dn- Throws:
LdapException
- If the Dn is not valid or if the deletion failed
-
deleteTree
public void deleteTree(String dn) throws LdapException
deletes the entry with the given Dn, and all its children- Parameters:
dn
- the target entry's Dn as a String- Throws:
LdapException
- If the Dn is not valid or if the deletion failed
-
delete
public DeleteResponse delete(DeleteRequest deleteRequest) throws LdapException
Performs a delete operation based on the delete request object.- Specified by:
delete
in interfaceLdapConnection
- Parameters:
deleteRequest
- the delete operation's request- Returns:
- delete operation's response
- Throws:
LdapException
- If the distinguished name is not valid or if the deletion failed
-
deleteAsync
public DeleteFuture deleteAsync(DeleteRequest deleteRequest) throws LdapException
Performs an asynchronous delete operation based on the delete request object.- Specified by:
deleteAsync
in interfaceLdapAsyncConnection
- Parameters:
deleteRequest
- the delete operation's request- Returns:
- delete operation's future
- Throws:
LdapException
- If the Dn is not valid or if the deletion failed
-
compare
public boolean compare(String dn, String attributeName, String value) throws LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.- Specified by:
compare
in interfaceLdapConnection
- Parameters:
dn
- the target entry's distinguished name, it must be a valid distinguished name.attributeName
- the attribute's namevalue
- a String value with which the target entry's attribute value to be compared with- Returns:
true
if the value matches,false
otherwise- Throws:
LdapException
- if some error occurred
-
compare
public boolean compare(String dn, String attributeName, byte[] value) throws LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.- Specified by:
compare
in interfaceLdapConnection
- Parameters:
dn
- the target entry's distinguished name, it must be a valid distinguished name.attributeName
- the attribute's namevalue
- a byte[] value with which the target entry's attribute value to be compared with- Returns:
true
if the value matches,false
otherwise- Throws:
LdapException
- if some error occurred
-
compare
public boolean compare(String dn, String attributeName, Value value) throws LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.- Specified by:
compare
in interfaceLdapConnection
- Parameters:
dn
- the target entry's distinguished name, it must be a valid distinguished name.attributeName
- the attribute's namevalue
- a Value<?> value with which the target entry's attribute value to be compared with- Returns:
true
if the value matches,false
otherwise- Throws:
LdapException
- if some error occurred
-
compare
public boolean compare(Dn dn, String attributeName, String value) throws LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.- Specified by:
compare
in interfaceLdapConnection
- Parameters:
dn
- the target entry's distinguished nameattributeName
- the attribute's namevalue
- a String value with which the target entry's attribute value to be compared with- Returns:
true
if the value matches,false
otherwise- Throws:
LdapException
- if some error occurred
-
compare
public boolean compare(Dn dn, String attributeName, byte[] value) throws LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.- Specified by:
compare
in interfaceLdapConnection
- Parameters:
dn
- the target entry's distinguished nameattributeName
- the attribute's namevalue
- a byte[] value with which the target entry's attribute value to be compared with- Returns:
true
if the value matches,false
otherwise- Throws:
LdapException
- if some error occurred
-
compare
public boolean compare(Dn dn, String attributeName, Value value) throws LdapException
Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.- Specified by:
compare
in interfaceLdapConnection
- Parameters:
dn
- the target entry's distinguished nameattributeName
- the attribute's namevalue
- a Value<?> value with which the target entry's attribute value to be compared with- Returns:
true
if the value matches,false
otherwise- Throws:
LdapException
- if some error occurred
-
compare
public CompareResponse compare(CompareRequest compareRequest) throws LdapException
Compares an entry's attribute's value with that of the given value.- Specified by:
compare
in interfaceLdapConnection
- Parameters:
compareRequest
- the compare request which contains the target distinguished name, attribute name and value- Returns:
- compare operation's response
- Throws:
LdapException
- if some error occurred
-
compareAsync
public CompareFuture compareAsync(CompareRequest compareRequest) throws LdapException
Asynchronously compares an entry's attribute's value with that of the given value- Specified by:
compareAsync
in interfaceLdapAsyncConnection
- Parameters:
compareRequest
- the CompareRequest which contains the target Dn, attribute name and value- Returns:
- compare operation's future
- Throws:
LdapException
- if some error occurred
-
extended
public ExtendedResponse extended(String oid) throws LdapException
Sends a extended operation request to the server with the given OID and no value.- Specified by:
extended
in interfaceLdapConnection
- Parameters:
oid
- the object identifier of the extended operation- Returns:
- extended operation's response
- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])
-
extended
public ExtendedResponse extended(String oid, byte[] value) throws LdapException
Sends a extended operation request to the server with the given OID and value.- Specified by:
extended
in interfaceLdapConnection
- Parameters:
oid
- the object identifier of the extended operationvalue
- value to be used by the extended operation, can be a null value- Returns:
- extended operation's response
- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])
-
extended
public ExtendedResponse extended(Oid oid) throws LdapException
Sends a extended operation request to the server with the given OID and no value.- Specified by:
extended
in interfaceLdapConnection
- Parameters:
oid
- the object identifier of the extended operation- Returns:
- extended operation's response
- Throws:
LdapException
- if some error occurred- See Also:
LdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])
-
extended
public ExtendedResponse extended(Oid oid, byte[] value) throws LdapException
Sends a extended operation request to the server with the given OID and value.- Specified by:
extended
in interfaceLdapConnection
- Parameters:
oid
- the object identifier of the extended operationvalue
- value to be used by the extended operation, can be a null value- Returns:
- extended operation's response
- Throws:
LdapException
- if some error occurred
-
extended
public ExtendedResponse extended(ExtendedRequest extendedRequest) throws LdapException
Performs an extended operation based on the extended request object.- Specified by:
extended
in interfaceLdapConnection
- Parameters:
extendedRequest
- the extended operation's request- Returns:
- Extended operation's response
- Throws:
LdapException
- if the extended operation failed
-
extendedAsync
public ExtendedFuture extendedAsync(ExtendedRequest extendedRequest) throws LdapException
Asynchronously requests the server to perform an extended operation based on the given request.- Specified by:
extendedAsync
in interfaceLdapAsyncConnection
- Parameters:
extendedRequest
- the object containing the details of the extended operation to be performed- Returns:
- extended operation's Future
- Throws:
LdapException
- if some error occurred
-
exists
public boolean exists(String dn) throws LdapException
Tells if an entry exists in the server.- Specified by:
exists
in interfaceLdapConnection
- Parameters:
dn
- The distinguished name of the entry to check for existence, must be a valid distinguished name.- 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:
LdapException
- if some error occurred
-
exists
public boolean exists(Dn dn) throws LdapException
Tells if an Entry exists in the server.- Specified by:
exists
in interfaceLdapConnection
- Parameters:
dn
- The distinguished name of the entry to check for 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:
LdapException
- if some error occurred
-
getRootDse
public Entry getRootDse() throws LdapException
Get back the RooDSE from the connected server. Only the user attributes are returned.- Specified by:
getRootDse
in interfaceLdapConnection
- Returns:
- The Entry containing all the information about the rootDSE
- Throws:
LdapException
- If the rootDSE can't be read
-
getRootDse
public Entry getRootDse(String... attributes) throws 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 interfaceLdapConnection
- Parameters:
attributes
- The list of attributes to return- Returns:
- The Entry containing all the information about the rootDSE
- Throws:
LdapException
- If the rootDSE can't be read
-
lookup
public Entry lookup(Dn dn) throws LdapException
Searches for an entry having the given distinguished name..- Specified by:
lookup
in interfaceLdapConnection
- Parameters:
dn
- the distinguished name of the entry to be fetched- Returns:
- the Entry with the given distinguished name or null if no entry exists with that distinguished name.
- Throws:
LdapException
- in case of any problems while searching for the distinguished name or if the returned response contains a referral- See Also:
LdapConnection.lookup(Dn, String...)
-
lookup
public Entry lookup(String dn) throws LdapException
Searches for an entry having the given distinguished name.- Specified by:
lookup
in interfaceLdapConnection
- Parameters:
dn
- the distinguished name of the entry to be fetched- Returns:
- the Entry with the given distinguished name or null if no entry exists with that distinguished name.
- Throws:
LdapException
- in case of any problems while searching for the distinguished name or if the returned response contains a referral- See Also:
LdapConnection.lookup(String, String...)
-
lookup
public Entry lookup(Dn dn, String... attributes) throws LdapException
Searches for an entry having the given distinguished name.- Specified by:
lookup
in interfaceLdapConnection
- Parameters:
dn
- the distinguished name of the entry to be fetchedattributes
- the attributes to be returned along with entry- Returns:
- the Entry with the given distinguished name or null if no entry exists with that distinguished name.
- Throws:
LdapException
- in case of any problems while searching for the distinguished name or if the returned response contains a referral
-
lookup
public Entry lookup(Dn dn, Control[] controls, String... attributes) throws LdapException
Searches for an entry having the given distinguished name.- Specified by:
lookup
in interfaceLdapConnection
- Parameters:
dn
- the distinguished name of the entry to be fetchedcontrols
- the controls to useattributes
- the attributes to be returned along with entry- Returns:
- the Entry with the given distinguished name or null if no entry exists with that distinguished name.
- Throws:
LdapException
- in case of any problems while searching for the distinguished name or if the returned response contains a referral
-
lookup
public Entry lookup(String dn, String... attributes) throws LdapException
Searches for an entry having the given distinguished name.- Specified by:
lookup
in interfaceLdapConnection
- Parameters:
dn
- the distinguished name of the entry to be fetchedattributes
- the attributes to be returned along with entry- Returns:
- the Entry with the given distinguished name or null if no entry exists with that distinguished name.
- Throws:
LdapException
- in case of any problems while searching for the distinguished name or if the returned response contains a referral- See Also:
LdapConnection.lookup(Dn, String...)
-
lookup
public Entry lookup(String dn, Control[] controls, String... attributes) throws LdapException
Searches for an entry having the given distinguished name.- Specified by:
lookup
in interfaceLdapConnection
- Parameters:
dn
- the distinguished name of the entry to be fetchedcontrols
- the controls to useattributes
- the attributes to be returned along with entry- Returns:
- the Entry with the given distinguished name or null if no entry exists with that distinguished name.
- Throws:
LdapException
- in case of any problems while searching for the distinguished name or if the returned response contains a referral- See Also:
LdapConnection.lookup(Dn, String...)
-
isControlSupported
public boolean isControlSupported(String controlOID) throws LdapException
Checks if a control with the given OID is supported.- Specified by:
isControlSupported
in interfaceLdapConnection
- Parameters:
controlOID
- the OID of the control- Returns:
- true if the control is supported, false otherwise
- Throws:
LdapException
- if some error occurred
-
getSupportedControls
public List<String> getSupportedControls() throws LdapException
Get the Controls supported by server.- Specified by:
getSupportedControls
in interfaceLdapConnection
- Returns:
- a list of control OIDs supported by server
- Throws:
LdapException
- if some error occurred
-
loadSchema
public void loadSchema() throws 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 interfaceLdapConnection
- Throws:
LdapException
- in case of problems while loading the schema
-
loadSchemaRelaxed
public void loadSchemaRelaxed() throws LdapException
Loads all the default schemas that are bundled with the API, in a relaxed mode.
Note: This method enables all schemas prior to loading.
The relaxed mode will allow inconsistencies in the schema.- Specified by:
loadSchemaRelaxed
in interfaceLdapConnection
- Throws:
LdapException
- in case of problems while loading the schema
-
loadSchema
public void loadSchema(SchemaLoader loader) throws LdapException
loads schema using the specified schema loader- Parameters:
loader
- theSchemaLoader
to be used to load schema- Throws:
LdapException
- If the schema loading failed
-
addSchema
public void addSchema(File schemaFile) throws 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:
LdapException
- in case of any errors while parsing
-
addSchema
public void addSchema(String schemaFileName) throws LdapException
- Parameters:
schemaFileName
- The schema file name to add- Throws:
LdapException
- If the schema addition failed- See Also:
addSchema(File)
-
getCodecService
public LdapApiService getCodecService()
Gets the LDAP CODEC service responsible for encoding and decoding messages.- Specified by:
getCodecService
in interfaceLdapConnection
- Returns:
- The LDAP CODEC service.
-
getSchemaManager
public SchemaManager getSchemaManager()
- Specified by:
getSchemaManager
in interfaceLdapConnection
- Returns:
- The SchemaManager associated with this LdapConection if any
-
getConfig
public LdapConnectionConfig getConfig()
gives the configuration information of the connection- Specified by:
getConfig
in interfaceLdapAsyncConnection
- Returns:
- the configuration of the connection
-
isRequestCompleted
public boolean isRequestCompleted(int messageId)
Checks if a request has been completed, or not.- Specified by:
isRequestCompleted
in interfaceLdapConnection
- Parameters:
messageId
- ID of the request- Returns:
- true if the request has been completed, false is still being processed
-
doesFutureExistFor
public boolean doesFutureExistFor(int messageId)
Checks if there is a ResponseFuture associated with the given message ID.- Specified by:
doesFutureExistFor
in interfaceLdapConnection
- 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
-
inputClosed
public void inputClosed(org.apache.mina.core.session.IoSession session) throws Exception
- Specified by:
inputClosed
in interfaceorg.apache.mina.core.service.IoHandler
- Overrides:
inputClosed
in classorg.apache.mina.core.service.IoHandlerAdapter
- Throws:
Exception
-
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 interfaceorg.apache.mina.core.service.IoHandler
- Overrides:
sessionCreated
in classorg.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 interfaceorg.apache.mina.core.service.IoHandler
- Overrides:
sessionClosed
in classorg.apache.mina.core.service.IoHandlerAdapter
- Throws:
Exception
-
startTls
public void startTls() throws 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:
LdapException
- If the StartTLS operation failed
-
bindSasl
public BindFuture bindSasl(SaslRequest saslRequest) throws LdapException
Process the SASL Bind. It's a dialog with the server, we will send a first BindRequest, receive a response and the, if this response is a challenge, continue by sending a new BindRequest with the requested informations.- Parameters:
saslRequest
- The SASL request object containing all the needed parameters- Returns:
- A
BindResponse
containing the result - Throws:
LdapException
- if some error occurred
-
getBinaryAttributeDetector
public BinaryAttributeDetector getBinaryAttributeDetector()
- Specified by:
getBinaryAttributeDetector
in interfaceLdapConnection
- Returns:
- the object responsible for the detection of binary attributes
-
setBinaryAttributeDetector
public void setBinaryAttributeDetector(BinaryAttributeDetector binaryAttributeDetector)
Sets the object responsible for the detection of binary attributes.- Specified by:
setBinaryAttributeDetector
in interfaceLdapConnection
- Parameters:
binaryAttributeDetector
- The Binary Attribute Detector to use
-
setSchemaManager
public void setSchemaManager(SchemaManager schemaManager)
sets a SchemaManager to be used by this connection- Specified by:
setSchemaManager
in interfaceLdapConnection
- Parameters:
schemaManager
- The SchemaManager to set
-
getSocketSessionConfig
public org.apache.mina.transport.socket.SocketSessionConfig getSocketSessionConfig()
- Returns:
- the socketSessionConfig
-
setSocketSessionConfig
public void setSocketSessionConfig(org.apache.mina.transport.socket.SocketSessionConfig socketSessionConfig)
- Parameters:
socketSessionConfig
- the socketSessionConfig to set
-
-