com.ibm.di.connector
Class LDAPServerConnector

java.lang.Object
  extended by com.ibm.di.connector.Connector
      extended by com.ibm.di.connector.LDAPServerConnector
All Implemented Interfaces:
ConnectorInterface, VersionInfoInterface

public class LDAPServerConnector
extends Connector
implements ConnectorInterface

LDAPServerConnector is an LDAP server that returns a client connection from the getNextClient method. The returned connector interface is initialized with an LDAP client connection. Calls to the returned connector should be getNextEntry() to retrieve the next client request (e.g. bind, search etc), putEntry() to send search results to the LDAP client and finally replyEntry() to send the status message that completes the client request.

The returned connector is not thread safe. Alls calls to putEntry and replyEntry uses the previous getNextEntry request attributes in the data sent to the client. Specifically, the LDAP message id and response operation code is reused from the client request.


Field Summary
static String PARAM_SYSTEM_TCP_BACKLOG
          Configuration parameter name: "com.ibm.di.tcp.backlog"
static String PARAM_TCP_BACKLOG
          Configuration parameter name: "backlog"
 
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
 
Constructor Summary
LDAPServerConnector()
          Default constructor.
 
Method Summary
 LDAPControl createControl(String oid)
          Creates an instance of the LDAPControl class.
 ConnectorInterface getNextClient()
          Server mode - returns a new instance of the connector with a client connection.
 Entry getNextEntry()
          Returns the next Entry from the LDAP client.
static ResourceHash getResHash()
           
 LDAPServerConnector getServerConnector()
          Retrieves server connector.
 String getVersion()
          Version information.
 void initialize(Object obj)
          Initialize the connector.
 boolean isAbandoned(int messageID)
          This method returns true if there is an abandon message in the queue with the specified message ID.
 boolean isAccepting()
          Checks if the connector is waiting for a client connection.
 boolean isTerminating()
          Checks if a termination request is sent.
 void putEntry(Entry entry)
          Sends a search result entry to the LDAP client in response to a search request.
 void replyEntry(Entry conn)
          Send an LDAP result message in response to the last request from the LDAP Client.
 void setServerConnector(LDAPServerConnector serverConnector)
          Sets the server connector for this connector.
 void terminate()
          Terminate the connector.
 void terminateServer()
          This method tries to terminate the server by setting the termination flag for the connector returned by getServerConnector and immediately connecting to its port (which should fail).
 
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, deleteEntry, findEntry, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, getUI, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logError, logmsg, modEntry, modEntry, pushback, queryOperations, queryReply, querySchema, queryTables, reconnect, reconnect, registerScriptBeans, selectEntries, setConfiguration, setContext, setCurrent, setDebugMode, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.di.connector.ConnectorInterface
deleteEntry, findEntry, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, modEntry, modEntry, pushback, queryOperations, queryReply, querySchema, reconnect, registerScriptBeans, selectEntries, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface
 

Field Detail

PARAM_TCP_BACKLOG

public static final String PARAM_TCP_BACKLOG
Configuration parameter name: "backlog"

See Also:
Constant Field Values

PARAM_SYSTEM_TCP_BACKLOG

public static final String PARAM_SYSTEM_TCP_BACKLOG
Configuration parameter name: "com.ibm.di.tcp.backlog"

See Also:
Constant Field Values
Constructor Detail

LDAPServerConnector

public LDAPServerConnector()
Default constructor.

Method Detail

getResHash

public static ResourceHash getResHash()
Returns:
The resource object.

getServerConnector

public LDAPServerConnector getServerConnector()
Retrieves server connector.

Returns:
the server connector if this connector is handling an LDAP client session.

setServerConnector

public void setServerConnector(LDAPServerConnector serverConnector)
Sets the server connector for this connector.

Parameters:
serverConnector - the server connector to set.

isAccepting

public boolean isAccepting()
Checks if the connector is waiting for a client connection.

Returns:
true if this connector is currently waiting for a client connection.

isTerminating

public boolean isTerminating()
Checks if a termination request is sent.

Returns:
true if this connector has the termination flag set.

terminateServer

public void terminateServer()
                     throws Exception
This method tries to terminate the server by setting the termination flag for the connector returned by getServerConnector and immediately connecting to its port (which should fail).

Specified by:
terminateServer in interface ConnectorInterface
Overrides:
terminateServer in class Connector
Throws:
Exception - if an error occurs.

initialize

public void initialize(Object obj)
                throws Exception
Initialize the connector. To initialize this connector with an LDAP client session provide a java.net.Socket object for the obj parameter. In all other cases, the connector will initialize an LDAP server session.

Specified by:
initialize in interface ConnectorInterface
Overrides:
initialize in class Connector
Parameters:
obj - Null, Socket or ConnectorMode class
Throws:
Exception - if an error occurs.

terminate

public void terminate()
               throws Exception
Terminate the connector. This function closes all connection and releases all resources used by the connector. This function also calls the parser's closeParser() method if a parser is active.

Specified by:
terminate in interface ConnectorInterface
Overrides:
terminate in class Connector
Throws:
Exception - if an error occurs.

getNextClient

public ConnectorInterface getNextClient()
                                 throws Exception
Server mode - returns a new instance of the connector with a client connection. The new connector map getNextEntry() to get requests from the client, putEntry(Entry) to send a search result to the client, and finally replyEntry(Entry) to send the LDAP result message.

Specified by:
getNextClient in interface ConnectorInterface
Overrides:
getNextClient in class Connector
Returns:
an instance of this connector, that handles client sessions.
Throws:
Exception - if an error occurs.

getNextEntry

public Entry getNextEntry()
                   throws Exception
Returns the next Entry from the LDAP client.

Specified by:
getNextEntry in interface ConnectorInterface
Overrides:
getNextEntry in class Connector
Returns:
- the next Entry, or null if client connection has been closed.
Throws:
Exception - if an error occurs.
See Also:
Connector.selectEntries()

putEntry

public void putEntry(Entry entry)
              throws Exception
Sends a search result entry to the LDAP client in response to a search request. The previously received client request must be a Search request or this method will most likely cause trouble for the LDAP client since the message id from the previous request is used in the search result packet.

Specified by:
putEntry in interface ConnectorInterface
Overrides:
putEntry in class Connector
Parameters:
entry - The entry. It must contain the $dn attribute plus other LDAP attributes.
Throws:
Exception - if an error occurs.

replyEntry

public void replyEntry(Entry conn)
                throws Exception
Send an LDAP result message in response to the last request from the LDAP Client. The attributes used in the result packet are: ldap.status to set the status code, ldap.errormessage to provide additional info in case ldap.status is not zero, ldap.matcheddn to tell the client about the offending DN if any and finally ldap.referrals to refer the client to another LDAP server. The default value for all attributes is NULL and ZERO (e.g. OK) for the ldap.status attribute. You generally only have to set attribute values in case there is an error or you want to refer to another server.

Specified by:
replyEntry in interface ConnectorInterface
Overrides:
replyEntry in class Connector
Parameters:
conn - the entry, result of the Output Mapping
Throws:
Exception - if an error occurs.

isAbandoned

public boolean isAbandoned(int messageID)
                    throws Exception
This method returns true if there is an abandon message in the queue with the specified message ID.

Parameters:
messageID - The LDAP Message ID
Returns:
true if there is an abandoned message with the provided id, false otherwise.
Throws:
Exception - if an error occurs.

createControl

public LDAPControl createControl(String oid)
Creates an instance of the LDAPControl class.

Parameters:
oid - the extended operation id
Returns:
the newly created object.

getVersion

public String getVersion()
Version information.

Specified by:
getVersion in interface VersionInfoInterface
Returns:
the version information