You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2011/07/28 16:27:46 UTC

svn commit: r1151869 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java

Author: olegk
Date: Thu Jul 28 14:27:45 2011
New Revision: 1151869

URL: http://svn.apache.org/viewvc?rev=1151869&view=rev
Log:
HTTPCLIENT-1111: Added #prepareSocket method to SSLSocketFactory 
Contributed by Pasi Eronen <pe at iki.fi>

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java?rev=1151869&r1=1151868&r2=1151869&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java Thu Jul 28 14:27:45 2011
@@ -340,12 +340,16 @@ public class SSLSocketFactory implements
      * @since 4.1
      */
     public Socket createSocket(final HttpParams params) throws IOException {
-        return this.socketfactory.createSocket();
+        SSLSocket sock = (SSLSocket) this.socketfactory.createSocket();
+        prepareSocket(sock);
+        return sock;
     }
 
     @Deprecated
     public Socket createSocket() throws IOException {
-        return this.socketfactory.createSocket();
+        SSLSocket sock = (SSLSocket) this.socketfactory.createSocket();
+        prepareSocket(sock);
+        return sock;
     }
 
     /**
@@ -384,6 +388,7 @@ public class SSLSocketFactory implements
         } else {
             sslsock = (SSLSocket) this.socketfactory.createSocket(
                     sock, remoteAddress.getHostName(), remoteAddress.getPort(), true);
+            prepareSocket(sslsock);
         }
         if (this.hostnameVerifier != null) {
             try {
@@ -448,6 +453,7 @@ public class SSLSocketFactory implements
               port,
               autoClose
         );
+        prepareSocket(sslSocket);
         if (this.hostnameVerifier != null) {
             this.hostnameVerifier.verify(host, sslSocket);
         }
@@ -505,4 +511,15 @@ public class SSLSocketFactory implements
         return createLayeredSocket(socket, host, port, autoClose);
     }
 
+    /**
+     * Performs any custom initialization for a newly created SSLSocket
+     * (before the SSL handshake happens).
+     *
+     * The default implementation is a no-op, but could be overriden to, e.g.,
+     * call {@link SSLSocket#setEnabledCipherSuites(java.lang.String[])}.
+     * 
+     * @since 4.2
+     */
+    protected void prepareSocket(final SSLSocket socket) throws IOException {
+    }
 }