org.opends.server.protocols.ldap
Class LDAPConnectionHandler

java.lang.Object
  extended by java.lang.Thread
      extended by org.opends.server.api.DirectoryThread
          extended by org.opends.server.api.ConnectionHandler<LDAPConnectionHandlerCfg>
              extended by org.opends.server.protocols.ldap.LDAPConnectionHandler
All Implemented Interfaces:
java.lang.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 java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LDAPConnectionHandler()
          Creates a new instance of this LDAP connection handler.
 
Method Summary
 boolean allowLDAPv2()
          Indicates whether this connection handler should allow interaction with LDAPv2 clients.
 boolean allowStartTLS()
          Indicates whether this connection handler should allow the use of the StartTLS extended operation.
 ConfigChangeResult applyConfigurationChange(LDAPConnectionHandlerCfg config)
          Applies the configuration changes to this change listener.
 void finalizeConnectionHandler(Message finalizeReason, boolean closeConnections)
          Closes this connection handler so that it will no longer accept new client connections.
 java.util.LinkedHashMap<java.lang.String,java.lang.String> getAlerts()
          Retrieves information about the set of alerts that this generator may produce.
 java.lang.String getClassName()
          Retrieves the fully-qualified name of the Java class for this alert generator implementation.
 java.util.Collection<ClientConnection> getClientConnections()
          Retrieves the set of active client connections that have been established through this connection handler.
 DN getComponentEntryDN()
          Retrieves the DN of the configuration entry with which this alert generator is associated.
 java.lang.String getConnectionHandlerName()
          Retrieves a name that may be used to refer to this connection handler.
 java.lang.String[] getEnabledSSLCipherSuites()
          Retrieves the set of enabled SSL cipher suites configured for this connection handler.
 java.lang.String[] getEnabledSSLProtocols()
          Retrieves the set of enabled SSL protocols configured for this connection handler.
 DN getKeyManagerProviderDN()
          Retrieves the DN of the key manager provider that should be used for operations associated with this connection handler which need access to a key manager.
 java.util.Collection<HostPort> getListeners()
          Retrieves information about the listener(s) that will be used to accept client connections.
 int getListenPort()
          Retrieves the port on which this connection handler is listening for client connections.
 long getMaxBlockedWriteTimeLimit()
          Retrieves the maximum length of time in milliseconds that attempts to write to LDAP client connections should be allowed to block.
 int getMaxRequestSize()
          Retrieves the maximum ASN.1 element value length that will be allowed by this connection handler.
 java.lang.String getProtocol()
          Retrieves the name of the protocol used to communicate with clients.
 java.lang.String getShutdownListenerName()
          Retrieves the human-readable name for this shutdown listener.
 SSLClientAuthPolicy getSSLClientAuthPolicy()
          Retrieves the SSL client authentication policy for this connection handler.
 java.lang.String getSSLServerCertNickname()
          Retrieves the nickname of the server certificate that should be used in conjunction with this LDAP connection handler.
 LDAPStatistics getStatTracker()
          Retrieves the set of statistics maintained by this connection handler.
 DN getTrustManagerProviderDN()
          Retrieves the DN of the trust manager provider that should be used for operations associated with this connection handler which need access to a trust manager.
 void initializeConnectionHandler(LDAPConnectionHandlerCfg config)
          Initializes this connection handler provider based on the information in the provided connection handler configuration.
 boolean isConfigurationAcceptable(ConnectionHandlerCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the provided configuration is acceptable for this connection handler.
 boolean isConfigurationChangeAcceptable(LDAPConnectionHandlerCfg config, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed change to the configuration is acceptable to this change listener.
 boolean keepStats()
          Indicates whether this connection handler should maintain usage statistics.
 void processServerShutdown(Message 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.
 void run()
          Operates in a loop, accepting new connections and ensuring that requests on those connections are handled properly.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this connection handler to the provided buffer.
 boolean useSSL()
          Indicates whether this connection handler should use SSL to communicate with clients.
 
Methods inherited from class org.opends.server.api.ConnectionHandler
getConnectionHandlerMonitor, setConnectionHandlerMonitor, toString
 
Methods inherited from class org.opends.server.api.DirectoryThread
getAssociatedTask, getCreationStackTrace, getDebugProperties, getParentThread, setAssociatedTask
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LDAPConnectionHandler

public LDAPConnectionHandler()
Creates a new instance of this LDAP connection handler. It must be initialized before it may be used.

Method Detail

allowLDAPv2

public boolean allowLDAPv2()
Indicates whether this connection handler should allow interaction with LDAPv2 clients.

Returns:
true if LDAPv2 is allowed, or false if not.

allowStartTLS

public boolean allowStartTLS()
Indicates whether this connection handler should allow the use of the StartTLS extended operation.

Returns:
true if StartTLS is allowed, or false if not.

applyConfigurationChange

public ConfigChangeResult applyConfigurationChange(LDAPConnectionHandlerCfg config)
Applies the configuration changes to this change listener.

Specified by:
applyConfigurationChange in interface ConfigurationChangeListener<LDAPConnectionHandlerCfg>
Parameters:
config - The new configuration containing the changes.
Returns:
Returns information about the result of changing the configuration.

finalizeConnectionHandler

public void finalizeConnectionHandler(Message finalizeReason,
                                      boolean closeConnections)
Closes this connection handler so that it will no longer accept new client connections. It may or may not disconnect existing client connections based on the provided flag. Note, however, that some connection handler implementations may not have any way to continue processing requests from existing connections, in which case they should always be closed regardless of the value of the closeConnections flag.

Specified by:
finalizeConnectionHandler in class ConnectionHandler<LDAPConnectionHandlerCfg>
Parameters:
finalizeReason - The reason that this connection handler should be finalized.
closeConnections - Indicates whether any established client connections associated with the connection handler should also be closed.

getAlerts

public java.util.LinkedHashMap<java.lang.String,java.lang.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:
getAlerts in interface AlertGenerator
Returns:
Information about the set of alerts that this generator may produce.

getClassName

public java.lang.String getClassName()
Retrieves the fully-qualified name of the Java class for this alert generator implementation.

Specified by:
getClassName in interface AlertGenerator
Returns:
The fully-qualified name of the Java class for this alert generator implementation.

getClientConnections

public java.util.Collection<ClientConnection> getClientConnections()
Retrieves the set of active client connections that have been established through this connection handler.

Specified by:
getClientConnections in class ConnectionHandler<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:
getComponentEntryDN in interface AlertGenerator
Returns:
The DN of the configuration entry with which this alert generator is associated.

getConnectionHandlerName

public java.lang.String getConnectionHandlerName()
Retrieves 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:
getConnectionHandlerName in class ConnectionHandler<LDAPConnectionHandlerCfg>
Returns:
A unique name that may be used to refer to this connection handler.

getEnabledSSLCipherSuites

public java.lang.String[] getEnabledSSLCipherSuites()
Retrieves the set of enabled SSL cipher suites configured for this connection handler.

Returns:
The set of enabled SSL cipher suites configured for this connection handler.

getEnabledSSLProtocols

public java.lang.String[] getEnabledSSLProtocols()
Retrieves the set of enabled SSL protocols configured for this connection handler.

Returns:
The set of enabled SSL protocols configured for this connection handler.

getKeyManagerProviderDN

public DN getKeyManagerProviderDN()
Retrieves the DN of the key manager provider that should be used for operations associated with this connection handler which need access to a key manager.

Returns:
The DN of the key manager provider that should be used for operations associated with this connection handler which need access to a key manager, or null if no key manager provider has been configured for this connection handler.

getListeners

public java.util.Collection<HostPort> getListeners()
Retrieves information about the listener(s) that will be used to accept client connections.

Specified by:
getListeners in class ConnectionHandler<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.

getProtocol

public java.lang.String getProtocol()
Retrieves 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:
getProtocol in class ConnectionHandler<LDAPConnectionHandlerCfg>
Returns:
The name of the protocol used to communicate with clients.

getShutdownListenerName

public java.lang.String getShutdownListenerName()
Retrieves the human-readable name for this shutdown listener.

Specified by:
getShutdownListenerName in interface ServerShutdownListener
Returns:
The human-readable name for this shutdown listener.

getSSLServerCertNickname

public java.lang.String getSSLServerCertNickname()
Retrieves the nickname of the server certificate that should be used in conjunction with this LDAP connection handler.

Returns:
The nickname of the server certificate that should be used in conjunction with this LDAP connection handler.

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.

getTrustManagerProviderDN

public DN getTrustManagerProviderDN()
Retrieves the DN of the trust manager provider that should be used for operations associated with this connection handler which need access to a trust manager.

Returns:
The DN of the trust manager provider that should be used for operations associated with this connection handler which need access to a trust manager, or null if no trust manager provider has been configured for this connection handler.

initializeConnectionHandler

public void initializeConnectionHandler(LDAPConnectionHandlerCfg config)
                                 throws ConfigException,
                                        InitializationException
Initializes this connection handler provider based on the information in the provided connection handler configuration.

Specified by:
initializeConnectionHandler in class ConnectionHandler<LDAPConnectionHandlerCfg>
Parameters:
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,
                                         java.util.List<Message> unacceptableReasons)
Indicates 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:
isConfigurationAcceptable in class ConnectionHandler<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:
true if the provided configuration is acceptable for this connection handler, or false if not.

isConfigurationChangeAcceptable

public boolean isConfigurationChangeAcceptable(LDAPConnectionHandlerCfg config,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.

Specified by:
isConfigurationChangeAcceptable in interface ConfigurationChangeListener<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 true if the proposed change is acceptable, or false if it is not.

keepStats

public boolean keepStats()
Indicates whether this connection handler should maintain usage statistics.

Returns:
true if this connection handler should maintain usage statistics, or false if not.

processServerShutdown

public void processServerShutdown(Message 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.

Specified by:
processServerShutdown in interface ServerShutdownListener
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:
run in interface java.lang.Runnable
Specified by:
run in class ConnectionHandler<LDAPConnectionHandlerCfg>

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this connection handler to the provided buffer.

Specified by:
toString in class ConnectionHandler<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:
true if this connection handler should use SSL to communicate with clients, or false if not.