org.apache.ldap.clients
Class LdapBind

java.lang.Object
  extended by org.apache.ldap.clients.LdapBind
Direct Known Subclasses:
LdapAdd, LdapDel, LdapModify, LdapSearch

public class LdapBind
extends java.lang.Object

Ldap client for the ADD operation


Constructor Summary
LdapBind(java.lang.String[] argv)
          Take the command line string and pass it into the argument parser, which will set our option flags.
 
Method Summary
 BindResponse bind(int id)
          Send the bind request to the LDAP server.
 void connect()
          Connect to the LDAP server through a socket and establish the Input and Output Streams.
 void disconnect()
          Close the socket
 void enableLogging(Level level)
          Set the logging priority of the logger object
 MessageDecoder getDecoder()
          Get the message decoder used to tranform the ASN1 from the server
 MessageEncoder getEncoder()
          Get the message encoder used to transform the message into ASN1 nototation being sent to the server
 java.io.InputStream getIn()
          Get the input stream used to send messages to the server
 Logger getLog()
          Get the instance of the logger
 java.lang.String getModule()
          Get the module's name
 BindOpts getOpts()
          Get the command line options from the clinet
 java.io.OutputStream getOut()
          Get the output stream used to receive messages from the server
 java.net.Socket getSocket()
          Get the socket used to connect to the server machine
static void main(java.lang.String[] args)
          Main method for the Bind client.
 void setDecoder(MessageDecoder decoder)
          Set the Message decoder used to tranform the ASN1 from the server
 void setEncoder(MessageEncoder encoder)
          Set the Message encoder used to transform the message into ASN1 nototation being sent to the server
 void setIn(java.io.InputStream stream)
          Set the input stream used to send messages to the server
 void setLog(Logger logger)
          Set the instance of the logger
 void setModule(java.lang.String module)
          Set the module's name
 void setOpts(BindOpts opts)
          Set the command line options from the clinet
 void setOut(java.io.OutputStream stream)
          Set the output stream used to receive messages from the server
 void setSocket(java.net.Socket socket)
          Set the socket used to connect to the server machine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LdapBind

public LdapBind(java.lang.String[] argv)
Take the command line string and pass it into the argument parser, which will set our option flags.

Parameters:
argv - The command line string
Method Detail

getModule

public java.lang.String getModule()
Get the module's name

Returns:
Returns the module's name.

enableLogging

public void enableLogging(Level level)
Set the logging priority of the logger object

Parameters:
level - The level to set the logging to

getDecoder

public MessageDecoder getDecoder()
Get the message decoder used to tranform the ASN1 from the server

Returns:
Message decoder used to tranform the ASN1 from the server

getEncoder

public MessageEncoder getEncoder()
Get the message encoder used to transform the message into ASN1 nototation being sent to the server

Returns:
Message encoder used to transform the message into ASN1 nototation being sent to the server

getIn

public java.io.InputStream getIn()
Get the input stream used to send messages to the server

Returns:
Input stream used to send messages to the server

getLog

public Logger getLog()
Get the instance of the logger

Returns:
The logger

getOpts

public BindOpts getOpts()
Get the command line options from the clinet

Returns:
The command line options object

getOut

public java.io.OutputStream getOut()
Get the output stream used to receive messages from the server

Returns:
Ouput stream used to receive messages from the server

getSocket

public java.net.Socket getSocket()
Get the socket used to connect to the server machine

Returns:
Socket used to connect to the server machine

setModule

public void setModule(java.lang.String module)
Set the module's name

Parameters:
module - The module name to set.

setDecoder

public void setDecoder(MessageDecoder decoder)
Set the Message decoder used to tranform the ASN1 from the server

Parameters:
decoder - Message decoder used to tranform the ASN1 from server

setEncoder

public void setEncoder(MessageEncoder encoder)
Set the Message encoder used to transform the message into ASN1 nototation being sent to the server

Parameters:
encoder - Message encoder used to transform the message into ASN1 nototation being sent to the server

setIn

public void setIn(java.io.InputStream stream)
Set the input stream used to send messages to the server

Parameters:
stream - Set the input stream used to send messages to the server

setLog

public void setLog(Logger logger)
Set the instance of the logger

Parameters:
logger - logger object

setOpts

public void setOpts(BindOpts opts)
Set the command line options from the clinet

Parameters:
opts - Command line options from the clinet

setOut

public void setOut(java.io.OutputStream stream)
Set the output stream used to receive messages from the server

Parameters:
stream - Output stream used to receive messages from the server

setSocket

public void setSocket(java.net.Socket socket)
Set the socket used to connect to the server machine

Parameters:
a_socket - Socket used to connect to the server machine

connect

public void connect()
             throws java.net.UnknownHostException,
                    java.io.IOException
Connect to the LDAP server through a socket and establish the Input and Output Streams. All the required information for the connection should be in the options from the command line, or the default values.

Throws:
java.net.UnknownHostException - The hostname or the Address of server could not be found
java.io.IOException - There was a error opening or establishing the socket

bind

public BindResponse bind(int id)
                  throws java.net.UnknownHostException,
                         java.io.IOException
Send the bind request to the LDAP server.

Parameters:
id - Message number of this request, If this is a simple bind, the ID will be one.
Returns:
The decoder response from the bind request
Throws:
java.net.UnknownHostException - The hostname or the Address of server could not be found
java.io.IOException - There was a error opening or establishing the socket

disconnect

public void disconnect()
                throws java.io.IOException
Close the socket

Throws:
java.io.IOException - Could not close the socket

main

public static void main(java.lang.String[] args)
Main method for the Bind client. All this will do is call the bind, read the response, close the socket and report the response of the bind operation

Parameters:
args - Command line string