public class LdapConnectionWrapper extends Object implements LdapConnection, Wrapper<LdapConnection>
Wrapper
for LdapConnection
objects. All methods are passed through to the wrapped
LdapConnection
.Modifier and Type | Field and Description |
---|---|
protected LdapConnection |
connection |
Modifier | Constructor and Description |
---|---|
protected |
LdapConnectionWrapper(LdapConnection connection) |
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.
|
AddResponse |
add(AddRequest addRequest)
Add an entry present in the
AddRequest to the server. |
void |
add(Entry entry)
Add an entry to the server.
|
void |
anonymousBind()
Anonymous 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.
|
void |
bind(Dn name)
Unauthenticated authentication bind on a server.
|
void |
bind(Dn name,
String credentials)
Simple bind on a server.
|
void |
bind(String name)
Unauthenticated authentication bind on a server.
|
void |
bind(String name,
String credentials)
Simple bind on a server.
|
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,
String attributeName,
byte[] value)
Compares whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given distinguished name.
|
boolean |
compare(Dn dn,
String attributeName,
String value)
Compares whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given distinguished name.
|
boolean |
compare(Dn dn,
String attributeName,
Value<?> value)
Compares whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given distinguished name.
|
boolean |
compare(String dn,
String attributeName,
byte[] value)
Compares whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given distinguished name.
|
boolean |
compare(String dn,
String attributeName,
String value)
Compares whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given distinguished name.
|
boolean |
compare(String dn,
String attributeName,
Value<?> value)
Compares whether a given attribute's value matches that of the
existing value of the attribute present in the entry with the given distinguished name.
|
boolean |
connect()
Connect to the remote LDAP server.
|
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(String dn)
Deletes the entry with the given distinguished name.
|
boolean |
doesFutureExistFor(int messageId)
Checks if there is a ResponseFuture associated with the given message ID.
|
boolean |
exists(Dn dn)
Tells if an Entry exists in the server.
|
boolean |
exists(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(String oid)
Sends a extended operation request to the server with the given OID and no value.
|
ExtendedResponse |
extended(String oid,
byte[] value)
Sends a extended operation request to the server with the given OID and value.
|
BinaryAttributeDetector |
getBinaryAttributeDetector() |
LdapApiService |
getCodecService()
Gets the LDAP CODEC service responsible for encoding and decoding
messages.
|
Entry |
getRootDse()
Get back the RooDSE from the connected server.
|
Entry |
getRootDse(String... attributes)
Get back the RooDSE from the connected server.
|
SchemaManager |
getSchemaManager() |
List<String> |
getSupportedControls()
Get the Controls supported by server.
|
boolean |
isAuthenticated()
Check if we are authenticated.
|
boolean |
isConnected()
Check if we are connected.
|
boolean |
isControlSupported(String controlOID)
Checks if a control with the given OID is supported.
|
void |
loadSchema()
Loads all the default schemas that are bundled with the API.
Note: This method enables all schemas prior to loading. |
Entry |
lookup(Dn dn)
Searches for an entry having the given Dn.
|
Entry |
lookup(Dn dn,
Control[] controls,
String... attributes)
Searches for an entry having the given Dn.
|
Entry |
lookup(Dn dn,
String... attributes)
Searches for an entry having the given Dn.
|
Entry |
lookup(String dn)
Searches for an entry having the given Dn.
|
Entry |
lookup(String dn,
Control[] controls,
String... attributes)
Searches for an entry having the given Dn.
|
Entry |
lookup(String dn,
String... attributes)
Searches for an entry having the given Dn.
|
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(String dn,
Modification... modifications)
Applies all the modifications to the entry specified by its distinguished name.
|
ModifyDnResponse |
modifyDn(ModifyDnRequest modDnRequest)
Performs the modifyDn operation based on the given request object.
|
void |
move(Dn entryDn,
Dn newSuperiorDn)
Moves the given entry Dn under the new superior Dn.
|
void |
move(String entryDn,
String newSuperiorDn)
Moves the given entry Dn under the new superior Dn.
|
void |
moveAndRename(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(String entryDn,
String newDn)
Moves and renames the given entryDn.The old Rdn will be deleted
|
void |
moveAndRename(String entryDn,
String newDn,
boolean deleteOldRdn)
Moves and renames the given entryDn.
|
void |
rename(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(String entryDn,
String newRdn)
Renames the given entryDn with new Rdn and deletes the old Rdn.
|
void |
rename(String entryDn,
String newRdn,
boolean deleteOldRdn)
Renames the given entryDn with new Rdn and deletes the old Rdn if
deleteOldRdn is set to true.
|
EntryCursor |
search(Dn baseDn,
String filter,
SearchScope scope,
String... attributes)
Do a search, on the base object, using the given filter and scope.
|
SearchCursor |
search(SearchRequest searchRequest)
Performs search using a search request object.
|
EntryCursor |
search(String baseDn,
String filter,
SearchScope scope,
String... attributes)
Do a search, on the base object, using the given filter and scope.
|
void |
setBinaryAttributeDetector(BinaryAttributeDetector binaryAttributeDetecter)
Sets the object responsible for the detection of binary attributes.
|
void |
setSchemaManager(SchemaManager schemaManager)
sets a SchemaManager to be used by this connection
|
void |
setTimeOut(long timeOut)
Set the timeout for the responses.
|
void |
unBind()
UnBind from a server.
|
LdapConnection |
wrapped()
Returns the wrapped object.
|
protected LdapConnection connection
protected LdapConnectionWrapper(LdapConnection connection)
public LdapConnection wrapped()
wrapped
in interface Wrapper<LdapConnection>
public boolean isConnected()
LdapConnection
isConnected
in interface LdapConnection
true
if we are connected.public boolean isAuthenticated()
LdapConnection
isAuthenticated
in interface LdapConnection
true
if we are connected.public boolean connect() throws LdapException
LdapConnection
connect
in interface LdapConnection
true
if the connection is established, false otherwiseLdapException
- if some error occurredpublic void close() throws IOException
LdapConnection
close
in interface Closeable
close
in interface AutoCloseable
close
in interface LdapConnection
IOException
- if some I/O error occurspublic void add(Entry entry) throws LdapException
LdapConnection
add
in interface LdapConnection
entry
- The entry to addLdapException
- if some error occurredpublic AddResponse add(AddRequest addRequest) throws LdapException
LdapConnection
AddRequest
to the server.add
in interface LdapConnection
addRequest
- the request object containing an entry and controls (if any)LdapException
- if some error occurredpublic void abandon(int messageId)
LdapConnection
abandon
in interface LdapConnection
messageId
- the ID of the request message sent to the serverpublic void abandon(AbandonRequest abandonRequest)
LdapConnection
abandon
in interface LdapConnection
abandonRequest
- the abandon operation's requestpublic void bind() throws LdapException
LdapConnection
LdapConnectionConfig
information of this connection.bind
in interface LdapConnection
LdapException
- if some error occurredpublic void anonymousBind() throws LdapException
LdapConnection
anonymousBind
in interface LdapConnection
LdapException
- if some error occurredpublic void bind(String name) throws LdapException
LdapConnection
bind
in interface LdapConnection
name
- The name we use to authenticate the user. It must be a
valid Dn
LdapException
- if some error occurredpublic void bind(String name, String credentials) throws LdapException
LdapConnection
bind
in interface LdapConnection
name
- The name we use to authenticate the user. It must be a
valid Dn
credentials
- The password, it can't be null
LdapException
- if some error occurredpublic void bind(Dn name) throws LdapException
LdapConnection
bind
in interface LdapConnection
name
- The name we use to authenticate the user.LdapException
- if some error occurredpublic void bind(Dn name, String credentials) throws LdapException
LdapConnection
bind
in interface LdapConnection
name
- The name we use to authenticate the user.credentials
- The password, it can't be nullLdapException
- if some error occurredpublic BindResponse bind(BindRequest bindRequest) throws LdapException
LdapConnection
bind
in interface LdapConnection
bindRequest
- The bind request object containing all the needed parametersBindResponse
containing the resultLdapException
- if some error occurredpublic EntryCursor search(Dn baseDn, String filter, SearchScope scope, String... attributes) throws LdapException
LdapConnection
search
in interface LdapConnection
baseDn
- The base for the search. It must be a valid distinguished name and can't be emtpyfilter
- The filter to use for this search. It can't be emptyscope
- The search scope : OBJECT, ONELEVEL or SUBTREEattributes
- The attributes to use for this searchEntryCursor
on the result.LdapException
- if some error occurredpublic EntryCursor search(String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException
LdapConnection
search
in interface LdapConnection
baseDn
- The base for the search. It must be a valid distinguished name, and can't be emtpyfilter
- The filter to use for this search. It can't be emptyscope
- The search scope : OBJECT, ONELEVEL or SUBTREEattributes
- The attributes to use for this searchEntryCursor
on the result.LdapException
- if some error occurredpublic SearchCursor search(SearchRequest searchRequest) throws LdapException
LdapConnection
search
in interface LdapConnection
searchRequest
- The search request object containing all the needed informationLdapException
- if some error occurredpublic void unBind() throws LdapException
LdapConnection
unBind
in interface LdapConnection
LdapException
- if some error occurredpublic void setTimeOut(long timeOut)
LdapConnection
setTimeOut
in interface LdapConnection
timeOut
- The timeout, in millisecondspublic void modify(Dn dn, Modification... modifications) throws LdapException
LdapConnection
modify
in interface LdapConnection
dn
- The entry's distinguished namemodifications
- The list of modifications to be appliedLdapException
- in case of modify operation failure or timeout happenspublic void modify(String dn, Modification... modifications) throws LdapException
LdapConnection
modify
in interface LdapConnection
dn
- The entry's distinguished name, it must be a valid Dn
modifications
- The list of modifications to be appliedLdapException
- in case of modify operation failure or timeout happenspublic void modify(Entry entry, ModificationOperation modOp) throws LdapException
LdapConnection
modify
in interface LdapConnection
entry
- 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 ModifyResponse modify(ModifyRequest modRequest) throws LdapException
LdapConnection
modify
in interface LdapConnection
modRequest
- the modify request objectLdapException
- in case of modify operation failure or timeout happenspublic void rename(String entryDn, String newRdn) throws LdapException
LdapConnection
rename
in interface LdapConnection
entryDn
- 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
LdapConnection
rename
in interface LdapConnection
entryDn
- the target DnnewRdn
- new Rdn for the target DnLdapException
- if some error occurredLdapConnection.rename(Dn, Rdn, boolean)
public void rename(String entryDn, String newRdn, boolean deleteOldRdn) throws LdapException
LdapConnection
rename
in interface LdapConnection
entryDn
- 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
LdapConnection
rename
in interface LdapConnection
entryDn
- the target DnnewRdn
- new Rdn for the target DndeleteOldRdn
- flag to indicate whether to delete the old RdnLdapException
- if some error occurredpublic void move(String entryDn, String newSuperiorDn) throws LdapException
LdapConnection
move
in interface LdapConnection
entryDn
- 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
LdapConnection
move
in interface LdapConnection
entryDn
- the Dn of the target entrynewSuperiorDn
- Dn of the new parent/superiorLdapException
- if some error occurredpublic void moveAndRename(Dn entryDn, Dn newDn) throws LdapException
LdapConnection
moveAndRename
in interface LdapConnection
entryDn
- The original entry DnnewDn
- The new entry DnLdapException
- if some error occurredLdapConnection.moveAndRename(Dn, Dn, boolean)
public void moveAndRename(String entryDn, String newDn) throws LdapException
LdapConnection
moveAndRename
in interface LdapConnection
entryDn
- 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
LdapConnection
moveAndRename
in interface LdapConnection
entryDn
- The original entry DnnewDn
- The new entry DndeleteOldRdn
- Tells if the old Rdn must be removedLdapException
- if some error occurredpublic void moveAndRename(String entryDn, String newDn, boolean deleteOldRdn) throws LdapException
LdapConnection
moveAndRename
in interface LdapConnection
entryDn
- 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
LdapConnection
modifyDn
in interface LdapConnection
modDnRequest
- the request objectLdapException
- if some error occurredpublic void delete(String dn) throws LdapException
LdapConnection
delete
in interface LdapConnection
dn
- the target entry's distinguished name, it must be a valid Dn
LdapException
- If the Dn is not valid or if the deletion failedpublic void delete(Dn dn) throws LdapException
LdapConnection
delete
in interface LdapConnection
dn
- the target entry's distinguished nameLdapException
- If the Dn is not valid or if the deletion failedpublic DeleteResponse delete(DeleteRequest deleteRequest) throws LdapException
LdapConnection
delete
in interface LdapConnection
deleteRequest
- the delete operation's requestLdapException
- If the Dn is not valid or if the deletion failedpublic boolean compare(String dn, String attributeName, String value) throws LdapException
LdapConnection
compare
in interface LdapConnection
dn
- the target entry's distinguished name, it must be a valid Dn
attributeName
- 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(String dn, String attributeName, byte[] value) throws LdapException
LdapConnection
compare
in interface LdapConnection
dn
- the target entry's distinguished name, it must be a valid Dn
attributeName
- 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(String dn, String attributeName, Value<?> value) throws LdapException
LdapConnection
compare
in interface LdapConnection
dn
- the target entry's distinguished name, it must be a valid Dn
attributeName
- 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, String attributeName, String value) throws LdapException
LdapConnection
compare
in interface LdapConnection
dn
- the target entry's distinguished nameattributeName
- the attribute's namevalue
- a String value with which the target entry's attribute value to be compared withtrue
if the value matches, false
otherwiseLdapException
- if some error occurredpublic boolean compare(Dn dn, String attributeName, byte[] value) throws LdapException
LdapConnection
compare
in interface LdapConnection
dn
- the target entry's distinguished nameattributeName
- the attribute's namevalue
- a byte[] value with which the target entry's attribute value to be compared withtrue
if the value matches, false
otherwiseLdapException
- if some error occurredpublic boolean compare(Dn dn, String attributeName, Value<?> value) throws LdapException
LdapConnection
compare
in interface LdapConnection
dn
- the target entry's distinguished nameattributeName
- the attribute's namevalue
- a Value> value with which the target entry's attribute value to be compared withtrue
if the value matches, false
otherwiseLdapException
- if some error occurredpublic CompareResponse compare(CompareRequest compareRequest) throws LdapException
LdapConnection
compare
in interface LdapConnection
compareRequest
- the compare request which contains the target Dn, attribute name and valueLdapException
- if some error occurredpublic ExtendedResponse extended(String oid) throws LdapException
LdapConnection
extended
in interface LdapConnection
oid
- the object identifier of the extended operationLdapException
- if some error occurredLdapConnection.extended(org.apache.directory.api.asn1.util.Oid, byte[])
public ExtendedResponse extended(String oid, byte[] value) throws LdapException
LdapConnection
extended
in interface LdapConnection
oid
- 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
LdapConnection
extended
in interface LdapConnection
oid
- 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
LdapConnection
extended
in interface LdapConnection
oid
- 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
LdapConnection
extended
in interface LdapConnection
extendedRequest
- the extended operation's requestLdapException
- if the extended operation failedpublic boolean exists(String dn) throws LdapException
LdapConnection
exists
in interface LdapConnection
dn
- The distinguished name of the entry we want to check the existence, must be a valid Dn
true
if the entry exists, false
otherwise.
Note that if the entry exists but if the user does not have the permission to
read it, false
will also be returnedLdapException
- if some error occurredpublic boolean exists(Dn dn) throws LdapException
LdapConnection
exists
in interface LdapConnection
dn
- 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
LdapConnection
getRootDse
in interface LdapConnection
LdapException
- If the rootDSE can't be readpublic Entry getRootDse(String... attributes) throws LdapException
LdapConnection
getRootDse
in interface LdapConnection
attributes
- The list of attributes to returnLdapException
- If the rootDSE can't be readpublic Entry lookup(Dn dn) throws LdapException
LdapConnection
lookup
in interface LdapConnection
dn
- 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(String dn) throws LdapException
LdapConnection
lookup
in interface LdapConnection
dn
- 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, String... attributes) throws LdapException
LdapConnection
lookup
in interface LdapConnection
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 Dn or if the returned response contains a referralpublic Entry lookup(Dn dn, Control[] controls, String... attributes) throws LdapException
LdapConnection
lookup
in interface LdapConnection
dn
- 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(String dn, String... attributes) throws LdapException
LdapConnection
lookup
in interface LdapConnection
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 Dn or if the returned response contains a referralLdapConnection.lookup(org.apache.directory.api.ldap.model.name.Dn, String...)
public Entry lookup(String dn, Control[] controls, String... attributes) throws LdapException
LdapConnection
lookup
in interface LdapConnection
dn
- 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(String controlOID) throws LdapException
LdapConnection
isControlSupported
in interface LdapConnection
controlOID
- the OID of the controlLdapException
- if some error occurredpublic List<String> getSupportedControls() throws LdapException
LdapConnection
getSupportedControls
in interface LdapConnection
LdapException
- if some error occurredpublic void loadSchema() throws LdapException
LdapConnection
loadSchema
in interface LdapConnection
LdapException
- in case of problems while loading the schemapublic SchemaManager getSchemaManager()
getSchemaManager
in interface LdapConnection
public LdapApiService getCodecService()
LdapConnection
getCodecService
in interface LdapConnection
public boolean doesFutureExistFor(int messageId)
LdapConnection
doesFutureExistFor
in interface LdapConnection
messageId
- ID of the requestpublic BinaryAttributeDetector getBinaryAttributeDetector()
getBinaryAttributeDetector
in interface LdapConnection
public void setBinaryAttributeDetector(BinaryAttributeDetector binaryAttributeDetecter)
LdapConnection
setBinaryAttributeDetector
in interface LdapConnection
public void setSchemaManager(SchemaManager schemaManager)
LdapConnection
setSchemaManager
in interface LdapConnection
Copyright © 2003–2015 The Apache Software Foundation. All rights reserved.