< prev index next >

src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java

Print this page




 320                     socket.connect(endpoint, connectTimeout);
 321             }
 322 
 323             // continue (but ignore connectTimeout)
 324 
 325             if (socket == null) {
 326                 if (debug) {
 327                     System.err.println("Connection: creating socket");
 328                 }
 329                 // connected socket
 330                 socket = new Socket(host, port);
 331             }
 332         }
 333 
 334         // For LDAP connect timeouts on LDAP over SSL connections must treat
 335         // the SSL handshake following socket connection as part of the timeout.
 336         // So explicitly set a socket read timeout, trigger the SSL handshake,
 337         // then reset the timeout.
 338         if (socket instanceof SSLSocket) {
 339             SSLSocket sslSocket = (SSLSocket) socket;
 340             int socketTimeout = sslSocket.getSoTimeout();
 341             if (!IS_HOSTNAME_VERIFICATION_DISABLED) {
 342                 SSLParameters param = sslSocket.getSSLParameters();
 343                 param.setEndpointIdentificationAlgorithm("LDAPS");
 344                 sslSocket.setSSLParameters(param);
 345             }
 346             if (connectTimeout > 0) {

 347                 sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value
 348             }
 349             sslSocket.startHandshake();
 350             sslSocket.setSoTimeout(socketTimeout);


 351         }
 352         return socket;
 353     }
 354 
 355     ////////////////////////////////////////////////////////////////////////////
 356     //
 357     // Methods to IO to the LDAP server
 358     //
 359     ////////////////////////////////////////////////////////////////////////////
 360 
 361     synchronized int getMsgId() {
 362         return ++outMsgId;
 363     }
 364 
 365     LdapRequest writeRequest(BerEncoder ber, int msgId) throws IOException {
 366         return writeRequest(ber, msgId, false /* pauseAfterReceipt */, -1);
 367     }
 368 
 369     LdapRequest writeRequest(BerEncoder ber, int msgId,
 370         boolean pauseAfterReceipt) throws IOException {




 320                     socket.connect(endpoint, connectTimeout);
 321             }
 322 
 323             // continue (but ignore connectTimeout)
 324 
 325             if (socket == null) {
 326                 if (debug) {
 327                     System.err.println("Connection: creating socket");
 328                 }
 329                 // connected socket
 330                 socket = new Socket(host, port);
 331             }
 332         }
 333 
 334         // For LDAP connect timeouts on LDAP over SSL connections must treat
 335         // the SSL handshake following socket connection as part of the timeout.
 336         // So explicitly set a socket read timeout, trigger the SSL handshake,
 337         // then reset the timeout.
 338         if (socket instanceof SSLSocket) {
 339             SSLSocket sslSocket = (SSLSocket) socket;            

 340             if (!IS_HOSTNAME_VERIFICATION_DISABLED) {
 341                 SSLParameters param = sslSocket.getSSLParameters();
 342                 param.setEndpointIdentificationAlgorithm("LDAPS");
 343                 sslSocket.setSSLParameters(param);
 344             }
 345             if (connectTimeout > 0) {
 346                 int socketTimeout = sslSocket.getSoTimeout();
 347                 sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value

 348                 sslSocket.startHandshake();
 349                 sslSocket.setSoTimeout(socketTimeout);
 350             }
 351             
 352         }
 353         return socket;
 354     }
 355 
 356     ////////////////////////////////////////////////////////////////////////////
 357     //
 358     // Methods to IO to the LDAP server
 359     //
 360     ////////////////////////////////////////////////////////////////////////////
 361 
 362     synchronized int getMsgId() {
 363         return ++outMsgId;
 364     }
 365 
 366     LdapRequest writeRequest(BerEncoder ber, int msgId) throws IOException {
 367         return writeRequest(ber, msgId, false /* pauseAfterReceipt */, -1);
 368     }
 369 
 370     LdapRequest writeRequest(BerEncoder ber, int msgId,
 371         boolean pauseAfterReceipt) throws IOException {


< prev index next >