Home » openjdk-7 » com.sun.jndi » ldap » [javadoc | source]
com.sun.jndi.ldap
public final class: Connection [javadoc | source]
java.lang.Object
   com.sun.jndi.ldap.Connection

All Implemented Interfaces:
    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 %%%

Field Summary
public final  String host     
public final  int port     
public  InputStream inStream     
public  OutputStream outStream     
public  Socket sock     
volatile  IOException closureReason     
volatile  boolean useable     
Constructor:
 Connection(LdapClient parent,
    String host,
    int port,
    String socketFactory,
    int connectTimeout,
    int readTimeout,
    OutputStream trace) throws NamingException 
Method from com.sun.jndi.ldap.Connection Summary:
abandonOutstandingReqs,   abandonRequest,   cleanup,   findRequest,   getMsgId,   readReply,   removeRequest,   replaceStreams,   run,   setBound,   setV3,   writeRequest,   writeRequest,   writeRequest
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.jndi.ldap.Connection Detail:
 synchronized  void abandonOutstandingReqs(Control[] reqCtls) 
  void abandonRequest(LdapRequest ldr,
    Control[] reqCtls) 
  void cleanup(Control[] reqCtls,
    boolean notifyParent) 
 synchronized LdapRequest findRequest(int msgId) 
 synchronized int getMsgId() 
 BerDecoder readReply(LdapRequest ldr) throws IOException, NamingException 
    Reads a reply; waits until one is ready.
 synchronized  void removeRequest(LdapRequest req) 
 public synchronized  void replaceStreams(InputStream newIn,
    OutputStream newOut) 
 public  void run() 
  void setBound() 
  void setV3(boolean v) 
 LdapRequest writeRequest(BerEncoder ber,
    int msgId) throws IOException 
 LdapRequest writeRequest(BerEncoder ber,
    int msgId,
    boolean pauseAfterReceipt) throws IOException 
 LdapRequest writeRequest(BerEncoder ber,
    int msgId,
    boolean pauseAfterReceipt,
    int replyQueueCapacity) throws IOException