|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mina.core.service.IoHandlerAdapter
org.apache.directory.ldap.client.api.LdapConnection
public class LdapConnection
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.
Constructor Summary | |
---|---|
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(java.lang.String server)
Create a new instance of a LdapConnection on a given server, using the default port (389). |
|
LdapConnection(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. |
|
LdapConnection(java.lang.String server,
int port)
Create a new instance of a LdapConnection on a given server and a given port. |
|
LdapConnection(java.lang.String server,
int port,
boolean useSsl)
Create a new instance of a LdapConnection on a given server, and a give port. |
Method Summary | |
---|---|
void |
abandon(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,
java.lang.String credentials)
Simple Bind on a server. |
BindResponse |
bind(java.lang.String name,
java.lang.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,
java.lang.String credentials)
Simple asynchronous Bind on a server. |
BindFuture |
bindAsync(java.lang.String name,
java.lang.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,
java.lang.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,
java.lang.String attributeName,
java.lang.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,
java.lang.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(java.lang.String dn,
java.lang.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(java.lang.String dn,
java.lang.String attributeName,
java.lang.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(java.lang.String dn,
java.lang.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(java.lang.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(java.lang.String dn)
deletes the entry with the given DN, and all its children |
boolean |
doesFutureExistFor(java.lang.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(java.lang.String oid)
|
ExtendedResponse |
extended(java.lang.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()
|
java.util.List<java.lang.String> |
getSupportedControls()
get the Controls supported by server. |
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 |
void |
loadSchema()
loads the default schema that is bundled in the shared-ldap-schema.jar |
SearchResponse |
lookup(java.lang.String dn)
|
SearchResponse |
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. |
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(java.lang.String entryDn,
java.lang.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(java.lang.String entryDn,
java.lang.String newRdn)
renames the given entryDn with new Rdn and deletes the old RDN. |
ModifyDnResponse |
rename(java.lang.String entryDn,
java.lang.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(java.lang.String baseDn,
java.lang.String filter,
org.apache.directory.shared.ldap.filter.SearchScope scope,
java.lang.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(java.lang.String baseDn,
java.lang.String filter,
org.apache.directory.shared.ldap.filter.SearchScope scope,
java.lang.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. |
Methods inherited from class org.apache.mina.core.service.IoHandlerAdapter |
---|
exceptionCaught, messageSent, sessionClosed, sessionCreated, sessionIdle, sessionOpened |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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(java.lang.String server)
server
- The server we want to be connected topublic LdapConnection(java.lang.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(java.lang.String server, int port)
server
- The server we want to be connected toport
- The port the server is listening topublic LdapConnection(java.lang.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.Method Detail |
---|
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, java.io.IOException
true
if the connection is established, false otherwise
LdapException
- if some error has occured
java.io.IOException
public boolean close() throws java.io.IOException
true
if the connection is closed, false otherwise
java.io.IOException
- if some I/O error occurspublic AddResponse add(org.apache.directory.shared.ldap.entry.Entry entry) throws LdapException
entry
- The entry to add
LdapException
public AddFuture addAsync(org.apache.directory.shared.ldap.entry.Entry entry) throws LdapException
entry
- The entry to add
LdapException
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, java.io.IOException
LdapException
java.io.IOException
public BindFuture bindAsync() throws LdapException, java.io.IOException
LdapException
java.io.IOException
public BindResponse bind(java.lang.String name, java.lang.String credentials) throws LdapException, java.io.IOException
name
- The name we use to authenticate the user. It must be a
valid DNcredentials
- The password. It can't be null
LdapException
java.io.IOException
public BindFuture bindAsync(java.lang.String name, java.lang.String credentials) throws LdapException, java.io.IOException
name
- The name we use to authenticate the user. It must be a
valid DNcredentials
- The password. It can't be null
LdapException
java.io.IOException
public BindResponse bind(org.apache.directory.shared.ldap.name.DN name, java.lang.String credentials) throws LdapException, java.io.IOException
name
- The name we use to authenticate the user. It must be a
valid DNcredentials
- The password. It can't be null
LdapException
java.io.IOException
public BindFuture bindAsync(org.apache.directory.shared.ldap.name.DN name, java.lang.String credentials) throws LdapException, java.io.IOException
name
- The name we use to authenticate the user. It must be a
valid DNcredentials
- The password. It can't be null
LdapException
java.io.IOException
public BindResponse bind(BindRequest bindRequest) throws LdapException, java.io.IOException
bindRequest
- The BindRequest POJO containing all the needed
parameters
LdapException
java.io.IOException
public BindFuture bindAsync(BindRequest bindRequest) throws LdapException, java.io.IOException
bindRequest
- The BindRequest to send
LdapException
java.io.IOException
public org.apache.directory.shared.ldap.cursor.Cursor<SearchResponse> search(java.lang.String baseDn, java.lang.String filter, org.apache.directory.shared.ldap.filter.SearchScope scope, java.lang.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 SUBTREE
LdapException
public SearchFuture searchAsync(java.lang.String baseDn, java.lang.String filter, org.apache.directory.shared.ldap.filter.SearchScope scope, java.lang.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 SUBTREE
LdapException
public SearchFuture searchAsync(SearchRequest searchRequest) throws LdapException
searchRequest
- The search request to send to the server
LdapException
public org.apache.directory.shared.ldap.cursor.Cursor<SearchResponse> search(SearchRequest searchRequest) throws LdapException
searchRequest
- The search configuration
Cursor
containing Entries and Referencs
LdapException
- @TODOpublic void unBind() throws java.lang.Exception
java.lang.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, java.lang.Object message) throws java.lang.Exception
messageReceived
in interface org.apache.mina.core.service.IoHandler
messageReceived
in class org.apache.mina.core.service.IoHandlerAdapter
java.lang.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 entry
LdapException
- in case of modify operation failure or timeout happenspublic ModifyResponse modify(ModifyRequest modRequest) throws LdapException
modRequest
- the request for modify operation
LdapException
- in case of modify operation failure or timeout happenspublic ModifyFuture modifyAsync(ModifyRequest modRequest) throws LdapException
modRequest
- the request for modify operation
LdapException
- in case of modify operation failure or timeout happenspublic ModifyDnResponse rename(java.lang.String entryDn, java.lang.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(java.lang.String entryDn, java.lang.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 Rdn
LdapException
public ModifyDnResponse move(java.lang.String entryDn, java.lang.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/superior
LdapException
public ModifyDnResponse modifyDn(ModifyDnRequest modDnRequest) throws LdapException
modDnRequest
- the request
LdapException
public ModifyDnFuture modifyDnAsync(ModifyDnRequest modDnRequest) throws LdapException
modDnRequest
- the requestlistener
- callback listener which will be called after the operation is completed
LdapException
public DeleteResponse delete(java.lang.String dn) throws LdapException
dn
- the target entry's DN as a String
LdapException
- 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 DN
LdapException
- 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 DN
LdapException
- If the DN is not valid or if the deletion failedpublic DeleteResponse deleteTree(java.lang.String dn) throws LdapException
dn
- the target entry's DN as a String
LdapException
- If the DN is not valid or if the deletion failedpublic DeleteResponse delete(DeleteRequest deleteRequest) throws LdapException
deleteRequest
- the delete operation's request
LdapException
- If the DN is not valid or if the deletion failedpublic DeleteFuture deleteAsync(DeleteRequest delRequest) throws LdapException
delRequest
- the delete operation's request
LdapException
- If the DN is not valid or if the deletion failedpublic CompareResponse compare(java.lang.String dn, java.lang.String attributeName, java.lang.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 with
LdapException
public CompareResponse compare(java.lang.String dn, java.lang.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 with
LdapException
public CompareResponse compare(java.lang.String dn, java.lang.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 with
LdapException
public CompareResponse compare(org.apache.directory.shared.ldap.name.DN dn, java.lang.String attributeName, java.lang.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 with
LdapException
public CompareResponse compare(org.apache.directory.shared.ldap.name.DN dn, java.lang.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 with
LdapException
public CompareResponse compare(org.apache.directory.shared.ldap.name.DN dn, java.lang.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 with
LdapException
public CompareResponse compare(CompareRequest compareRequest) throws LdapException
compareRequest
- the CompareRequest which contains the target DN, attribute name and value
LdapException
public CompareFuture compareAsync(CompareRequest compareRequest) throws LdapException
compareRequest
- the CompareRequest which contains the target DN, attribute name and value
LdapException
public ExtendedResponse extended(java.lang.String oid) throws LdapException
LdapException
extended(OID, byte[])
public ExtendedResponse extended(java.lang.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 value
LdapException
public ExtendedResponse extended(ExtendedRequest extendedRequest) throws LdapException
extendedRequest
- the extended operation's request
LdapException
- 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 performed
LdapException
public SearchResponse lookup(java.lang.String dn) throws LdapException
LdapException
lookup(String, String...)
public SearchResponse lookup(java.lang.String dn, java.lang.String... attributes) throws LdapException
dn
- the DN of the entry to be fetchedattributes
- the attributes to be returned along with entry
LdapException
- in case of any problems while searching for the DNpublic boolean isControlSupported(java.lang.String controlOID) throws LdapException
controlOID
- the OID of the control
LdapException
public java.util.List<java.lang.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(java.lang.Integer messageId)
messageId
- ID of the request
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |