harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r420481 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
Date Mon, 10 Jul 2006 10:30:16 GMT
Author: mloenko
Date: Mon Jul 10 03:30:16 2006
New Revision: 420481

URL: http://svn.apache.org/viewvc?rev=420481&view=rev
Log:
applied patch from HARMONY-809
[classlib][luni] HttpsURLConnection enhancement allowing interaction with the server

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java?rev=420481&r1=420480&r2=420481&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
Mon Jul 10 03:30:16 2006
@@ -27,6 +27,7 @@
 import java.security.cert.Certificate;
 import java.util.List;
 import java.util.Map;
+
 import javax.net.ssl.SSLPeerUnverifiedException;
 import javax.net.ssl.SSLSocket;
 
@@ -320,8 +321,31 @@
         }
 
         public void connect() throws IOException {
+            if (connected) {
+                return;
+            }
             super.connect();
-            // TODO wrap established Socket into SSLSocket
+            // TODO make SSL Tunnel in case of using the proxy
+            setUpTransportIO(wrapConnection(socket));
+        }
+
+        /**
+         * Create the secure socket over the connected socket and
+         * verify remote hostname.
+         */
+        private Socket wrapConnection(Socket socket) throws IOException {
+            String hostname = url.getHost();
+            // create the wrapper over connected socket
+            sslSocket = (SSLSocket) getSSLSocketFactory().createSocket(
+                    socket, hostname, url.getPort(), true);
+            sslSocket.setUseClientMode(true);
+            sslSocket.startHandshake();
+            if (!getHostnameVerifier().verify(hostname,
+                    sslSocket.getSession())) {
+                throw new IOException("Hostname <"
+                        + hostname + "> was not verified.");
+            }
+            return sslSocket;
         }
     }
 }



Mime
View raw message