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 %%%
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| pack-priv volatile IOException | |
| pack-priv int | |
| private static final boolean | |
| public final String | |
| public InputStream | |
| private static final boolean | |
| private volatile boolean | |
| private final ReentrantLock | |
| private int | |
| public OutputStream | |
| private final LdapClient | |
| private final Condition | |
| private boolean | |
| private final ReentrantLock | |
| private LdapRequest | |
| public final int | |
| pack-priv int | |
| public Socket | |
| pack-priv final ReentrantLock | |
| private volatile Connection. | |
| private OutputStream | |
| private String | |
| private String | |
| pack-priv volatile boolean | |
| private boolean | |
| private final Thread |
| Access | Constructor and Description |
|---|---|
| pack-priv | Connection(LdapClient parent, String host, int port, String socketFactory, int connectTimeout, int readTimeout, OutputStream trace)
|
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| pack-priv void | |
| private void | |
| pack-priv void | cleanup(Control[]
Possibly null request controls that accompanies the
abandon and unbind LDAP request. reqCtls, boolean true means to call parent LdapClient back, notifying
it that the connection has been closed; false means not to notify
parent. If LdapClient invokes cleanup(), notifyParent should be set to
false because LdapClient already knows that it is closing
the connection. If Connection invokes cleanup(), notifyParent should be
set to true because LdapClient needs to know about the closure. notifyParent)
|
| private void | |
| private Socket | |
| private InetSocketAddress | |
| private Socket | |
| pack-priv LdapRequest | |
| private void | |
| private InputStream | |
| pack-priv int | |
| private SocketFactory | |
| public X509Certificate | |
| private static boolean | |
| private void | |
| public boolean | |
| public boolean | |
| private void | |
| private void | |
| private static byte[] | |
| pack-priv BerDecoder | |
| pack-priv void | |
| public void | |
| public void | |
| public void | |
| pack-priv void | |
| public void | |
| pack-priv void | |
| private void | |
| private void | |
| pack-priv LdapRequest | |
| pack-priv LdapRequest | |
| pack-priv LdapRequest |
| bound | back to summary |
|---|---|
| private boolean bound | |
| closureReason | back to summary |
|---|---|
| pack-priv volatile IOException closureReason | |
| connectTimeout | back to summary |
|---|---|
| pack-priv int connectTimeout | |
| debug | back to summary |
|---|---|
| private static final boolean debug | |
| host | back to summary |
|---|---|
| public final String host | |
| inStream | back to summary |
|---|---|
| public InputStream inStream | |
| IS_HOSTNAME_VERIFICATION_DISABLED | back to summary |
|---|---|
| private static final boolean IS_HOSTNAME_VERIFICATION_DISABLED | |
| isUpgradedToStartTls | back to summary |
|---|---|
| private volatile boolean isUpgradedToStartTls | |
| lock | back to summary |
|---|---|
| private final ReentrantLock lock | |
| outMsgId | back to summary |
|---|---|
| private int outMsgId | |
| outStream | back to summary |
|---|---|
| public OutputStream outStream | |
| parent | back to summary |
|---|---|
| private final LdapClient parent | |
| pauseCondition | back to summary |
|---|---|
| private final Condition pauseCondition | |
| paused | back to summary |
|---|---|
| private boolean paused | |
| pauseLock | back to summary |
|---|---|
| private final ReentrantLock pauseLock | |
| pendingRequests | back to summary |
|---|---|
| private LdapRequest pendingRequests | |
| port | back to summary |
|---|---|
| public final int port | |
| readTimeout | back to summary |
|---|---|
| pack-priv int readTimeout | |
| sock | back to summary |
|---|---|
| public Socket sock | |
| startTlsLock | back to summary |
|---|---|
| pack-priv final ReentrantLock startTlsLock | |
| tlsHandshakeListener | back to summary |
|---|---|
| private volatile Connection. | |
| traceFile | back to summary |
|---|---|
| private OutputStream traceFile | |
| traceTagIn | back to summary |
|---|---|
| private String traceTagIn | |
| traceTagOut | back to summary |
|---|---|
| private String traceTagOut | |
| useable | back to summary |
|---|---|
| pack-priv volatile boolean useable | |
| v3 | back to summary |
|---|---|
| private boolean v3 | |
| worker | back to summary |
|---|---|
| private final Thread worker | |
| Connection | back to summary |
|---|---|
| pack-priv Connection(LdapClient parent, String host, int port, String socketFactory, int connectTimeout, int readTimeout, OutputStream trace) throws NamingException | |
| abandonOutstandingReqs | back to summary |
|---|---|
| pack-priv void abandonOutstandingReqs(Control[] reqCtls) | |
| abandonRequest | back to summary |
|---|---|
| pack-priv void abandonRequest(LdapRequest ldr, Control[] reqCtls) | |
| addRequest | back to summary |
|---|---|
| private void addRequest(LdapRequest ldapRequest) | |
| cleanup | back to summary |
|---|---|
pack-priv void cleanup(Control[] reqCtls, boolean notifyParent)
| |
| closeOpenedSocket | back to summary |
|---|---|
| private void closeOpenedSocket(Socket socket) | |
| createConnectionSocket | back to summary |
|---|---|
| private Socket createConnectionSocket(String host, int port, SocketFactory factory, int connectTimeout) throws IOException | |
| createInetSocketAddress | back to summary |
|---|---|
| private InetSocketAddress createInetSocketAddress(String host, int port) | |
| createSocket | back to summary |
|---|---|
| private Socket createSocket(String host, int port, String socketFactory, int connectTimeout) throws Exception | |
| findRequest | back to summary |
|---|---|
| pack-priv LdapRequest findRequest(int msgId) | |
| flushAndCloseOutputStream | back to summary |
|---|---|
| private void flushAndCloseOutputStream() | |
| getInputStream | back to summary |
|---|---|
| private InputStream getInputStream() Used by Connection thread to read inStream into a local variable. This ensures that there is no contention between the main thread and the Connection thread when the main thread updates inStream. | |
| getMsgId | back to summary |
|---|---|
| pack-priv int getMsgId() | |
| getSocketFactory | back to summary |
|---|---|
| private SocketFactory getSocketFactory(String socketFactoryName) throws Exception | |
| getTlsServerCertificate | back to summary |
|---|---|
| public X509Certificate getTlsServerCertificate() throws SaslException | |
| hostnameVerificationDisabledValue | back to summary |
|---|---|
| private static boolean hostnameVerificationDisabledValue() | |
| initialSSLHandshake | back to summary |
|---|---|
| private void initialSSLHandshake(SSLSocket sslSocket, int connectTimeout) throws Exception | |
| isTlsConnection | back to summary |
|---|---|
| public boolean isTlsConnection() | |
| isUpgradedToStartTls | back to summary |
|---|---|
| public boolean isUpgradedToStartTls() | |
| ldapUnbind | back to summary |
|---|---|
| private void ldapUnbind(Control[] reqCtls) | |
| pauseReader | back to summary |
|---|---|
| private void pauseReader() throws IOException | |
| readFully | back to summary |
|---|---|
| private static byte[] readFully(InputStream is, int length) throws IOException | |
| readReply | back to summary |
|---|---|
| pack-priv BerDecoder readReply(LdapRequest ldr) throws NamingException Reads a reply; waits until one is ready. | |
| removeRequest | back to summary |
|---|---|
| pack-priv void removeRequest(LdapRequest req) | |
| replaceStreams | back to summary |
|---|---|
| public void replaceStreams(InputStream newIn, OutputStream newOut) | |
| replaceStreams | back to summary |
|---|---|
| public void replaceStreams(InputStream newIn, OutputStream newOut, boolean isStartTls) | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| setBound | back to summary |
|---|---|
| pack-priv void setBound() | |
| setHandshakeCompletedListener | back to summary |
|---|---|
| public void setHandshakeCompletedListener(SSLSocket sslSocket) | |
| setV3 | back to summary |
|---|---|
| pack-priv void setV3(boolean v) | |
| tryUnpauseReader | back to summary |
|---|---|
| private void tryUnpauseReader() | |
| unpauseReader | back to summary |
|---|---|
| private void unpauseReader() throws IOException | |
| writeRequest | back to summary |
|---|---|
| pack-priv LdapRequest writeRequest(BerEncoder ber, int msgId) throws IOException | |
| writeRequest | back to summary |
|---|---|
| pack-priv LdapRequest writeRequest(BerEncoder ber, int msgId, boolean pauseAfterReceipt) throws IOException | |
| writeRequest | back to summary |
|---|---|
| pack-priv LdapRequest writeRequest(BerEncoder ber, int msgId, boolean pauseAfterReceipt, int replyQueueCapacity) throws IOException | |
| Modifier and Type | Field and Description |
|---|---|
| private final CompletableFuture |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | handshakeCompleted(HandshakeCompletedEvent event)
Implements javax. This method is invoked on registered objects when a SSL handshake is completed. |
| tlsHandshakeCompleted | back to summary |
|---|---|
| private final CompletableFuture<X509Certificate> tlsHandshakeCompleted | |
| HandshakeListener | back to summary |
|---|---|
| private HandshakeListener() | |
| handshakeCompleted | back to summary |
|---|---|
| public void handshakeCompleted(HandshakeCompletedEvent event) Implements javax. Doc from javax. This method is invoked on registered objects when a SSL handshake is completed.
| |