org.apache.ldap.clients.embedded
Class LdapClientImpl

java.lang.Object
  extended by org.apache.ldap.clients.embedded.LdapClientImpl
All Implemented Interfaces:
LdapClient

public class LdapClientImpl
extends java.lang.Object
implements LdapClient

Interface into the LDAPd session


Field Summary
static java.lang.String DEFAULT_HOST
          The default host to use if it is not specified on command lin
static int DEFAULT_PORT
          The default port to use if none are specified on command line
 
Constructor Summary
LdapClientImpl()
           
 
Method Summary
 void closeServerConnection()
          Close the socket connection to the server.
 void connectToServer()
          Connects the socket to the server.
 java.lang.String getBindDn()
          DN used to bind to the server
 java.lang.String getHost()
          Get the hostname if of the LDAP server
 java.lang.String getPassword()
          Password of the DN entry used to bind to the server
 int getPort()
          Port used to connect to the LDAP server
 boolean isConnectedToServer()
          Determines if there is a current connection to the server
 boolean isDryRun()
          Determine if this is a dry run, no message sent to the server
 boolean isVerbose()
          Determine if verbose has been turned on
 boolean isVersion3()
          Determine if the LDIF format version 3 compliant
 LdapClientResponse ldapAdd(java.lang.StringBuffer a_entry)
           
 LdapClientResponse ldapBind()
          Perform an LDAP bind to the server
 LdapClientResponse ldapDelete(java.lang.String a_deleteDn)
          Perform an LDAP delete on the DN passed in
 LdapClientResponse ldapModify(java.lang.StringBuffer a_entry)
           
 LdapClientResponse ldapSearch(LdapSearchParameters a_parms)
          Perform an LDAP search operation on the search filer passed in.
 void ldapUnbind()
          Perform an LDAP unbind to the server
 void printAttributeList(javax.naming.NamingEnumeration a_attributeList)
          Print each attribute and the values for each attribute from the list passed into the method.
 void printAttributeNames(javax.naming.NamingEnumeration a_attributeList)
          Print each attribute name only.
 void printLdapBindResponse(BindResponse a_response)
           
 void setBindDn(java.lang.String a_bindDn)
          Set the DN of the user to bind to server with
 void setHost(java.lang.String a_host)
          Set the hostname of the LDAP Server
 void setIsDryRun(boolean a_isDryRun)
          Set the value of the dry run mode
 void setIsVerbose(boolean a_isVerbose)
          Set verbose mode
 void setIsVersion3(boolean a_isVersion3)
          Set value of version3 compatibility
 void setPassword(java.lang.String a_password)
          Password for the DN entry being used to bind
 void setPort(int a_port)
          Set the port number to connect to server with
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The default port to use if none are specified on command line

See Also:
Constant Field Values

DEFAULT_HOST

public static final java.lang.String DEFAULT_HOST
The default host to use if it is not specified on command lin

See Also:
Constant Field Values
Constructor Detail

LdapClientImpl

public LdapClientImpl()
Method Detail

setHost

public void setHost(java.lang.String a_host)
Set the hostname of the LDAP Server

Specified by:
setHost in interface LdapClient
Parameters:
a_host - Hostname of the LDAP Server

setPort

public void setPort(int a_port)
Set the port number to connect to server with

Specified by:
setPort in interface LdapClient
Parameters:
a_port - Port number to use to connect to the server

setBindDn

public void setBindDn(java.lang.String a_bindDn)
Set the DN of the user to bind to server with

Specified by:
setBindDn in interface LdapClient
Parameters:
a_bindDn - DN of the user to bind to server with

setPassword

public void setPassword(java.lang.String a_password)
Password for the DN entry being used to bind

Specified by:
setPassword in interface LdapClient
Parameters:
a_password - Password for the DN entry being used to bind

setIsVersion3

public void setIsVersion3(boolean a_isVersion3)
Set value of version3 compatibility

Specified by:
setIsVersion3 in interface LdapClient
Parameters:
a_isVersion3 - True if LDIF is version3

setIsVerbose

public void setIsVerbose(boolean a_isVerbose)
Set verbose mode

Specified by:
setIsVerbose in interface LdapClient
Parameters:
a_isVerbose - True if verbose mode is turned on

setIsDryRun

public void setIsDryRun(boolean a_isDryRun)
Set the value of the dry run mode

Specified by:
setIsDryRun in interface LdapClient
Parameters:
a_isDryRun - True if the dry run mode is turned on

getHost

public java.lang.String getHost()
Get the hostname if of the LDAP server

Specified by:
getHost in interface LdapClient
Returns:
hostname of the LDAP server

getPort

public int getPort()
Port used to connect to the LDAP server

Specified by:
getPort in interface LdapClient
Returns:
Port used to connect to the LDAP server

getBindDn

public java.lang.String getBindDn()
DN used to bind to the server

Specified by:
getBindDn in interface LdapClient
Returns:
DN used to bind to the server

getPassword

public java.lang.String getPassword()
Password of the DN entry used to bind to the server

Specified by:
getPassword in interface LdapClient
Returns:
Password of the DN entry used to bind to the server

isVersion3

public boolean isVersion3()
Determine if the LDIF format version 3 compliant

Specified by:
isVersion3 in interface LdapClient
Returns:
True if the LDIF format version 3 compliant

isVerbose

public boolean isVerbose()
Determine if verbose has been turned on

Specified by:
isVerbose in interface LdapClient
Returns:
True if verbose has been turned on

isDryRun

public boolean isDryRun()
Determine if this is a dry run, no message sent to the server

Specified by:
isDryRun in interface LdapClient
Returns:
True if this is a dry run

connectToServer

public void connectToServer()
                     throws java.net.UnknownHostException,
                            java.io.IOException
Description copied from interface: LdapClient
Connects the socket to the server. This will not perform a bind, it will only establish the connection. The bind will call this, it does not have to be done manually. This can be used to test or step through the communication process.

Specified by:
connectToServer in interface LdapClient
Throws:
java.net.UnknownHostException - Cannot find the host
java.io.IOException - Error establishing the socket connection

isConnectedToServer

public boolean isConnectedToServer()
Description copied from interface: LdapClient
Determines if there is a current connection to the server

Specified by:
isConnectedToServer in interface LdapClient
Returns:
True if the connection is established

closeServerConnection

public void closeServerConnection()
                           throws java.io.IOException
Description copied from interface: LdapClient
Close the socket connection to the server. This will help keep the server clean.

Specified by:
closeServerConnection in interface LdapClient
Throws:
java.io.IOException - Error terminating the socket connection

ldapBind

public LdapClientResponse ldapBind()
                            throws java.io.IOException
Description copied from interface: LdapClient
Perform an LDAP bind to the server

Specified by:
ldapBind in interface LdapClient
Returns:
Response Object
Throws:
java.io.IOException - Error with the IO communication to the server

printLdapBindResponse

public void printLdapBindResponse(BindResponse a_response)
                           throws java.io.IOException
Throws:
java.io.IOException

ldapUnbind

public void ldapUnbind()
                throws java.io.IOException
Description copied from interface: LdapClient
Perform an LDAP unbind to the server

Specified by:
ldapUnbind in interface LdapClient
Throws:
java.io.IOException - Error with the IO communication to the server

ldapDelete

public LdapClientResponse ldapDelete(java.lang.String a_deleteDn)
                              throws java.io.IOException
Description copied from interface: LdapClient
Perform an LDAP delete on the DN passed in

Specified by:
ldapDelete in interface LdapClient
Parameters:
a_deleteDn - DN of the entry to delete
Returns:
Response Object
Throws:
java.io.IOException - Error with the IO communication to the server

ldapAdd

public LdapClientResponse ldapAdd(java.lang.StringBuffer a_entry)
                           throws java.io.IOException
Specified by:
ldapAdd in interface LdapClient
Returns:
Response Object
Throws:
java.io.IOException - Error with the IO communication to the server

ldapModify

public LdapClientResponse ldapModify(java.lang.StringBuffer a_entry)
                              throws java.io.IOException
Specified by:
ldapModify in interface LdapClient
Returns:
Response Object
Throws:
java.io.IOException - Error with the IO communication to the server

ldapSearch

public LdapClientResponse ldapSearch(LdapSearchParameters a_parms)
                              throws java.io.IOException
Description copied from interface: LdapClient
Perform an LDAP search operation on the search filer passed in. The result code and the actuall search results will be placed in the LdapClientResponse objected returned

Specified by:
ldapSearch in interface LdapClient
Returns:
Response Object containing the result code and search results
Throws:
java.io.IOException - Error with the IO communication to the server

printAttributeNames

public void printAttributeNames(javax.naming.NamingEnumeration a_attributeList)
Print each attribute name only. This is used when the Types Only mode is selected from the command line options

Specified by:
printAttributeNames in interface LdapClient
Parameters:
a_attributeList - NamingEnumeration of Attributes

printAttributeList

public void printAttributeList(javax.naming.NamingEnumeration a_attributeList)
Print each attribute and the values for each attribute from the list passed into the method. Each attribute has an ID, which is the name of the attribute and a list of values. This is the default method for the search client output. Each value of the same attribute will also print the ID, for example an entry with two value for objectclass will look like this: ou=unix,ou=People,dc=fl,dc=wellspringres,dc=com objectClass=top objectClass=organizationalunit ou=unix

Specified by:
printAttributeList in interface LdapClient
Parameters:
a_attributeList - NamingEnumeration of Attributes