com.sun.jndi.ldap
Class Connection
java.lang.Object
com.sun.jndi.ldap.Connection
- All Implemented Interfaces:
- Runnable
public final class Connection
- extends Object
- implements Runnable
A thread that creates a connection to an LDAP server.
After the connection, the thread reads from the connection.
A caller can invoke methods on the instance to read LDAP responses
and to send LDAP requests.
There is a one-to-one correspondence between an LdapClient and
a Connection. Access to Connection and its methods is only via
LdapClient with two exceptions: SASL authentication and StartTLS.
SASL needs to access Connection's socket IO streams (in order to do encryption
of the security layer). StartTLS needs to do replace IO streams
and close the IO streams on nonfatal close. The code for SASL
authentication can be treated as being the same as from LdapClient
because the SASL code is only ever called from LdapClient, from
inside LdapClient's synchronized authenticate() method. StartTLS is called
directly by the application but should only occur when the underlying
connection is quiet.
In terms of synchronization, worry about data structures
used by the Connection thread because that usage might contend
with calls by the main threads (i.e., those that call LdapClient).
Main threads need to worry about contention with each other.
Fields that Connection thread uses:
inStream - synced access and update; initialized in constructor;
referenced outside class unsync'ed (by LdapSasl) only
when connection is quiet
traceFile, traceTagIn, traceTagOut - no sync; debugging only
parent - no sync; initialized in constructor; no updates
pendingRequests - sync
pauseLock - per-instance lock;
paused - sync via pauseLock (pauseReader())
Members used by main threads (LdapClient):
host, port - unsync; read-only access for StartTLS and debug messages
setBound(), setV3() - no sync; called only by LdapClient.authenticate(),
which is a sync method called only when connection is "quiet"
getMsgId() - sync
writeRequest(), removeRequest(),findRequest(), abandonOutstandingReqs() -
access to shared pendingRequests is sync
writeRequest(), abandonRequest(), ldapUnbind() - access to outStream sync
cleanup() - sync
readReply() - access to sock sync
unpauseReader() - (indirectly via writeRequest) sync on pauseLock
Members used by SASL auth (main thread):
inStream, outStream - no sync; used to construct new stream; accessed
only when conn is "quiet" and not shared
replaceStreams() - sync method
Members used by StartTLS:
inStream, outStream - no sync; used to record the existing streams;
accessed only when conn is "quiet" and not shared
replaceStreams() - sync method
Handles anonymous, simple, and SASL bind for v3; anonymous and simple
for v2.
%%% made public for access by LdapSasl %%%
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
host
public final String host
port
public final int port
inStream
public InputStream inStream
outStream
public OutputStream outStream
sock
public Socket sock
replaceStreams
public void replaceStreams(InputStream newIn,
OutputStream newOut)
run
public void run()
- Description copied from interface:
Runnable
- run executes this Runnable()'s code.
- Specified by:
run in interface Runnable
aicas GmbH, Karlsruhe - Germany www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.