public class LdapConnection
extends org.apache.mina.core.service.IoHandlerAdapter
Constructor and Description |
---|
LdapConnection()
Create a new instance of a LdapConnection on localhost,
port 389.
|
LdapConnection(boolean useSsl)
Create a new instance of a LdapConnection on localhost,
port 389 if the SSL flag is off, or 636 otherwise.
|
LdapConnection(LdapConnectionConfig config)
Creates a new instance of LdapConnection with the given connection configuration.
|
LdapConnection(String server)
Create a new instance of a LdapConnection on a given
server, using the default port (389).
|
LdapConnection(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.
|
LdapConnection(String server,
int port)
Create a new instance of a LdapConnection on a
given server and a given port.
|
LdapConnection(String server,
int port,
boolean useSsl)
Create a new instance of a LdapConnection on a given
server, and a give port.
|
Modifier and Type | Method and Description |
---|---|
void |
abandon(AbandonRequest abandonRequest)
An abandon request essentially with the request message ID of the operation to be cancelled
and/or potentially some controls and timeout (the controls and timeout are not mandatory).
|
void |
abandon(int messageId)
Abandons a request submitted to the server for performing a particular operation
The abandonRequest is always non-blocking, because no response is expected
|
AddResponse |
add(AddRequest addRequest)
Add an entry present in the AddRequest to the server.
|
AddResponse |
add(org.apache.directory.shared.ldap.entry.Entry entry)
Add an entry to the server.
|
AddFuture |
addAsync(AddRequest addRequest)
Add an entry present in the AddRequest to the server.
|
AddFuture |
addAsync(org.apache.directory.shared.ldap.entry.Entry entry)
Add an entry to the server asynchronously.
|
BindResponse |
bind()
Anonymous Bind on a server.
|
BindResponse |
bind(BindRequest bindRequest)
Bind to the server using a BindRequest object.
|
BindResponse |
bind(org.apache.directory.shared.ldap.name.DN name,
String credentials)
Simple Bind on a server.
|
BindResponse |
bind(String name,
String credentials)
Simple Bind on a server.
|
BindFuture |
bindAsync()
Anonymous asynchronous Bind on a server.
|
BindFuture |
bindAsync(BindRequest bindRequest)
Do an asynchronous bind, based on a BindRequest.
|
BindFuture |
bindAsync(org.apache.directory.shared.ldap.name.DN name,
String credentials)
Simple asynchronous Bind on a server.
|
BindFuture |
bindAsync(String name,
String credentials)
Simple asynchronous Bind on a server.
|
boolean |
close()
Disconnect from the remote LDAP server
|
CompareResponse |
compare(CompareRequest compareRequest)
compares an entry's attribute's value with that of the given value
|
CompareResponse |
compare(org.apache.directory.shared.ldap.name.DN dn,
String attributeName,
byte[] value)
Compares a whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given DN
|
CompareResponse |
compare(org.apache.directory.shared.ldap.name.DN dn,
String attributeName,
String value)
Compares a whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given DN
|
CompareResponse |
compare(org.apache.directory.shared.ldap.name.DN dn,
String attributeName,
org.apache.directory.shared.ldap.entry.Value<?> value)
Compares a whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given DN
|
CompareResponse |
compare(String dn,
String attributeName,
byte[] value)
Compares a whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given DN
|
CompareResponse |
compare(String dn,
String attributeName,
String value)
Compares a whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given DN
|
CompareResponse |
compare(String dn,
String attributeName,
org.apache.directory.shared.ldap.entry.Value<?> value)
Compares a whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given DN
|
CompareFuture |
compareAsync(CompareRequest compareRequest)
Asynchronously compares an entry's attribute's value with that of the given value
|
boolean |
connect()
Connect to the remote LDAP server.
|
DeleteResponse |
delete(DeleteRequest deleteRequest)
Performs a delete operation based on the delete request object.
|
DeleteResponse |
delete(org.apache.directory.shared.ldap.name.DN dn)
deletes the entry with the given DN
|
DeleteResponse |
delete(String dn)
deletes the entry with the given DN
|
DeleteFuture |
deleteAsync(DeleteRequest delRequest)
Performs an asynchronous delete operation based on the delete request object.
|
DeleteResponse |
deleteTree(org.apache.directory.shared.ldap.name.DN dn)
deletes the entry with the given DN, and all its children
|
DeleteResponse |
deleteTree(String dn)
deletes the entry with the given DN, and all its children
|
boolean |
doesFutureExistFor(Integer messageId)
checks if there is a ResponseFuture associated with the given message id
|
ExtendedResponse |
extended(ExtendedRequest extendedRequest)
Performs an extended operation based on the Extended request object.
|
ExtendedResponse |
extended(org.apache.directory.shared.asn1.primitives.OID oid) |
ExtendedResponse |
extended(org.apache.directory.shared.asn1.primitives.OID oid,
byte[] value)
sends a extended operation request to the server with the given OID and value
|
ExtendedResponse |
extended(String oid) |
ExtendedResponse |
extended(String oid,
byte[] value) |
ExtendedFuture |
extendedAsync(ExtendedRequest extendedRequest)
Asynchronously requests the server to perform an extended operation based on the given request.
|
LdapConnectionConfig |
getConfig()
gives the configuration information of the connection
|
org.apache.directory.shared.ldap.codec.LdapMessageCodec |
getResponse()
Return the response stored into the current session.
|
org.apache.directory.shared.ldap.schema.SchemaManager |
getSchemaManager() |
List<String> |
getSupportedControls()
get the Controls supported by server.
|
boolean |
isAuthenticated()
Check if we are authenticated
|
boolean |
isConnected()
Check if we are connected
|
boolean |
isControlSupported(String controlOID)
checks if a control with the given OID is supported
|
void |
loadSchema()
loads the default schema that is bundled in the shared-ldap-schema.jar
|
SearchResponse |
lookup(String dn) |
SearchResponse |
lookup(String dn,
String... attributes)
searches for an entry having the given DN
|
void |
messageReceived(org.apache.mina.core.session.IoSession session,
Object message)
Handle the incoming LDAP messages.
|
ModifyResponse |
modify(org.apache.directory.shared.ldap.entry.Entry entry,
org.apache.directory.shared.ldap.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 ModifyRequest.
|
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 ModifyDnRequest.
|
ModifyDnFuture |
modifyDnAsync(ModifyDnRequest modDnRequest)
performs the modifyDn operation based on the given ModifyDnRequest.
|
ModifyDnResponse |
move(org.apache.directory.shared.ldap.name.DN entryDn,
org.apache.directory.shared.ldap.name.DN newSuperiorDn)
moves the given entry DN under the new superior DN
|
ModifyDnResponse |
move(String entryDn,
String newSuperiorDn) |
ModifyDnResponse |
rename(org.apache.directory.shared.ldap.name.DN entryDn,
org.apache.directory.shared.ldap.name.RDN newRdn)
renames the given entryDn with new RDN and deletes the old RDN.
|
ModifyDnResponse |
rename(org.apache.directory.shared.ldap.name.DN entryDn,
org.apache.directory.shared.ldap.name.RDN newRdn,
boolean deleteOldRdn)
renames the given entryDn with new RDN and deletes the old Rdn if
deleteOldRdn is set to true.
|
ModifyDnResponse |
rename(String entryDn,
String newRdn)
renames the given entryDn with new Rdn and deletes the old RDN.
|
ModifyDnResponse |
rename(String entryDn,
String newRdn,
boolean deleteOldRdn) |
org.apache.directory.shared.ldap.cursor.Cursor<SearchResponse> |
search(SearchRequest searchRequest)
Performs search in a synchronous mode.
|
org.apache.directory.shared.ldap.cursor.Cursor<SearchResponse> |
search(String baseDn,
String filter,
org.apache.directory.shared.ldap.filter.SearchScope scope,
String... attributes)
Do a 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(String baseDn,
String filter,
org.apache.directory.shared.ldap.filter.SearchScope scope,
String... attributes)
Do an asynchronous search, on the base object, using the given filter.
|
void |
setConnector(org.apache.mina.core.service.IoConnector connector)
Set the connector to use.
|
void |
setTimeOut(long timeOut)
Set the timeOut for the responses.
|
void |
unBind()
UnBind from a server.
|
public LdapConnection()
public LdapConnection(LdapConnectionConfig config)
config
- the configuration of the LdapConnectionpublic LdapConnection(boolean useSsl)
useSsl
- A flag to tell if it's a SSL connection or not.public LdapConnection(String server)
server
- The server we want to be connected topublic LdapConnection(String server, boolean useSsl)
server
- The server we want to be connected touseSsl
- A flag to tell if it's a SSL connection or not.public LdapConnection(String server, int port)
server
- The server we want to be connected toport
- The port the server is listening topublic LdapConnection(String server, int port, boolean useSsl)
server
- The server we want to be connected toport
- The port the server is listening touseSsl
- A flag to tell if it's a SSL connection or not.public boolean isConnected()
true
if we are connected.public boolean isAuthenticated()
true
if we are connected.public org.apache.directory.shared.ldap.codec.LdapMessageCodec getResponse()
public boolean connect() throws LdapException, IOException
true
if the connection is established, false otherwiseLdapException
- if some error has occuredIOException
public boolean close() throws IOException
true
if the connection is closed, false otherwiseIOException
- if some I/O error occurspublic AddResponse add(org.apache.directory.shared.ldap.entry.Entry entry) throws LdapException
entry
- The entry to addLdapException
public AddFuture addAsync(org.apache.directory.shared.ldap.entry.Entry entry) throws LdapException
entry
- The entry to addLdapException
public AddResponse add(AddRequest addRequest) throws LdapException
addRequest
- the request object containing an entry and controls(if any)LdapException
public AddFuture addAsync(AddRequest addRequest) throws LdapException
addRequest
- the request object containing an entry and controls(if any)LdapException
public void abandon(int messageId)
messageId
- the ID of the request message sent to the serverpublic void abandon(AbandonRequest abandonRequest)
abandonRequest
- the abandon operation's requestpublic BindResponse bind() throws LdapException, IOException
LdapException
IOException
public BindFuture bindAsync() throws LdapException, IOException
LdapException
IOException
public BindResponse bind(String name, String credentials) throws LdapException, IOException
name
- The name we use to authenticate the user. It must be a
valid DNcredentials
- The password. It can't be nullLdapException
IOException
public BindFuture bindAsync(String name, String credentials) throws LdapException, IOException
name
- The name we use to authenticate the user. It must be a
valid DNcredentials
- The password. It can't be nullLdapException
IOException
public BindResponse bind(org.apache.directory.shared.ldap.name.DN name, String credentials) throws LdapException, IOException
name
- The name we use to authenticate the user. It must be a
valid DNcredentials
- The password. It can't be nullLdapException
IOException
public BindFuture bindAsync(org.apache.directory.shared.ldap.name.DN name, String credentials) throws LdapException, IOException
name
- The name we use to authenticate the user. It must be a
valid DNcredentials
- The password. It can't be nullLdapException
IOException
public BindResponse bind(BindRequest bindRequest) throws LdapException, IOException
bindRequest
- The BindRequest POJO containing all the needed
parametersLdapException
IOException
public BindFuture bindAsync(BindRequest bindRequest) throws LdapException, IOException
bindRequest
- The BindRequest to sendLdapException
IOException
public org.apache.directory.shared.ldap.cursor.Cursor<SearchResponse> search(String baseDn, String filter, org.apache.directory.shared.ldap.filter.SearchScope scope, String... attributes) throws LdapException
baseDn
- The base for the search. It must be a valid
DN, and can't be emtpyfilterString
- The filter to use for this search. It can't be emptyscope
- The sarch scope : OBJECT, ONELEVEL or SUBTREELdapException
public SearchFuture searchAsync(String baseDn, String filter, org.apache.directory.shared.ldap.filter.SearchScope scope, String... attributes) throws LdapException
baseDn
- The base for the search. It must be a valid
DN, and can't be emtpyfilterString
- The filter to use for this search. It can't be emptyscope
- The sarch scope : OBJECT, ONELEVEL or SUBTREELdapException
public SearchFuture searchAsync(SearchRequest searchRequest) throws LdapException
searchRequest
- The search request to send to the serverLdapException
public org.apache.directory.shared.ldap.cursor.Cursor<SearchResponse> search(SearchRequest searchRequest) throws LdapException
searchRequest
- The search configurationCursor
containing Entries and ReferencsLdapException
- @TODOpublic void unBind() throws Exception
Exception
public void setConnector(org.apache.mina.core.service.IoConnector connector)
connector
- The connector to usepublic void setTimeOut(long timeOut)
timeOut
- The timeout, in millisecondspublic void messageReceived(org.apache.mina.core.session.IoSession session, Object message) throws Exception
messageReceived
in interface org.apache.mina.core.service.IoHandler
messageReceived
in class org.apache.mina.core.service.IoHandlerAdapter
Exception
public ModifyResponse modify(org.apache.directory.shared.ldap.entry.Entry entry, org.apache.directory.shared.ldap.entry.ModificationOperation modOp) throws LdapException
entry
- the entry whise 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 ModifyResponse modify(ModifyRequest modRequest) throws LdapException
modRequest
- the request for modify operationLdapException
- in case of modify operation failure or timeout happenspublic ModifyFuture modifyAsync(ModifyRequest modRequest) throws LdapException
modRequest
- the request for modify operationLdapException
- in case of modify operation failure or timeout happenspublic ModifyDnResponse rename(String entryDn, String newRdn) throws LdapException
LdapException
rename(String, String, boolean)
public ModifyDnResponse rename(org.apache.directory.shared.ldap.name.DN entryDn, org.apache.directory.shared.ldap.name.RDN newRdn) throws LdapException
LdapException
rename(DN, RDN, boolean)
public ModifyDnResponse rename(String entryDn, String newRdn, boolean deleteOldRdn) throws LdapException
LdapException
rename(DN, RDN, boolean)
public ModifyDnResponse rename(org.apache.directory.shared.ldap.name.DN entryDn, org.apache.directory.shared.ldap.name.RDN newRdn, boolean deleteOldRdn) throws LdapException
entryDn
- the target DNnewRdn
- new Rdn for the target DNdeleteOldRdn
- flag to indicate whether to delete the old RdnLdapException
public ModifyDnResponse move(String entryDn, String newSuperiorDn) throws LdapException
LdapException
move(DN, DN)
public ModifyDnResponse move(org.apache.directory.shared.ldap.name.DN entryDn, org.apache.directory.shared.ldap.name.DN newSuperiorDn) throws LdapException
entryDn
- the DN of the target entrynewSuperiorDn
- DN of the new parent/superiorLdapException
public ModifyDnResponse modifyDn(ModifyDnRequest modDnRequest) throws LdapException
modDnRequest
- the requestLdapException
public ModifyDnFuture modifyDnAsync(ModifyDnRequest modDnRequest) throws LdapException
modDnRequest
- the requestlistener
- callback listener which will be called after the operation is completedLdapException
public DeleteResponse delete(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(org.apache.directory.shared.ldap.name.DN dn) throws LdapException
dn
- the target entry's DNLdapException
- If the DN is not valid or if the deletion failedpublic DeleteResponse deleteTree(org.apache.directory.shared.ldap.name.DN dn) throws LdapException
dn
- the target entry's DNLdapException
- If the DN is not valid or if the deletion failedpublic DeleteResponse deleteTree(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
deleteRequest
- the delete operation's requestLdapException
- If the DN is not valid or if the deletion failedpublic DeleteFuture deleteAsync(DeleteRequest delRequest) throws LdapException
delRequest
- the delete operation's requestLdapException
- If the DN is not valid or if the deletion failedpublic CompareResponse compare(String dn, String attributeName, String value) throws LdapException
dn
- the target entry's String DNattributeName
- the attribute's namevalue
- a String value with which the target entry's attribute value to be compared withLdapException
public CompareResponse compare(String dn, String attributeName, byte[] value) throws LdapException
dn
- the target entry's String DNattributeName
- the attribute's namevalue
- a byte[] value with which the target entry's attribute value to be compared withLdapException
public CompareResponse compare(String dn, String attributeName, org.apache.directory.shared.ldap.entry.Value<?> value) throws LdapException
dn
- the target entry's String DNattributeName
- the attribute's namevalue
- a Value> value with which the target entry's attribute value to be compared withLdapException
public CompareResponse compare(org.apache.directory.shared.ldap.name.DN dn, String attributeName, String value) throws LdapException
dn
- the target entry's DNattributeName
- the attribute's namevalue
- a String value with which the target entry's attribute value to be compared withLdapException
public CompareResponse compare(org.apache.directory.shared.ldap.name.DN dn, String attributeName, byte[] value) throws LdapException
dn
- the target entry's DNattributeName
- the attribute's namevalue
- a byte[] value with which the target entry's attribute value to be compared withLdapException
public CompareResponse compare(org.apache.directory.shared.ldap.name.DN dn, String attributeName, org.apache.directory.shared.ldap.entry.Value<?> value) throws LdapException
dn
- the target entry's DNattributeName
- the attribute's namevalue
- a Value> value with which the target entry's attribute value to be compared withLdapException
public CompareResponse compare(CompareRequest compareRequest) throws LdapException
compareRequest
- the CompareRequest which contains the target DN, attribute name and valueLdapException
public CompareFuture compareAsync(CompareRequest compareRequest) throws LdapException
compareRequest
- the CompareRequest which contains the target DN, attribute name and valueLdapException
public ExtendedResponse extended(String oid) throws LdapException
LdapException
extended(OID, byte[])
public ExtendedResponse extended(String oid, byte[] value) throws LdapException
LdapException
extended(OID, byte[])
public ExtendedResponse extended(org.apache.directory.shared.asn1.primitives.OID oid) throws LdapException
LdapException
extended(OID, byte[])
public ExtendedResponse extended(org.apache.directory.shared.asn1.primitives.OID oid, byte[] value) throws LdapException
oid
- the object identifier of the extended operationvalue
- value to be used by the extended operation, can be a null valueLdapException
public ExtendedResponse extended(ExtendedRequest extendedRequest) throws LdapException
extendedRequest
- the extended operation's requestLdapException
- If the DN is not valid or if the extended operation failedpublic ExtendedFuture extendedAsync(ExtendedRequest extendedRequest) throws LdapException
extendedRequest
- the object containing the details of the extended operation to be performedLdapException
public SearchResponse lookup(String dn) throws LdapException
LdapException
lookup(String, String...)
public SearchResponse lookup(String dn, String... attributes) throws LdapException
dn
- 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 DNpublic boolean isControlSupported(String controlOID) throws LdapException
controlOID
- the OID of the controlLdapException
public List<String> getSupportedControls() throws LdapException
LdapException
public void loadSchema() throws LdapException
LdapException
- in case of problems while loading the schemapublic org.apache.directory.shared.ldap.schema.SchemaManager getSchemaManager()
public LdapConnectionConfig getConfig()
public boolean doesFutureExistFor(Integer messageId)
messageId
- ID of the requestCopyright © 2009–2013 The Apache Software Foundation. All rights reserved.