Package com.ibm.di.connector
Class LDAPServerConnector
- java.lang.Object
-
- com.ibm.di.connector.Connector
-
- 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
Fields Modifier and Type Field Description static java.lang.String
PARAM_SYSTEM_TCP_BACKLOG
Configuration parameter name: "com.ibm.di.tcp.backlog"static java.lang.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
Constructors Constructor Description LDAPServerConnector()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LDAPControl
createControl(java.lang.String oid)
Creates an instance of theLDAPControl
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.java.lang.String
getVersion()
Version information.void
initialize(java.lang.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
setKeepAlive(boolean value)
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, extractExceptionInformation, 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 java.lang.String PARAM_TCP_BACKLOG
Configuration parameter name: "backlog"- See Also:
- Constant Field Values
-
PARAM_SYSTEM_TCP_BACKLOG
public static final java.lang.String PARAM_SYSTEM_TCP_BACKLOG
Configuration parameter name: "com.ibm.di.tcp.backlog"- See Also:
- Constant Field Values
-
-
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 java.lang.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 interfaceConnectorInterface
- Overrides:
terminateServer
in classConnector
- Throws:
java.lang.Exception
- if an error occurs.
-
initialize
public void initialize(java.lang.Object obj) throws java.lang.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 interfaceConnectorInterface
- Overrides:
initialize
in classConnector
- Parameters:
obj
- Null, Socket or ConnectorMode class- Throws:
java.lang.Exception
- if an error occurs.
-
terminate
public void terminate() throws java.lang.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 interfaceConnectorInterface
- Overrides:
terminate
in classConnector
- Throws:
java.lang.Exception
- if an error occurs.
-
getNextClient
public ConnectorInterface getNextClient() throws java.lang.Exception
Server mode - returns a new instance of the connector with a client connection. The new connector mapgetNextEntry()
to get requests from the client,putEntry(Entry)
to send a search result to the client, and finallyreplyEntry(Entry)
to send the LDAP result message.- Specified by:
getNextClient
in interfaceConnectorInterface
- Overrides:
getNextClient
in classConnector
- Returns:
- an instance of this connector, that handles client sessions.
- Throws:
java.lang.Exception
- if an error occurs.
-
getNextEntry
public Entry getNextEntry() throws java.lang.Exception
Returns the next Entry from the LDAP client.- Specified by:
getNextEntry
in interfaceConnectorInterface
- Overrides:
getNextEntry
in classConnector
- Returns:
- - the next Entry, or null if client connection has been closed.
- Throws:
java.lang.Exception
- if an error occurs.- See Also:
Connector.selectEntries()
-
putEntry
public void putEntry(Entry entry) throws java.lang.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 interfaceConnectorInterface
- Overrides:
putEntry
in classConnector
- Parameters:
entry
- The entry. It must contain the $dn attribute plus other LDAP attributes.- Throws:
java.lang.Exception
- if an error occurs.
-
replyEntry
public void replyEntry(Entry conn) throws java.lang.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 interfaceConnectorInterface
- Overrides:
replyEntry
in classConnector
- Parameters:
conn
- the entry, result of the Output Mapping- Throws:
java.lang.Exception
- if an error occurs.
-
isAbandoned
public boolean isAbandoned(int messageID) throws java.lang.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:
java.lang.Exception
- if an error occurs.
-
createControl
public LDAPControl createControl(java.lang.String oid)
Creates an instance of theLDAPControl
class.- Parameters:
oid
- the extended operation id- Returns:
- the newly created object.
-
getVersion
public java.lang.String getVersion()
Version information.- Specified by:
getVersion
in interfaceVersionInfoInterface
- Returns:
- the version information
-
setKeepAlive
public void setKeepAlive(boolean value)
-
-