| | |
| | | public final class LDAPClientConnection extends ClientConnection implements |
| | | TLSCapableConnection |
| | | { |
| | | |
| | | /** |
| | | * A runnable whose task is to close down all IO related channels |
| | | * associated with a client connection after a small delay. |
| | |
| | | this.socketChannel = socketChannel; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | |
| | | clientChannel.close(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public int write(ByteBuffer byteBuffer) throws IOException |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** The tracer object for the debug logger. */ |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * Thread local ASN1Writer and buffer. |
| | | */ |
| | | /** Thread local ASN1Writer and buffer. */ |
| | | private static final class ASN1WriterHolder implements Closeable |
| | | { |
| | | private final ASN1Writer writer; |
| | |
| | | this.writer = ASN1.getWriter(buffer, maxBufferSize); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Cached ASN1 writer: a thread can only write to one connection at a time. |
| | | */ |
| | | /** Cached ASN1 writer: a thread can only write to one connection at a time. */ |
| | | private static final ThreadLocal<ASN1WriterHolder> ASN1_WRITER_CACHE = |
| | | new ThreadLocal<ASN1WriterHolder>() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected ASN1WriterHolder initialValue() |
| | | { |
| | |
| | | |
| | | /** The time that the last operation was completed. */ |
| | | private final AtomicLong lastCompletionTime; |
| | | |
| | | /** The next operation ID that should be used for this connection. */ |
| | | private final AtomicLong nextOperationID; |
| | | |
| | | /** The selector that may be used for write operations. */ |
| | | private final AtomicReference<Selector> writeSelector; |
| | | |
| | |
| | | |
| | | /** The port on the client from which this connection originated. */ |
| | | private final int clientPort; |
| | | |
| | | /** |
| | | * The LDAP version that the client is using to communicate with the server. |
| | | */ |
| | | /** The LDAP version that the client is using to communicate with the server. */ |
| | | private int ldapVersion; |
| | | |
| | | /** The port on the server to which this client has connected. */ |
| | | private final int serverPort; |
| | | |
| | | /** The reference to the connection handler that accepted this connection. */ |
| | | private final LDAPConnectionHandler connectionHandler; |
| | | |
| | | /** The statistics tracker associated with this client connection. */ |
| | | private final LDAPStatistics statTracker; |
| | | private boolean useNanoTime; |
| | | |
| | | |
| | | /** The connection ID assigned to this connection. */ |
| | | private final long connectionID; |
| | | |
| | | /** |
| | | * The lock used to provide threadsafe access to the set of operations in |
| | | * progress. |
| | | */ |
| | | /** The lock used to provide threadsafe access to the set of operations in progress. */ |
| | | private final Object opsInProgressLock; |
| | | |
| | | /** The socket channel with which this client connection is associated. */ |
| | | private final SocketChannel clientChannel; |
| | | |
| | | /** The byte channel used for blocking writes with time out. */ |
| | | private final ByteChannel timeoutClientChannel; |
| | | |
| | | /** The string representation of the address of the client. */ |
| | | private final String clientAddress; |
| | | |
| | | /** |
| | | * The name of the protocol that the client is using to communicate with the |
| | | * server. |
| | | */ |
| | | /** The name of the protocol that the client is using to communicate with the server. */ |
| | | private final String protocol; |
| | | |
| | | /** |
| | | * The string representation of the address of the server to which the client |
| | | * has connected. |
| | | */ |
| | | /** The string representation of the address of the server to which the client has connected. */ |
| | | private final String serverAddress; |
| | | |
| | | |
| | | |
| | | private ASN1ByteChannelReader asn1Reader; |
| | | private final int bufferSize; |
| | | private final RedirectingByteChannel saslChannel; |
| | |
| | | private volatile ConnectionSecurityProvider saslPendingProvider; |
| | | private volatile ConnectionSecurityProvider tlsPendingProvider; |
| | | |
| | | |
| | | /** |
| | | * Creates a new LDAP client connection with the provided information. |
| | | * |
| | |
| | | return connectionID; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the connection handler that accepted this client |
| | | * connection. |
| | |
| | | return connectionHandler; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the socket channel that can be used to communicate with |
| | | * the client. |
| | |
| | | return clientChannel; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the protocol that the client is using to communicate with |
| | | * the Directory Server. |
| | |
| | | return protocol; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a string representation of the address of the client. |
| | | * |
| | |
| | | return clientAddress; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the port number for this connection on the client system. |
| | | * |
| | |
| | | return clientPort; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a string representation of the address on the server to |
| | | * which the client connected. |
| | |
| | | return serverAddress; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the port number for this connection on the server system. |
| | | * |
| | |
| | | return serverPort; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the <CODE>java.net.InetAddress</CODE> associated with the |
| | | * remote client system. |
| | |
| | | return clientChannel.socket().getInetAddress(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the <CODE>java.net.InetAddress</CODE> for the Directory |
| | | * Server system to which the client has established the connection. |
| | |
| | | return clientChannel.socket().getLocalAddress(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConnectionValid() |
| | | { |
| | |
| | | return secure; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sends a response to the client based on the information in the |
| | | * provided operation. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves an LDAPMessage containing a response generated from the |
| | | * provided operation. |
| | |
| | | controls); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sends the provided search result entry to the client. |
| | | * |
| | |
| | | protocolOp, searchEntry.getControls())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sends the provided search result reference to the client. |
| | | * |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sends the provided intermediate response message to the client. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sends the provided LDAP message to the client. |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Closes the connection to the client, optionally sending it a |
| | | * message indicating the reason for the closure. Note that the |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of operations in progress for this client |
| | | * connection. This list must not be altered by any caller. |
| | |
| | | return operationsInProgress.values(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the operation in progress with the specified message ID. |
| | | * |
| | |
| | | return operationsInProgress.get(messageID); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Adds the provided operation to the set of operations in progress |
| | | * for this client connection. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Removes the provided operation from the set of operations in |
| | | * progress for this client connection. Note that this does not make |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Attempts to cancel the specified operation. |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Attempts to cancel all operations in progress on this connection. |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Attempts to cancel all operations in progress on this connection |
| | | * except the operation with the specified message ID. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Selector getWriteSelector() |
| | | { |
| | |
| | | return selector; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getMaxBlockedWriteTimeLimit() |
| | | { |
| | | return connectionHandler.getMaxBlockedWriteTimeLimit(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the total number of operations initiated on this |
| | | * connection. |
| | |
| | | return operationsPerformed.get(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the ASN1 reader for this connection. |
| | | * |
| | |
| | | return asn1Reader; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Process data read. |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message read from the client and takes |
| | | * whatever action is appropriate. For most requests, this will |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as an abandon request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as an add request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as a bind request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as a compare request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as a delete request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as an extended request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as a modify request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as a modify DN request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as a search request. |
| | | * |
| | |
| | | return connectionValid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes the provided LDAP message as an unbind request. |
| | | * |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMonitorSummary() |
| | | { |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this client connection to the |
| | | * provided buffer. |
| | |
| | | buffer.append(serverPort); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean prepareTLS(LocalizableMessageBuilder unavailableReason) |
| | | { |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the length of time in milliseconds that this client |
| | | * connection has been idle. <BR> |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Set the connection provider that is not in use yet. Used in TLS |
| | | * negotiation when a clear response is needed before the connection |
| | |
| | | tlsPendingProvider = provider; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Set the connection provider that is not in use. Used in SASL |
| | | * negotiation when a clear response is needed before the connection |
| | |
| | | saslPendingProvider = provider; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Enable the provider that is inactive. |
| | | */ |
| | | /** Enable the provider that is inactive. */ |
| | | private void enableTLS() |
| | | { |
| | | tlsActiveProvider = tlsPendingProvider; |
| | |
| | | tlsPendingProvider = null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Set the security provider to the specified provider. |
| | | * |
| | |
| | | tlsChannel.redirect(sslProvider); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Enable the SASL provider that is currently inactive or pending. |
| | | */ |
| | | /** Enable the SASL provider that is currently inactive or pending. */ |
| | | private void enableSASL() |
| | | { |
| | | saslActiveProvider = saslPendingProvider; |
| | |
| | | saslPendingProvider = null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Return the certificate chain array associated with a connection. |
| | | * |
| | |
| | | return new Certificate[0]; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the TLS redirecting byte channel used in a LDAP client |
| | | * connection. |
| | |
| | | return this.tlsChannel; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int getSSF() |
| | | { |
| | |
| | | return Math.max(tlsSSF, saslSSF); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finishBind() |
| | | { |
| | |
| | | super.finishBind(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finishStartTLS() |
| | | { |