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.StringPARAM_SYSTEM_TCP_BACKLOGConfiguration parameter name: "com.ibm.di.tcp.backlog"static java.lang.StringPARAM_TCP_BACKLOGConfiguration 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 LDAPControlcreateControl(java.lang.String oid)Creates an instance of theLDAPControlclass.ConnectorInterfacegetNextClient()Server mode - returns a new instance of the connector with a client connection.EntrygetNextEntry()Returns the next Entry from the LDAP client.static ResourceHashgetResHash()LDAPServerConnectorgetServerConnector()Retrieves server connector.java.lang.StringgetVersion()Version information.voidinitialize(java.lang.Object obj)Initialize the connector.booleanisAbandoned(int messageID)This method returns true if there is an abandon message in the queue with the specified message ID.booleanisAccepting()Checks if the connector is waiting for a client connection.booleanisTerminating()Checks if a termination request is sent.voidputEntry(Entry entry)Sends a search result entry to the LDAP client in response to a search request.voidreplyEntry(Entry conn)Send an LDAP result message in response to the last request from the LDAP Client.voidsetKeepAlive(boolean value)voidsetServerConnector(LDAPServerConnector serverConnector)Sets the server connector for this connector.voidterminate()Terminate the connector.voidterminateServer()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.ExceptionThis 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:
terminateServerin interfaceConnectorInterface- Overrides:
terminateServerin classConnector- Throws:
java.lang.Exception- if an error occurs.
-
initialize
public void initialize(java.lang.Object obj) throws java.lang.ExceptionInitialize 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:
initializein interfaceConnectorInterface- Overrides:
initializein classConnector- Parameters:
obj- Null, Socket or ConnectorMode class- Throws:
java.lang.Exception- if an error occurs.
-
terminate
public void terminate() throws java.lang.ExceptionTerminate 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:
terminatein interfaceConnectorInterface- Overrides:
terminatein 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:
getNextClientin interfaceConnectorInterface- Overrides:
getNextClientin 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:
getNextEntryin interfaceConnectorInterface- Overrides:
getNextEntryin 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:
putEntryin interfaceConnectorInterface- Overrides:
putEntryin 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:
replyEntryin interfaceConnectorInterface- Overrides:
replyEntryin 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.ExceptionThis 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 theLDAPControlclass.- Parameters:
oid- the extended operation id- Returns:
- the newly created object.
-
getVersion
public java.lang.String getVersion()
Version information.- Specified by:
getVersionin interfaceVersionInfoInterface- Returns:
- the version information
-
setKeepAlive
public void setKeepAlive(boolean value)
-
-