public class LdapNetworkConnection extends AbstractLdapConnection implements LdapAsyncConnection
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicBoolean |
authenticated
A flag indicating that the BindRequest has been issued and successfully authenticated the user
|
private java.util.List<ConnectionClosedEventListener> |
conCloseListeners
a list of listeners interested in getting notified when the
connection's session gets closed cause of network issues
|
private LdapConnectionConfig |
config
configuration object for the connection
|
private java.util.concurrent.atomic.AtomicBoolean |
connected
A flag indicating that the connection is connected or not
|
private org.apache.mina.core.service.IoConnector |
connector
The connector open with the remote server
|
private java.util.concurrent.locks.ReentrantLock |
connectorMutex
A mutex used to avoid a double close of the connector
|
private static java.lang.String |
EXCEPTION_KEY
The exception stored in the session if we've got one
|
private java.util.Map<java.lang.Integer,ResponseFuture<? extends Response>> |
futureMap
a map to hold the ResponseFutures for all operations
|
private org.apache.mina.core.filterchain.IoFilter |
ldapProtocolFilter
The Ldap codec protocol filter
|
private org.apache.mina.core.session.IoSession |
ldapSession
The created session, created when we open a connection with
the Ldap server.
|
private static org.slf4j.Logger |
LOG
logger for reporting errors that might not be handled properly upstream
|
(package private) static java.lang.String |
NO_RESPONSE_ERROR |
private Entry |
rootDse
The ROOT DSE entry
|
private static java.lang.String |
SSL_FILTER_KEY
the SslFilter key
|
private java.util.List<java.lang.String> |
supportedControls
list of controls supported by the server
|
(package private) static java.lang.String |
TIME_OUT_ERROR |
private long |
timeout
The timeout used for response we are waiting for
|
codec, messageId, schemaManager| Constructor and 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) |
LdapNetworkConnection(LdapConnectionConfig config)
Creates a new instance of LdapConnection with the given connection configuration.
|
LdapNetworkConnection(LdapConnectionConfig config,
LdapApiService ldapApiService) |
LdapNetworkConnection(java.lang.String server)
Create a new instance of a LdapConnection on a given
server, using the default port (389).
|
LdapNetworkConnection(java.lang.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(java.lang.String server,
boolean useSsl,
LdapApiService ldapApiService) |
LdapNetworkConnection(java.lang.String server,
int port)
Create a new instance of a LdapConnection on a
given server and a given port.
|
LdapNetworkConnection(java.lang.String server,
int port,
boolean useSsl)
Create a new instance of a LdapConnection on a given
server, and a give port.
|
LdapNetworkConnection(java.lang.String server,
int port,
boolean useSsl,
LdapApiService ldapApiService) |
LdapNetworkConnection(java.lang.String server,
int port,
LdapApiService ldapApiService) |
LdapNetworkConnection(java.lang.String server,
LdapApiService ldapApiService) |
| Modifier and Type | Method and Description |
|---|---|
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 |
abandon(int messageId)
Abandons a request submitted to the server for performing a particular operation.
|
private void |
abandonInternal(AbandonRequest abandonRequest)
Internal AbandonRequest handling
|
AddResponse |
add(AddRequest addRequest)
Add an entry present in the
AddRequest to the server. |
void |
add(Entry entry)
Add an entry to the server.
|
AddFuture |
addAsync(AddRequest addRequest)
Add an entry present in the AddRequest to the server.
|
AddFuture |
addAsync(Entry entry)
Add an entry to the server asynchronously.
|
void |
addConnectionClosedEventListener(ConnectionClosedEventListener ccListener)
Adds the connection closed event listener.
|
private void |
addControls(Message codec,
Message message) |
void |
addSchema(java.io.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(java.lang.String schemaFileName) |
private void |
addSslFilter()
adds
SslFilter to the IOConnector or IOSession's filter chain |
private void |
addToFutureMap(int messageId,
ResponseFuture<? extends Response> future) |
void |
anonymousBind()
Anonymous bind on a server.
|
BindFuture |
anonymousBindAsync()
Anonymous asynchronous Bind on a server.
|
void |
bind()
Bind on a server, using the
LdapConnectionConfig 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(SaslGssApiRequest request)
Bind to the server using a GssApiRequest object.
|
BindFuture |
bindAsync()
Asynchronous Bind on a server, using the LdapConnectionConfig informations.
|
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,
java.lang.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 |
bindAsync(java.lang.String name)
Asynchronous unauthenticated authentication bind
|
BindFuture |
bindAsync(java.lang.String name,
java.lang.String credentials)
Simple asynchronous Bind on a server.
|
private BindFuture |
bindSasl(SaslRequest saslRequest)
Process the SASL Bind.
|
BindResponse |
bindSaslPlain(java.lang.String authcid,
java.lang.String credentials)
SASL PLAIN Bind on a server.
|
BindResponse |
bindSaslPlain(java.lang.String authzid,
java.lang.String authcid,
java.lang.String credentials)
SASL PLAIN Bind on a server.
|
private static LdapConnectionConfig |
buildConfig(java.lang.String server,
int port,
boolean useSsl) |
private void |
checkSession()
Check that a session is valid, ie we can send requests to the
server
|
private void |
clearMaps()
clears the async listener, responseQueue and future mapppings to the corresponding request IDs
|
void |
close()
Disconnect from the remote LDAP server.
|
CompareResponse |
compare(CompareRequest compareRequest)
Compares an entry's attribute's value with that of the given value.
|
boolean |
compare(Dn dn,
java.lang.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,
java.lang.String attributeName,
java.lang.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,
java.lang.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.
|
boolean |
compare(java.lang.String dn,
java.lang.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(java.lang.String dn,
java.lang.String attributeName,
java.lang.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(java.lang.String dn,
java.lang.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 value
|
boolean |
connect()
Connect to the remote LDAP server.
|
private BindRequest |
createBindRequest(Dn name,
byte[] credentials)
Create a Simple BindRequest ready to be sent.
|
private BindRequest |
createBindRequest(java.lang.String name,
byte[] credentials)
Create a Simple BindRequest ready to be sent.
|
private void |
createConnector()
Create the connector
|
private java.lang.String |
createKrb5ConfFile(java.lang.String realmName,
java.lang.String kdcHost,
int kdcPort)
method to write the kerberos config in the standard MIT kerberos format
This is required cause the JGSS api is not able to recognize the port value set
in the system property java.security.krb5.kdc this issue makes it impossible
to set a kdc running non standard ports (other than 88)
e.g localhost:6088
|
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.
|
void |
delete(java.lang.String 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(Dn dn)
deletes the entry with the given Dn, and all its children
|
void |
deleteTree(java.lang.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,
java.lang.Throwable cause)
Handle the exception we got.
|
boolean |
exists(Dn dn)
Tells if an Entry exists in the server.
|
boolean |
exists(java.lang.String dn)
Tells if an entry exists in the server.
|
ExtendedResponse |
extended(ExtendedRequest extendedRequest)
Performs an extended operation based on the extended request object.
|
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(java.lang.String oid)
Sends a extended operation request to the server with the given OID and no value.
|
ExtendedResponse |
extended(java.lang.String oid,
byte[] value)
Sends a extended operation request to the server with the given OID and value.
|
ExtendedFuture |
extendedAsync(ExtendedRequest extendedRequest)
Asynchronously requests the server to perform an extended operation based on the given request.
|
private void |
fetchRootDSE(java.lang.String... explicitAttributes)
fetches the rootDSE from the server
|
BinaryAttributeDetector |
getBinaryAttributeDetector() |
LdapApiService |
getCodecService()
Gets the LDAP CODEC service responsible for encoding and decoding
messages.
|
LdapConnectionConfig |
getConfig()
gives the configuration information of the connection
|
private ResponseFuture<? extends Response> |
getFromFutureMap(int messageId) |
Entry |
getRootDse()
Get back the RooDSE from the connected server.
|
Entry |
getRootDse(java.lang.String... attributes)
Get back the RooDSE from the connected server.
|
SchemaManager |
getSchemaManager() |
java.util.List<java.lang.String> |
getSupportedControls()
Get the Controls supported by server.
|
(package private) static long |
getTimeout(long connectionTimoutInMS,
int searchTimeLimitInSeconds)
Get the largest timeout from the search time limit and the connection
timeout.
|
boolean |
isAuthenticated()
Check if we are authenticated.
|
boolean |
isConnected()
Check if we are connected.
|
boolean |
isControlSupported(java.lang.String controlOID)
Checks if a control with the given OID is supported.
|
private boolean |
isNoticeOfDisconnect(Message message)
Check if the message is a NoticeOfDisconnect message
|
void |
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 loader
|
void |
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(Dn dn)
Searches for an entry having the given Dn.
|
Entry |
lookup(Dn dn,
Control[] controls,
java.lang.String... attributes)
Searches for an entry having the given Dn.
|
Entry |
lookup(Dn dn,
java.lang.String... attributes)
Searches for an entry having the given Dn.
|
Entry |
lookup(java.lang.String dn)
Searches for an entry having the given Dn.
|
Entry |
lookup(java.lang.String dn,
Control[] controls,
java.lang.String... attributes)
Searches for an entry having the given Dn.
|
Entry |
lookup(java.lang.String dn,
java.lang.String... attributes)
Searches for an entry having the given Dn.
|
void |
messageReceived(org.apache.mina.core.session.IoSession session,
java.lang.Object message)
Handle the incoming LDAP messages.
|
void |
modify(Dn 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(java.lang.String 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(Dn entryDn,
Dn newSuperiorDn)
Moves the given entry Dn under the new superior Dn.
|
void |
move(java.lang.String entryDn,
java.lang.String newSuperiorDn)
Moves the given entry Dn under the new superior Dn.
|
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 |
moveAndRename(java.lang.String entryDn,
java.lang.String newDn)
Moves and renames the given entryDn.The old Rdn will be deleted
|
void |
moveAndRename(java.lang.String entryDn,
java.lang.String newDn,
boolean deleteOldRdn)
Moves and renames the given entryDn.
|
private ResponseFuture<? extends Response> |
peekFromFutureMap(int messageId) |
private void |
removeFromFutureMaps(int msgId)
removes the Objects associated with the given message ID
from future and response queue maps
|
void |
rename(Dn entryDn,
Rdn newRdn)
Renames the given entryDn with new Rdn and deletes the old Rdn.
|
void |
rename(Dn entryDn,
Rdn newRdn,
boolean deleteOldRdn)
Renames the given entryDn with new Rdn and deletes the old Rdn if
deleteOldRdn is set to true.
|
void |
rename(java.lang.String entryDn,
java.lang.String newRdn)
Renames the given entryDn with new Rdn and deletes the old Rdn.
|
void |
rename(java.lang.String entryDn,
java.lang.String newRdn,
boolean deleteOldRdn)
Renames the given entryDn with new Rdn and deletes the old Rdn if
deleteOldRdn is set to true.
|
EntryCursor |
search(Dn baseDn,
java.lang.String filter,
SearchScope scope,
java.lang.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(java.lang.String baseDn,
java.lang.String filter,
SearchScope scope,
java.lang.String... attributes)
Do a search, on the base object, using the given filter and scope.
|
SearchFuture |
searchAsync(Dn baseDn,
java.lang.String filter,
SearchScope scope,
java.lang.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(java.lang.String baseDn,
java.lang.String filter,
SearchScope scope,
java.lang.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 connection
|
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.
|
private void |
writeRequest(Request request)
a reusable code block to be used in various bind methods
|
bind, bind, bind, bind, createBindRequestinputClosed, messageSent, sessionIdle, sessionOpenedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbind, bind, bind, bindprivate static final org.slf4j.Logger LOG
private long timeout
private LdapConnectionConfig config
private org.apache.mina.core.service.IoConnector connector
private java.util.concurrent.locks.ReentrantLock connectorMutex
private org.apache.mina.core.session.IoSession ldapSession
private java.util.Map<java.lang.Integer,ResponseFuture<? extends Response>> futureMap
private java.util.List<java.lang.String> supportedControls
private Entry rootDse
private java.util.concurrent.atomic.AtomicBoolean authenticated
private java.util.concurrent.atomic.AtomicBoolean connected
private java.util.List<ConnectionClosedEventListener> conCloseListeners
private org.apache.mina.core.filterchain.IoFilter ldapProtocolFilter
private static final java.lang.String SSL_FILTER_KEY
private static final java.lang.String EXCEPTION_KEY
static final java.lang.String TIME_OUT_ERROR
static final java.lang.String NO_RESPONSE_ERROR
public LdapNetworkConnection()
public LdapNetworkConnection(LdapConnectionConfig config)
config - the configuration of the LdapConnectionpublic LdapNetworkConnection(LdapConnectionConfig config, LdapApiService ldapApiService)
public LdapNetworkConnection(boolean useSsl)
useSsl - A flag to tell if it's a SSL connection or not.public LdapNetworkConnection(boolean useSsl,
LdapApiService ldapApiService)
public LdapNetworkConnection(java.lang.String server)
server - The server we want to be connected to. If null or empty,
we will default to LocalHost.public LdapNetworkConnection(java.lang.String server,
LdapApiService ldapApiService)
public LdapNetworkConnection(java.lang.String server,
boolean useSsl)
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.public LdapNetworkConnection(java.lang.String server,
boolean useSsl,
LdapApiService ldapApiService)
public LdapNetworkConnection(java.lang.String server,
int port)
server - The server we want to be connected toport - The port the server is listening topublic LdapNetworkConnection(java.lang.String server,
int port,
LdapApiService ldapApiService)
public LdapNetworkConnection(java.lang.String server,
int port,
boolean useSsl)
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.public LdapNetworkConnection(java.lang.String server,
int port,
boolean useSsl,
LdapApiService ldapApiService)
public boolean isConnected()
isConnected in interface LdapConnectiontrue if we are connected.public boolean isAuthenticated()
isAuthenticated in interface LdapConnectiontrue if we are connected.private void checkSession()
throws InvalidConnectionException
java.lang.Exception - If the session is not validInvalidConnectionExceptionprivate void addToFutureMap(int messageId,
ResponseFuture<? extends Response> future)
private ResponseFuture<? extends Response> getFromFutureMap(int messageId)
private ResponseFuture<? extends Response> peekFromFutureMap(int messageId)
static long getTimeout(long connectionTimoutInMS,
int searchTimeLimitInSeconds)
private static LdapConnectionConfig buildConfig(java.lang.String server, int port, boolean useSsl)
private void createConnector()
throws LdapException
LdapExceptionpublic boolean connect()
throws LdapException
connect in interface LdapConnectiontrue if the connection is established, false otherwiseLdapException - if some error occurredpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface LdapConnectionjava.io.IOException - if some I/O error occurspublic void add(Entry entry) throws LdapException
add in interface LdapConnectionentry - The entry to addLdapException - if some error occurredpublic AddFuture addAsync(Entry entry) throws LdapException
addAsync in interface LdapAsyncConnectionentry - The entry to addLdapException - if some error occurredpublic AddResponse add(AddRequest addRequest) throws LdapException
AddRequest to the server.add in interface LdapConnectionaddRequest - the request object containing an entry and controls (if any)LdapException - if some error occurredpublic AddFuture addAsync(AddRequest addRequest) throws LdapException
addAsync in interface LdapAsyncConnectionaddRequest - the request object containing an entry and controls(if any)LdapException - if some error occurredpublic void abandon(int messageId)
abandon in interface LdapConnectionmessageId - the ID of the request message sent to the serverpublic void abandon(AbandonRequest abandonRequest)
abandon in interface LdapConnectionabandonRequest - the abandon operation's requestprivate void abandonInternal(AbandonRequest abandonRequest)
public void bind()
throws LdapException
LdapConnectionConfig information of this connection.bind in interface LdapConnectionLdapException - if some error occurredpublic void anonymousBind()
throws LdapException
anonymousBind in interface LdapConnectionLdapException - if some error occurredpublic BindFuture bindAsync() throws LdapException
bindAsync in interface LdapAsyncConnectionLdapException - if some error occurredpublic BindFuture anonymousBindAsync() throws LdapException
anonymousBindAsync in interface LdapAsyncConnectionLdapException - if some error occurredpublic BindFuture bindAsync(java.lang.String name) throws LdapException
name - The name we use to authenticate the user. It must be a
valid DnLdapException - if some error occurredpublic BindFuture bindAsync(java.lang.String name, java.lang.String credentials) throws LdapException
bindAsync in interface LdapAsyncConnectionname - The name we use to authenticate the user, it must be a valid Dncredentials - The password, it can't be nullLdapException - if some error occurredpublic BindFuture bindAsync(Dn name) throws LdapException
name - The name we use to authenticate the user. It must be a
valid DnLdapException - if some error occurredpublic BindFuture bindAsync(Dn name, java.lang.String credentials) throws LdapException
bindAsync in interface LdapAsyncConnectionname - The name we use to authenticate the user, it must be a valid Dncredentials - The password, it can't be nullLdapException - if some error occurredpublic BindResponse bind(BindRequest bindRequest) throws LdapException
bind in interface LdapConnectionbindRequest - The bind request object containing all the needed parametersBindResponse containing the resultLdapException - if some error occurredprivate BindRequest createBindRequest(java.lang.String name, byte[] credentials) throws LdapException
LdapExceptionprivate BindRequest createBindRequest(Dn name, byte[] credentials) throws LdapException
LdapExceptionpublic BindFuture bindAsync(BindRequest bindRequest) throws LdapException
bindAsync in interface LdapAsyncConnectionbindRequest - The BindRequest to sendLdapException - if some error occurredpublic BindResponse bindSaslPlain(java.lang.String authcid, java.lang.String credentials) throws LdapException
authcid - The Authentication identitycredentials - The password. It can't be null{@link - LdapException} if some error occurredLdapExceptionpublic BindResponse bindSaslPlain(java.lang.String authzid, java.lang.String authcid, java.lang.String credentials) throws LdapException
authzid - The Authorization identityauthcid - The Authentication identitycredentials - The password. It can't be null{@link - LdapException} if some error occurredLdapExceptionpublic BindResponse bind(SaslCramMd5Request request) throws LdapException
request - The CramMd5Request POJO containing all the needed parametersLdapException - if some error occurredpublic BindFuture bindAsync(SaslRequest request) throws LdapException
request - The SaslPlainRequest POJO containing all the needed parametersLdapException - if some error occurredpublic BindResponse bind(SaslDigestMd5Request request) throws LdapException
request - The DigestMd5Request POJO containing all the needed parametersLdapException - if some error occurredpublic BindResponse bind(SaslGssApiRequest request) throws LdapException
request - The GssApiRequest POJO containing all the needed parametersLdapException - if some error occurredpublic BindFuture bindAsync(SaslGssApiRequest request) throws LdapException
request - The GssApiRequest POJO containing all the needed parametersLdapException - if some error occurredpublic EntryCursor search(Dn baseDn, java.lang.String filter, SearchScope scope, java.lang.String... attributes) throws LdapException
search in interface LdapConnectionbaseDn - 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 searchEntryCursor on the result.LdapException - if some error occurredpublic EntryCursor search(java.lang.String baseDn, java.lang.String filter, SearchScope scope, java.lang.String... attributes) throws LdapException
search in interface LdapConnectionbaseDn - 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 searchEntryCursor on the result.LdapException - if some error occurredpublic SearchFuture searchAsync(Dn baseDn, java.lang.String filter, SearchScope scope, java.lang.String... attributes) throws LdapException
Scope : ONE DerefAlias : ALWAYS SizeLimit : none TimeLimit : none TypesOnly : false Attributes : all the user's attributes. This method is blocking.
searchAsync in interface LdapAsyncConnectionbaseDn - 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 searchLdapException - if some error occurredpublic SearchFuture searchAsync(java.lang.String baseDn, java.lang.String filter, SearchScope scope, java.lang.String... attributes) throws LdapException
Scope : ONE DerefAlias : ALWAYS SizeLimit : none TimeLimit : none TypesOnly : false Attributes : all the user's attributes. This method is blocking.
searchAsync in interface LdapAsyncConnectionbaseDn - 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 searchLdapException - if some error occurredpublic SearchFuture searchAsync(SearchRequest searchRequest) throws LdapException
Scope : ONE DerefAlias : ALWAYS SizeLimit : none TimeLimit : none TypesOnly : false Attributes : all the user's attributes. This method is blocking.
searchAsync in interface LdapAsyncConnectionsearchRequest - The search request to send to the serverLdapException - if some error occurredpublic SearchCursor search(SearchRequest searchRequest) throws LdapException
search in interface LdapConnectionsearchRequest - The search request object containing all the needed informationLdapException - if some error occurredpublic void unBind()
throws LdapException
unBind in interface LdapConnectionLdapException - if some error occurredpublic void setConnector(org.apache.mina.core.service.IoConnector connector)
connector - The connector to usepublic void setTimeOut(long timeout)
setTimeOut in interface LdapConnectiontimeout - The timeout, in millisecondspublic void exceptionCaught(org.apache.mina.core.session.IoSession session,
java.lang.Throwable cause)
throws java.lang.Exception
exceptionCaught in interface org.apache.mina.core.service.IoHandlerexceptionCaught in class org.apache.mina.core.service.IoHandlerAdaptersession - The session we got the exception oncause - The exception causejava.lang.Exception - The tprivate boolean isNoticeOfDisconnect(Message message)
public void messageReceived(org.apache.mina.core.session.IoSession session,
java.lang.Object message)
throws java.lang.Exception
messageReceived in interface org.apache.mina.core.service.IoHandlermessageReceived in class org.apache.mina.core.service.IoHandlerAdaptersession - The session that received a messagemessage - The received messagejava.lang.Exception - If there is some error while processing the messagepublic void modify(Entry entry, ModificationOperation modOp) throws LdapException
modify in interface LdapConnectionentry - the entry with the attributes to be modifiedmodOp - the operation to be applied on all the attributes of the above entryLdapException - in case of modify operation failure or timeout happenspublic void modify(Dn dn, Modification... modifications) throws LdapException
modify in interface LdapConnectiondn - The entry's distinguished namemodifications - The list of modifications to be appliedLdapException - in case of modify operation failure or timeout happenspublic void modify(java.lang.String dn,
Modification... modifications)
throws LdapException
modify in interface LdapConnectiondn - The entry's distinguished name, it must be a valid Dnmodifications - The list of modifications to be appliedLdapException - in case of modify operation failure or timeout happenspublic ModifyResponse modify(ModifyRequest modRequest) throws LdapException
modify in interface LdapConnectionmodRequest - the modify request objectLdapException - in case of modify operation failure or timeout happenspublic ModifyFuture modifyAsync(ModifyRequest modRequest) throws LdapException
modifyAsync in interface LdapAsyncConnectionmodRequest - the request for modify operationLdapException - in case of modify operation failure or timeout happenspublic void rename(java.lang.String entryDn,
java.lang.String newRdn)
throws LdapException
rename in interface LdapConnectionentryDn - the target DnnewRdn - new Rdn for the target DnLdapException - if some error occurredLdapConnection.rename(String, String, boolean)public void rename(Dn entryDn, Rdn newRdn) throws LdapException
rename in interface LdapConnectionentryDn - the target DnnewRdn - new Rdn for the target DnLdapException - if some error occurredLdapConnection.rename(Dn, Rdn, boolean)public void rename(java.lang.String entryDn,
java.lang.String newRdn,
boolean deleteOldRdn)
throws LdapException
rename in interface LdapConnectionentryDn - the target DnnewRdn - new Rdn for the target DndeleteOldRdn - flag to indicate whether to delete the old RdnLdapException - if some error occurredLdapConnection.rename(Dn, Rdn, boolean)public void rename(Dn entryDn, Rdn newRdn, boolean deleteOldRdn) throws LdapException
rename in interface LdapConnectionentryDn - the target DnnewRdn - new Rdn for the target DndeleteOldRdn - flag to indicate whether to delete the old RdnLdapException - if some error occurredpublic void move(java.lang.String entryDn,
java.lang.String newSuperiorDn)
throws LdapException
move in interface LdapConnectionentryDn - the Dn of the target entrynewSuperiorDn - Dn of the new parent/superiorLdapException - if some error occurredLdapConnection.move(Dn, Dn)public void move(Dn entryDn, Dn newSuperiorDn) throws LdapException
move in interface LdapConnectionentryDn - the Dn of the target entrynewSuperiorDn - Dn of the new parent/superiorLdapException - if some error occurredpublic void moveAndRename(Dn entryDn, Dn newDn) throws LdapException
moveAndRename in interface LdapConnectionentryDn - The original entry DnnewDn - The new entry DnLdapException - if some error occurredLdapConnection.moveAndRename(Dn, Dn, boolean)public void moveAndRename(java.lang.String entryDn,
java.lang.String newDn)
throws LdapException
moveAndRename in interface LdapConnectionentryDn - The original entry DnnewDn - The new entry DnLdapException - if some error occurredLdapConnection.moveAndRename(Dn, Dn, boolean)public void moveAndRename(Dn entryDn, Dn newDn, boolean deleteOldRdn) throws LdapException
moveAndRename in interface LdapConnectionentryDn - The original entry DnnewDn - The new entry DndeleteOldRdn - Tells if the old Rdn must be removedLdapException - if some error occurredpublic void moveAndRename(java.lang.String entryDn,
java.lang.String newDn,
boolean deleteOldRdn)
throws LdapException
moveAndRename in interface LdapConnectionentryDn - The original entry DnnewDn - The new entry DndeleteOldRdn - Tells if the old Rdn must be removedLdapException - if some error occurredpublic ModifyDnResponse modifyDn(ModifyDnRequest modDnRequest) throws LdapException
modifyDn in interface LdapConnectionmodDnRequest - the request objectLdapException - if some error occurredpublic ModifyDnFuture modifyDnAsync(ModifyDnRequest modDnRequest) throws LdapException
modifyDnAsync in interface LdapAsyncConnectionmodDnRequest - the requestLdapException - if some error occurredpublic void delete(java.lang.String dn)
throws LdapException
delete in interface LdapConnectiondn - the target entry's distinguished name, it must be a valid DnLdapException - If the Dn is not valid or if the deletion failedpublic void delete(Dn dn) throws LdapException
delete in interface LdapConnectiondn - the target entry's distinguished nameLdapException - If the Dn is not valid or if the deletion failedpublic void deleteTree(Dn dn) throws LdapException
dn - the target entry's DnLdapException - If the Dn is not valid or if the deletion failedpublic void deleteTree(java.lang.String dn)
throws LdapException
dn - the target entry's Dn as a StringLdapException - If the Dn is not valid or if the deletion failedpublic DeleteResponse delete(DeleteRequest deleteRequest) throws LdapException
delete in interface LdapConnectiondeleteRequest - the delete operation's requestLdapException - If the Dn is not valid or if the deletion failedpublic DeleteFuture deleteAsync(DeleteRequest deleteRequest) throws LdapException
deleteAsync in interface LdapAsyncConnectiondeleteRequest - the delete operation's requestLdapException - If the Dn is not valid or if the deletion failedpublic boolean compare(java.lang.String dn,
java.lang.String attributeName,
java.lang.String value)
throws LdapException
compare in interface LdapConnectiondn - the target entry's distinguished name, it must be a valid DnattributeName - the attribute's namevalue - a String value with which the target entry's attribute value to be compared withtrue if the value matches, false otherwiseLdapException - if some error occurredpublic boolean compare(java.lang.String dn,
java.lang.String attributeName,
byte[] value)
throws LdapException
compare in interface LdapConnectiondn - the target entry's distinguished name, it must be a valid DnattributeName - the attribute's namevalue - a byte[] value with which the target entry's attribute value to be compared withtrue if the value matches, false otherwiseLdapException - if some error occurredpublic boolean compare(java.lang.String dn,
java.lang.String attributeName,
Value<?> value)
throws LdapException
compare in interface LdapConnectiondn - the target entry's distinguished name, it must be a valid DnattributeName - the attribute's namevalue - a Value> value with which the target entry's attribute value to be compared withtrue if the value matches, false otherwiseLdapException - if some error occurredpublic boolean compare(Dn dn, java.lang.String attributeName, java.lang.String value) throws LdapException
compare in interface LdapConnectiondn - the target entry's distinguished nameattributeName - the attribute's namevalue - a String value with which the target entry's attribute value to be compared withtrue if the value matches, false otherwiseLdapException - if some error occurredpublic boolean compare(Dn dn, java.lang.String attributeName, byte[] value) throws LdapException
compare in interface LdapConnectiondn - the target entry's distinguished nameattributeName - the attribute's namevalue - a byte[] value with which the target entry's attribute value to be compared withtrue if the value matches, false otherwiseLdapException - if some error occurredpublic boolean compare(Dn dn, java.lang.String attributeName, Value<?> value) throws LdapException
compare in interface LdapConnectiondn - the target entry's distinguished nameattributeName - the attribute's namevalue - a Value> value with which the target entry's attribute value to be compared withtrue if the value matches, false otherwiseLdapException - if some error occurredpublic CompareResponse compare(CompareRequest compareRequest) throws LdapException
compare in interface LdapConnectioncompareRequest - the compare request which contains the target Dn, attribute name and valueLdapException - if some error occurredpublic CompareFuture compareAsync(CompareRequest compareRequest) throws LdapException
compareAsync in interface LdapAsyncConnectioncompareRequest - the CompareRequest which contains the target Dn, attribute name and valueLdapException - if some error occurredpublic ExtendedResponse extended(java.lang.String oid) throws LdapException
extended in interface LdapConnectionoid - the object identifier of the extended operationLdapException - if some error occurredLdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])public ExtendedResponse extended(java.lang.String oid, byte[] value) throws LdapException
extended in interface LdapConnectionoid - the object identifier of the extended operationvalue - value to be used by the extended operation, can be a null valueLdapException - if some error occurredLdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])public ExtendedResponse extended(Oid oid) throws LdapException
extended in interface LdapConnectionoid - the object identifier of the extended operationLdapException - if some error occurredLdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])public ExtendedResponse extended(Oid oid, byte[] value) throws LdapException
extended in interface LdapConnectionoid - the object identifier of the extended operationvalue - value to be used by the extended operation, can be a null valueLdapException - if some error occurredpublic ExtendedResponse extended(ExtendedRequest extendedRequest) throws LdapException
extended in interface LdapConnectionextendedRequest - the extended operation's requestLdapException - if the extended operation failedpublic ExtendedFuture extendedAsync(ExtendedRequest extendedRequest) throws LdapException
extendedAsync in interface LdapAsyncConnectionextendedRequest - the object containing the details of the extended operation to be performedLdapException - if some error occurredpublic boolean exists(java.lang.String dn)
throws LdapException
exists in interface LdapConnectiondn - The distinguished name of the entry we want to check the existence, must be a valid Dntrue 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 returnedLdapException - if some error occurredpublic boolean exists(Dn dn) throws LdapException
exists in interface LdapConnectiondn - The distinguished name of the entry we want to check the existencetrue 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 returnedLdapException - if some error occurredpublic Entry getRootDse() throws LdapException
getRootDse in interface LdapConnectionLdapException - If the rootDSE can't be readpublic Entry getRootDse(java.lang.String... attributes) throws LdapException
getRootDse in interface LdapConnectionattributes - The list of attributes to returnLdapException - If the rootDSE can't be readpublic Entry lookup(Dn dn) throws LdapException
lookup in interface LdapConnectiondn - the Dn of the entry to be fetchedLdapException - in case of any problems while searching for the Dn or if the returned response contains a referralLdapConnection.lookup(org.apache.directory.api.ldap.model.name.Dn, String...)public Entry lookup(java.lang.String dn) throws LdapException
lookup in interface LdapConnectiondn - the Dn of the entry to be fetchedLdapException - in case of any problems while searching for the Dn or if the returned response contains a referralLdapConnection.lookup(String, String...)public Entry lookup(Dn dn, java.lang.String... attributes) throws LdapException
lookup in interface LdapConnectiondn - the Dn of the entry to be fetchedattributes - the attributes to be returned along with entryLdapException - in case of any problems while searching for the Dn or if the returned response contains a referralpublic Entry lookup(Dn dn, Control[] controls, java.lang.String... attributes) throws LdapException
lookup in interface LdapConnectiondn - the Dn of the entry to be fetchedcontrols - the controls to useattributes - the attributes to be returned along with entryLdapException - in case of any problems while searching for the Dn or if the returned response contains a referralpublic Entry lookup(java.lang.String dn, java.lang.String... attributes) throws LdapException
lookup in interface LdapConnectiondn - the Dn of the entry to be fetchedattributes - the attributes to be returned along with entryLdapException - in case of any problems while searching for the Dn or if the returned response contains a referralLdapConnection.lookup(org.apache.directory.api.ldap.model.name.Dn, String...)public Entry lookup(java.lang.String dn, Control[] controls, java.lang.String... attributes) throws LdapException
lookup in interface LdapConnectiondn - the Dn of the entry to be fetchedcontrols - the controls to useattributes - the attributes to be returned along with entryLdapException - in case of any problems while searching for the Dn or if the returned response contains a referralLdapConnection.lookup(org.apache.directory.api.ldap.model.name.Dn, String...)public boolean isControlSupported(java.lang.String controlOID)
throws LdapException
isControlSupported in interface LdapConnectioncontrolOID - the OID of the controlLdapException - if some error occurredpublic java.util.List<java.lang.String> getSupportedControls()
throws LdapException
getSupportedControls in interface LdapConnectionLdapException - if some error occurredpublic void loadSchema()
throws LdapException
loadSchema in interface LdapConnectionLdapException - in case of problems while loading the schemapublic void loadSchemaRelaxed()
throws LdapException
loadSchemaRelaxed in interface LdapConnectionLdapException - in case of problems while loading the schemapublic void loadSchema(SchemaLoader loader) throws LdapException
loader - the SchemaLoader to be used to load schemaLdapExceptionpublic void addSchema(java.io.File schemaFile)
throws LdapException
schemaFile - the schema file in OpenLDAP schema formatLdapException - in case of any errors while parsingpublic void addSchema(java.lang.String schemaFileName)
throws LdapException
LdapExceptionaddSchema(File)public LdapApiService getCodecService()
getCodecService in interface LdapConnectionpublic SchemaManager getSchemaManager()
getSchemaManager in interface LdapConnectionprivate void fetchRootDSE(java.lang.String... explicitAttributes)
throws LdapException
LdapExceptionpublic LdapConnectionConfig getConfig()
getConfig in interface LdapAsyncConnectionprivate void removeFromFutureMaps(int msgId)
msgId - id of the messageprivate void clearMaps()
public boolean doesFutureExistFor(int messageId)
doesFutureExistFor in interface LdapConnectionmessageId - ID of the requestpublic void addConnectionClosedEventListener(ConnectionClosedEventListener ccListener)
ccListener - the connection closed listenerpublic void sessionCreated(org.apache.mina.core.session.IoSession session)
throws java.lang.Exception
sessionCreated in interface org.apache.mina.core.service.IoHandlersessionCreated in class org.apache.mina.core.service.IoHandlerAdaptersession - the newly created sessionjava.lang.Exceptionpublic void sessionClosed(org.apache.mina.core.session.IoSession session)
throws java.lang.Exception
sessionClosed in interface org.apache.mina.core.service.IoHandlersessionClosed in class org.apache.mina.core.service.IoHandlerAdapterjava.lang.Exceptionpublic void startTls()
throws LdapException
LdapExceptionprivate void addSslFilter()
throws LdapException
SslFilter to the IOConnector or IOSession's filter chainLdapExceptionprivate BindFuture bindSasl(SaslRequest saslRequest) throws LdapException
LdapExceptionprivate void writeRequest(Request request) throws LdapException
LdapExceptionprivate java.lang.String createKrb5ConfFile(java.lang.String realmName,
java.lang.String kdcHost,
int kdcPort)
throws java.io.IOException
[libdefaults]
default_realm = EXAMPLE.COM
[realms]
EXAMPLE.COM = {
kdc = localhost:6088
}
java.io.IOExceptionpublic BinaryAttributeDetector getBinaryAttributeDetector()
getBinaryAttributeDetector in interface LdapConnectionpublic void setBinaryAttributeDetector(BinaryAttributeDetector binaryAttributeDetector)
setBinaryAttributeDetector in interface LdapConnectionpublic void setSchemaManager(SchemaManager schemaManager)
setSchemaManager in interface LdapConnection