Package org.opends.server.protocols.ldap
Class LDAPConnectionHandler
- java.lang.Object
-
- java.lang.Thread
-
- org.opends.server.api.DirectoryThread
-
- org.opends.server.api.ConnectionHandler<LDAPConnectionHandlerCfg>
-
- org.opends.server.protocols.ldap.LDAPConnectionHandler
-
- All Implemented Interfaces:
Runnable,ConfigurationChangeListener<LDAPConnectionHandlerCfg>,AlertGenerator,ServerShutdownListener
public final class LDAPConnectionHandler extends ConnectionHandler<LDAPConnectionHandlerCfg> implements ConfigurationChangeListener<LDAPConnectionHandlerCfg>, ServerShutdownListener, AlertGenerator
This class defines a connection handler that will be used for communicating with clients over LDAP. It is actually implemented in two parts: as a connection handler and one or more request handlers. The connection handler is responsible for accepting new connections and registering each of them with a request handler. The request handlers then are responsible for reading requests from the clients and parsing them as operations. A single request handler may be used, but having multiple handlers might provide better performance in a multi-CPU system.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opends.server.api.DirectoryThread
DirectoryThread.Factory
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
-
Fields inherited from class org.opends.server.api.ConnectionHandler
LISTEN_TIMEOUT_MS
-
Fields inherited from class org.opends.server.api.DirectoryThread
DIRECTORY_THREAD_GROUP
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description LDAPConnectionHandler()Creates a new instance of this LDAP connection handler.LDAPConnectionHandler(QueueingStrategy strategy, String friendlyName)Creates a new instance of this LDAP connection handler, using a queueing strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowLDAPv2()Indicates whether this connection handler should allow interaction with LDAPv2 clients.booleanallowStartTLS()Indicates whether this connection handler should allow the use of the StartTLS extended operation.ConfigChangeResultapplyConfigurationChange(LDAPConnectionHandlerCfg config)Applies the configuration changes to this change listener.voidfinalizeConnectionHandler(org.forgerock.i18n.LocalizableMessage finalizeReason)Closes this connection handler so that it will no longer accept new client connections.Map<String,String>getAlerts()Retrieves information about the set of alerts that this generator may produce.intgetBufferSize()Retrieves the size in bytes of the LDAP response message write buffer defined for this connection handler.StringgetClassName()Retrieves the fully-qualified name of the Java class for this alert generator implementation.Collection<ClientConnection>getClientConnections()Retrieves the set of active client connections that have been established through this connection handler.DNgetComponentEntryDN()Retrieves the DN of the configuration entry with which this alert generator is associated.StringgetConnectionHandlerName()Retrieves a name that may be used to refer to this connection handler.Collection<String>getEnabledSSLCipherSuites()Retrieves an unmodifiable set of enabled SSL cipher suites configured for this connection handler, if applicable.Collection<String>getEnabledSSLProtocols()Retrieves the set of enabled SSL protocols configured for this connection handler.Collection<HostPort>getListeners()Retrieves information about the listener(s) that will be used to accept client connections.intgetListenPort()Retrieves the port on which this connection handler is listening for client connections.longgetMaxBlockedWriteTimeLimit()Retrieves the maximum length of time in milliseconds that attempts to write to LDAP client connections should be allowed to block.intgetMaxRequestSize()Retrieves the maximum ASN.1 element value length that will be allowed by this connection handler.StringgetProtocol()Retrieves the name of the protocol used to communicate with clients.QueueingStrategygetQueueingStrategy()Get the queueing strategy.StringgetShutdownListenerName()Retrieves the human-readable name for this shutdown listener.SSLClientAuthPolicygetSSLClientAuthPolicy()Retrieves the SSL client authentication policy for this connection handler.LDAPStatisticsgetStatTracker()Retrieves the set of statistics maintained by this connection handler.TLSByteChannelgetTLSByteChannel(ByteChannel channel)Creates a TLS Byte Channel instance using the specified socket channel.voidinitializeConnectionHandler(ServerContext serverContext, LDAPConnectionHandlerCfg config)Initializes this connection handler provider based on the information in the provided connection handler configuration.booleanisConfigurationAcceptable(ConnectionHandlerCfg configuration, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)Indicates whether the provided configuration is acceptable for this connection handler.booleanisConfigurationChangeAcceptable(LDAPConnectionHandlerCfg config, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)Indicates whether the proposed change to the configuration is acceptable to this change listener.booleankeepStats()Indicates whether this connection handler should maintain usage statistics.voidprocessServerShutdown(org.forgerock.i18n.LocalizableMessage reason)Indicates that the Directory Server has received a request to stop running and that this shutdown listener should take any action necessary to prepare for it.voidrun()Operates in a loop, accepting new connections and ensuring that requests on those connections are handled properly.voidstart()voidtoString(StringBuilder buffer)Appends a string representation of this connection handler to the provided buffer.booleanuseSSL()Indicates whether this connection handler should use SSL to communicate with clients.-
Methods inherited from class org.opends.server.api.ConnectionHandler
getConnectionHandlerMonitor, getNumRequestHandlers, isAdminConnectionHandler, setAdminConnectionHandler, setConnectionHandlerMonitor, toString
-
Methods inherited from class org.opends.server.api.DirectoryThread
getAssociatedTask, getCreationStackTrace, getDebugProperties, getParentThread, initiateShutdown, isShutdownInitiated, setAssociatedTask, startWork, stopWork
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, suspend, yield
-
-
-
-
Constructor Detail
-
LDAPConnectionHandler
public LDAPConnectionHandler()
Creates a new instance of this LDAP connection handler. It must be initialized before it may be used.
-
LDAPConnectionHandler
public LDAPConnectionHandler(QueueingStrategy strategy, String friendlyName)
Creates a new instance of this LDAP connection handler, using a queueing strategy. It must be initialized before it may be used.- Parameters:
strategy- Request handling strategy.friendlyName- The name of of this connection handler, ornullif the name should be taken from the configuration.
-
-
Method Detail
-
allowLDAPv2
public boolean allowLDAPv2()
Indicates whether this connection handler should allow interaction with LDAPv2 clients.- Returns:
trueif LDAPv2 is allowed, orfalseif not.
-
allowStartTLS
public boolean allowStartTLS()
Indicates whether this connection handler should allow the use of the StartTLS extended operation.- Returns:
trueif StartTLS is allowed, orfalseif not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(LDAPConnectionHandlerCfg config)
Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein interfaceConfigurationChangeListener<LDAPConnectionHandlerCfg>- Parameters:
config- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
finalizeConnectionHandler
public void finalizeConnectionHandler(org.forgerock.i18n.LocalizableMessage finalizeReason)
Description copied from class:ConnectionHandlerCloses this connection handler so that it will no longer accept new client connections. Implementations should disconnect any existing connections.- Specified by:
finalizeConnectionHandlerin classConnectionHandler<LDAPConnectionHandlerCfg>- Parameters:
finalizeReason- The reason that this connection handler should be finalized.
-
getAlerts
public Map<String,String> getAlerts()
Retrieves information about the set of alerts that this generator may produce. The map returned should be between the notification type for a particular notification and the human-readable description for that notification. This alert generator must not generate any alerts with types that are not contained in this list.- Specified by:
getAlertsin interfaceAlertGenerator- Returns:
- Information about the set of alerts that this generator may produce.
-
getClassName
public String getClassName()
Retrieves the fully-qualified name of the Java class for this alert generator implementation.- Specified by:
getClassNamein interfaceAlertGenerator- Returns:
- The fully-qualified name of the Java class for this alert generator implementation.
-
getClientConnections
public Collection<ClientConnection> getClientConnections()
Retrieves the set of active client connections that have been established through this connection handler.- Specified by:
getClientConnectionsin classConnectionHandler<LDAPConnectionHandlerCfg>- Returns:
- The set of active client connections that have been established through this connection handler.
-
getComponentEntryDN
public DN getComponentEntryDN()
Retrieves the DN of the configuration entry with which this alert generator is associated.- Specified by:
getComponentEntryDNin interfaceAlertGenerator- Specified by:
getComponentEntryDNin classConnectionHandler<LDAPConnectionHandlerCfg>- Returns:
- The DN of the configuration entry with which this alert generator is associated.
-
getConnectionHandlerName
public String getConnectionHandlerName()
Description copied from class:ConnectionHandlerRetrieves a name that may be used to refer to this connection handler. Every connection handler instance (even handlers of the same type) must have a unique name.- Specified by:
getConnectionHandlerNamein classConnectionHandler<LDAPConnectionHandlerCfg>- Returns:
- A unique name that may be used to refer to this connection handler.
-
getEnabledSSLCipherSuites
public Collection<String> getEnabledSSLCipherSuites()
Description copied from class:ConnectionHandlerRetrieves an unmodifiable set of enabled SSL cipher suites configured for this connection handler, if applicable. Implementations must return an empty set if use of SSL/TLS is not possible.- Overrides:
getEnabledSSLCipherSuitesin classConnectionHandler<LDAPConnectionHandlerCfg>- Returns:
- The set of enabled SSL cipher suites configured for this connection handler.
-
getEnabledSSLProtocols
public Collection<String> getEnabledSSLProtocols()
Description copied from class:ConnectionHandlerRetrieves the set of enabled SSL protocols configured for this connection handler. Implementations must return an empty set if use of SSL/TLS is not possible.- Overrides:
getEnabledSSLProtocolsin classConnectionHandler<LDAPConnectionHandlerCfg>- Returns:
- The set of enabled SSL protocols configured for this connection handler.
-
getListeners
public Collection<HostPort> getListeners()
Description copied from class:ConnectionHandlerRetrieves information about the listener(s) that will be used to accept client connections.- Specified by:
getListenersin classConnectionHandler<LDAPConnectionHandlerCfg>- Returns:
- Information about the listener(s) that will be used to accept client connections, or an empty list if this connection handler does not accept connections from network clients.
-
getListenPort
public int getListenPort()
Retrieves the port on which this connection handler is listening for client connections.- Returns:
- The port on which this connection handler is listening for client connections.
-
getMaxBlockedWriteTimeLimit
public long getMaxBlockedWriteTimeLimit()
Retrieves the maximum length of time in milliseconds that attempts to write to LDAP client connections should be allowed to block.- Returns:
- The maximum length of time in milliseconds that attempts to write to LDAP client connections should be allowed to block, or zero if there should not be any limit imposed.
-
getMaxRequestSize
public int getMaxRequestSize()
Retrieves the maximum ASN.1 element value length that will be allowed by this connection handler.- Returns:
- The maximum ASN.1 element value length that will be allowed by this connection handler.
-
getBufferSize
public int getBufferSize()
Retrieves the size in bytes of the LDAP response message write buffer defined for this connection handler.- Returns:
- The size in bytes of the LDAP response message write buffer.
-
getProtocol
public String getProtocol()
Description copied from class:ConnectionHandlerRetrieves the name of the protocol used to communicate with clients. It should take into account any special naming that may be needed to express any security mechanisms or other constraints in place (e.g., "LDAPS" for LDAP over SSL).- Specified by:
getProtocolin classConnectionHandler<LDAPConnectionHandlerCfg>- Returns:
- The name of the protocol used to communicate with clients.
-
getShutdownListenerName
public String getShutdownListenerName()
Description copied from interface:ServerShutdownListenerRetrieves the human-readable name for this shutdown listener.- Specified by:
getShutdownListenerNamein interfaceServerShutdownListener- Returns:
- The human-readable name for this shutdown listener.
-
getSSLClientAuthPolicy
public SSLClientAuthPolicy getSSLClientAuthPolicy()
Retrieves the SSL client authentication policy for this connection handler.- Returns:
- The SSL client authentication policy for this connection handler.
-
getStatTracker
public LDAPStatistics getStatTracker()
Retrieves the set of statistics maintained by this connection handler.- Returns:
- The set of statistics maintained by this connection handler.
-
initializeConnectionHandler
public void initializeConnectionHandler(ServerContext serverContext, LDAPConnectionHandlerCfg config) throws ConfigException, InitializationException
Description copied from class:ConnectionHandlerInitializes this connection handler provider based on the information in the provided connection handler configuration.- Specified by:
initializeConnectionHandlerin classConnectionHandler<LDAPConnectionHandlerCfg>- Parameters:
serverContext- The server context.config- The connection handler configuration that contains the information to use to initialize this connection handler.- Throws:
ConfigException- If an unrecoverable problem arises in the process of performing the initialization as a result of the server configuration.InitializationException- If a problem occurs during initialization that is not related to the server configuration.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(ConnectionHandlerCfg configuration, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)
Description copied from class:ConnectionHandlerIndicates whether the provided configuration is acceptable for this connection handler. It should be possible to call this method on an uninitialized connection handler instance in order to determine whether the connection handler would be able to use the provided configuration.
Note that implementations which use a subclass of the provided configuration class will likely need to cast the configuration to the appropriate subclass type.- Overrides:
isConfigurationAcceptablein classConnectionHandler<LDAPConnectionHandlerCfg>- Parameters:
configuration- The connection handler configuration for which to make the determination.unacceptableReasons- A list that may be used to hold the reasons that the provided configuration is not acceptable.- Returns:
trueif the provided configuration is acceptable for this connection handler, orfalseif not.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(LDAPConnectionHandlerCfg config, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)
Description copied from interface:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein interfaceConfigurationChangeListener<LDAPConnectionHandlerCfg>- Parameters:
config- The new configuration containing the changes.unacceptableReasons- A list that can be used to hold messages about why the provided configuration is not acceptable.- Returns:
- Returns
trueif the proposed change is acceptable, orfalseif it is not.
-
keepStats
public boolean keepStats()
Indicates whether this connection handler should maintain usage statistics.- Returns:
trueif this connection handler should maintain usage statistics, orfalseif not.
-
processServerShutdown
public void processServerShutdown(org.forgerock.i18n.LocalizableMessage reason)
Description copied from interface:ServerShutdownListenerIndicates that the Directory Server has received a request to stop running and that this shutdown listener should take any action necessary to prepare for it.- Specified by:
processServerShutdownin interfaceServerShutdownListener- Parameters:
reason- The human-readable reason for the shutdown.
-
run
public void run()
Operates in a loop, accepting new connections and ensuring that requests on those connections are handled properly.- Specified by:
runin interfaceRunnable- Specified by:
runin classConnectionHandler<LDAPConnectionHandlerCfg>
-
toString
public void toString(StringBuilder buffer)
Appends a string representation of this connection handler to the provided buffer.- Specified by:
toStringin classConnectionHandler<LDAPConnectionHandlerCfg>- Parameters:
buffer- The buffer to which the information should be appended.
-
useSSL
public boolean useSSL()
Indicates whether this connection handler should use SSL to communicate with clients.- Returns:
trueif this connection handler should use SSL to communicate with clients, orfalseif not.
-
getQueueingStrategy
public QueueingStrategy getQueueingStrategy()
Get the queueing strategy.- Returns:
- The queueing strategy.
-
getTLSByteChannel
public TLSByteChannel getTLSByteChannel(ByteChannel channel) throws DirectoryException
Creates a TLS Byte Channel instance using the specified socket channel.- Parameters:
channel- The socket channel to use in the creation.- Returns:
- A TLS Byte Channel instance.
- Throws:
DirectoryException- If the channel cannot be created.
-
-