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 2013/07/27 17:59:36 UTC
svn commit: r1507677 - in /httpcomponents/httpclient/trunk:
fluent-hc/src/main/java/org/apache/http/client/fluent/
httpclient/src/examples/org/apache/http/examples/client/
httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/
httpclient/src/...
Author: olegk
Date: Sat Jul 27 15:59:36 2013
New Revision: 1507677
URL: http://svn.apache.org/r1507677
Log:
Deprecated SSLSocketFactory in favor of SSLConnectionSocketFactory
Added:
httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/HostNameResolver.java (contents, props changed)
- copied, changed from r1507633, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/HostNameResolver.java
httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/
httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java (contents, props changed)
- copied, changed from r1507633, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java (contents, props changed)
- copied, changed from r1507633, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainSocketFactory.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java (with props)
Removed:
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/HostNameResolver.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainSocketFactory.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
Modified:
httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java
httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java (original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java Sat Jul 27 15:59:36 2013
@@ -50,7 +50,7 @@ import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLInitializationException;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.auth.BasicScheme;
@@ -89,7 +89,7 @@ public class Executor {
}
final Registry<ConnectionSocketFactory> sfr = RegistryBuilder.<ConnectionSocketFactory>create()
- .register("http", PlainSocketFactory.getSocketFactory())
+ .register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", ssl != null ? ssl : SSLSocketFactory.getSocketFactory())
.build();
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java Sat Jul 27 15:59:36 2013
@@ -59,10 +59,10 @@ import org.apache.http.conn.HttpConnecti
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContexts;
-import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.impl.client.BasicCookieStore;
@@ -147,8 +147,8 @@ public class ClientConfiguration {
// Create a registry of custom connection socket factories for supported
// protocol schemes.
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
- .register("http", PlainSocketFactory.INSTANCE)
- .register("https", new SSLSocketFactory(sslcontext, hostnameVerifier))
+ .register("http", PlainConnectionSocketFactory.INSTANCE)
+ .register("https", new SSLConnectionSocketFactory(sslcontext, hostnameVerifier))
.build();
// Use custom DNS resolver to override the system DNS resolution.
Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java Sat Jul 27 15:59:36 2013
@@ -36,7 +36,7 @@ import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ssl.SSLContexts;
-import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
@@ -59,8 +59,8 @@ public class ClientCustomSSL {
.loadTrustMaterial(trustStore)
.build();
- SSLSocketFactory sslsf = new SSLSocketFactory(sslcontext,
- SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext,
+ SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
CloseableHttpClient httpclient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.build();
Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/HostNameResolver.java (from r1507633, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/HostNameResolver.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/HostNameResolver.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/HostNameResolver.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/HostNameResolver.java&r1=1507633&r2=1507677&rev=1507677&view=diff
==============================================================================
(empty)
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/HostNameResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/HostNameResolver.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/HostNameResolver.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java Sat Jul 27 15:59:36 2013
@@ -45,7 +45,7 @@ import org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link org.apache.http.conn.socket.PlainSocketFactory}
+ * @deprecated (4.3) use {@link org.apache.http.conn.socket.PlainConnectionSocketFactory}
*/
@Immutable
@Deprecated
Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java (from r1507633, 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-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java&r1=1507633&r2=1507677&rev=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java Sat Jul 27 15:59:36 2013
@@ -130,9 +130,11 @@ import org.apache.http.util.TextUtils;
* </ul>
*
* @since 4.0
+ *
+ * @deprecated (4.3) use {@link SSLConnectionSocketFactory}.
*/
-@SuppressWarnings("deprecation")
@ThreadSafe
+@Deprecated
public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeLayeredSocketFactory,
LayeredSchemeSocketFactory, LayeredSocketFactory {
@@ -193,10 +195,6 @@ public class SSLSocketFactory implements
private final String[] supportedProtocols;
private final String[] supportedCipherSuites;
- /**
- * @deprecated (4.1) Use {@link SSLContextBuilder} and {@link #SSLSocketFactory(SSLContext)}.
- */
- @Deprecated
public SSLSocketFactory(
final String algorithm,
final KeyStore keystore,
@@ -216,11 +214,7 @@ public class SSLSocketFactory implements
/**
* @since 4.1
- *
- * @deprecated (4.3) Use {@link SSLContextBuilder} and {@link #SSLSocketFactory(SSLContext,
- * X509HostnameVerifier)}
*/
- @Deprecated
public SSLSocketFactory(
final String algorithm,
final KeyStore keystore,
@@ -241,11 +235,7 @@ public class SSLSocketFactory implements
/**
* @since 4.1
- *
- * @deprecated (4.3) Use {@link SSLContextBuilder} and {@link #SSLSocketFactory(SSLContext,
- * X509HostnameVerifier)}
*/
- @Deprecated
public SSLSocketFactory(
final String algorithm,
final KeyStore keystore,
@@ -263,10 +253,6 @@ public class SSLSocketFactory implements
hostnameVerifier);
}
- /**
- * @deprecated (4.3) Use {@link SSLContextBuilder} and {@link #SSLSocketFactory(SSLContext)}
- */
- @Deprecated
public SSLSocketFactory(
final KeyStore keystore,
final String keystorePassword,
@@ -279,10 +265,6 @@ public class SSLSocketFactory implements
BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
}
- /**
- * @deprecated (4.3) Use {@link SSLContextBuilder} and {@link #SSLSocketFactory(SSLContext)}
- */
- @Deprecated
public SSLSocketFactory(
final KeyStore keystore,
final String keystorePassword)
@@ -293,10 +275,6 @@ public class SSLSocketFactory implements
BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
}
- /**
- * @deprecated (4.3) Use {@link SSLContextBuilder} and {@link #SSLSocketFactory(SSLContext)}
- */
- @Deprecated
public SSLSocketFactory(
final KeyStore truststore)
throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
@@ -308,11 +286,7 @@ public class SSLSocketFactory implements
/**
* @since 4.1
- *
- * @deprecated (4.3) Use {@link SSLContextBuilder} and {@link #SSLSocketFactory(SSLContext,
- * X509HostnameVerifier)}
*/
- @Deprecated
public SSLSocketFactory(
final TrustStrategy trustStrategy,
final X509HostnameVerifier hostnameVerifier)
@@ -325,10 +299,7 @@ public class SSLSocketFactory implements
/**
* @since 4.1
- *
- * @deprecated (4.3) Use {@link SSLContextBuilder} and {@link #SSLSocketFactory(SSLContext)}
*/
- @Deprecated
public SSLSocketFactory(
final TrustStrategy trustStrategy)
throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
@@ -342,10 +313,6 @@ public class SSLSocketFactory implements
this(sslContext, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
}
- /**
- * @deprecated (4.1) Use {@link #SSLSocketFactory(SSLContext)}
- */
- @Deprecated
public SSLSocketFactory(
final SSLContext sslContext, final HostNameResolver nameResolver) {
super();
@@ -406,29 +373,18 @@ public class SSLSocketFactory implements
* @param params Optional parameters. Parameters passed to this method will have no effect.
* This method will create a unconnected instance of {@link Socket} class.
* @since 4.1
- *
- * @deprecated (4.3) use {@link #createSocket(HttpContext)}
*/
- @Deprecated
public Socket createSocket(final HttpParams params) throws IOException {
return createSocket((HttpContext) null);
}
- /**
- * @deprecated (4.1) use {@link #createSocket(HttpParams)}
- */
- @Deprecated
public Socket createSocket() throws IOException {
return createSocket((HttpContext) null);
}
/**
* @since 4.1
- *
- * @deprecated (4.3) use {@link #connectSocket(int, Socket, HttpHost, InetSocketAddress,
- * InetSocketAddress, HttpContext)}
*/
- @Deprecated
public Socket connectSocket(
final Socket socket,
final InetSocketAddress remoteAddress,
@@ -459,10 +415,7 @@ public class SSLSocketFactory implements
* @return <code>true</code>
*
* @throws IllegalArgumentException if the argument is invalid
- *
- * @deprecated (4.3) no longer used.
*/
- @Deprecated
public boolean isSecure(final Socket sock) throws IllegalArgumentException {
Args.notNull(sock, "Socket");
Asserts.check(sock instanceof SSLSocket, "Socket not created by this factory");
@@ -472,10 +425,7 @@ public class SSLSocketFactory implements
/**
* @since 4.2
- *
- * @deprecated (4.3) use {@link #createLayeredSocket(Socket, String, int, HttpContext)}
*/
- @Deprecated
public Socket createLayeredSocket(
final Socket socket,
final String host,
@@ -484,10 +434,6 @@ public class SSLSocketFactory implements
return createLayeredSocket(socket, host, port, (HttpContext) null);
}
- /**
- * @deprecated (4.1) use {@link #createLayeredSocket(Socket, String, int, HttpParams)}
- */
- @Deprecated
public Socket createLayeredSocket(
final Socket socket,
final String host,
@@ -496,10 +442,6 @@ public class SSLSocketFactory implements
return createLayeredSocket(socket, host, port, (HttpContext) null);
}
- /**
- * @deprecated (4.1) use constructor.
- */
- @Deprecated
public void setHostnameVerifier(final X509HostnameVerifier hostnameVerifier) {
Args.notNull(hostnameVerifier, "Hostname verifier");
this.hostnameVerifier = hostnameVerifier;
@@ -509,11 +451,6 @@ public class SSLSocketFactory implements
return this.hostnameVerifier;
}
- /**
- * @deprecated (4.1) Use {@link #connectSocket(Socket, InetSocketAddress, InetSocketAddress,
- * HttpParams)}
- */
- @Deprecated
public Socket connectSocket(
final Socket socket,
final String host, final int port,
@@ -534,10 +471,6 @@ public class SSLSocketFactory implements
return connectSocket(socket, remoteAddress, localAddress, params);
}
- /**
- * @deprecated (4.1) Use {@link #createLayeredSocket(Socket, String, int, boolean)}
- */
- @Deprecated
public Socket createSocket(
final Socket socket,
final String host, final int port,
@@ -567,22 +500,12 @@ public class SSLSocketFactory implements
prepareSocket(socket);
}
- /**
- * {@inheritDoc}
- *
- * @since 4.3
- */
public Socket createSocket(final HttpContext context) throws IOException {
final SSLSocket sock = (SSLSocket) this.socketfactory.createSocket();
internalPrepareSocket(sock);
return sock;
}
- /**
- * {@inheritDoc}
- *
- * @since 4.3
- */
public Socket connectSocket(
final int connectTimeout,
final Socket socket,
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java (from r1507633, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainSocketFactory.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainSocketFactory.java&r1=1507633&r2=1507677&rev=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java Sat Jul 27 15:59:36 2013
@@ -41,15 +41,15 @@ import org.apache.http.protocol.HttpCont
* @since 4.3
*/
@Immutable
-public class PlainSocketFactory implements ConnectionSocketFactory {
+public class PlainConnectionSocketFactory implements ConnectionSocketFactory {
- public static final PlainSocketFactory INSTANCE = new PlainSocketFactory();
+ public static final PlainConnectionSocketFactory INSTANCE = new PlainConnectionSocketFactory();
- public static PlainSocketFactory getSocketFactory() {
+ public static PlainConnectionSocketFactory getSocketFactory() {
return INSTANCE;
}
- public PlainSocketFactory() {
+ public PlainConnectionSocketFactory() {
super();
}
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java?rev=1507677&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java (added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java Sat Jul 27 15:59:36 2013
@@ -0,0 +1,299 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn.ssl;
+
+import org.apache.http.HttpHost;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
+import org.apache.http.util.TextUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+
+/**
+ * Layered socket factory for TLS/SSL connections.
+ * <p>
+ * SSLSocketFactory can be used to validate the identity of the HTTPS server against a list of
+ * trusted certificates and to authenticate to the HTTPS server using a private key.
+ * <p>
+ * SSLSocketFactory will enable server authentication when supplied with
+ * a {@link java.security.KeyStore trust-store} file containing one or several trusted certificates. The client
+ * secure socket will reject the connection during the SSL session handshake if the target HTTPS
+ * server attempts to authenticate itself with a non-trusted certificate.
+ * <p>
+ * Use JDK keytool utility to import a trusted certificate and generate a trust-store file:
+ * <pre>
+ * keytool -import -alias "my server cert" -file server.crt -keystore my.truststore
+ * </pre>
+ * <p>
+ * In special cases the standard trust verification process can be bypassed by using a custom
+ * {@link org.apache.http.conn.ssl.TrustStrategy}. This interface is primarily intended for allowing self-signed
+ * certificates to be accepted as trusted without having to add them to the trust-store file.
+ * <p>
+ * SSLSocketFactory will enable client authentication when supplied with
+ * a {@link java.security.KeyStore key-store} file containing a private key/public certificate
+ * pair. The client secure socket will use the private key to authenticate
+ * itself to the target HTTPS server during the SSL session handshake if
+ * requested to do so by the server.
+ * The target HTTPS server will in its turn verify the certificate presented
+ * by the client in order to establish client's authenticity.
+ * <p>
+ * Use the following sequence of actions to generate a key-store file
+ * </p>
+ * <ul>
+ * <li>
+ * <p>
+ * Use JDK keytool utility to generate a new key
+ * <pre>keytool -genkey -v -alias "my client key" -validity 365 -keystore my.keystore</pre>
+ * For simplicity use the same password for the key as that of the key-store
+ * </p>
+ * </li>
+ * <li>
+ * <p>
+ * Issue a certificate signing request (CSR)
+ * <pre>keytool -certreq -alias "my client key" -file mycertreq.csr -keystore my.keystore</pre>
+ * </p>
+ * </li>
+ * <li>
+ * <p>
+ * Send the certificate request to the trusted Certificate Authority for signature.
+ * One may choose to act as her own CA and sign the certificate request using a PKI
+ * tool, such as OpenSSL.
+ * </p>
+ * </li>
+ * <li>
+ * <p>
+ * Import the trusted CA root certificate
+ * <pre>keytool -import -alias "my trusted ca" -file caroot.crt -keystore my.keystore</pre>
+ * </p>
+ * </li>
+ * <li>
+ * <p>
+ * Import the PKCS#7 file containg the complete certificate chain
+ * <pre>keytool -import -alias "my client key" -file mycert.p7 -keystore my.keystore</pre>
+ * </p>
+ * </li>
+ * <li>
+ * <p>
+ * Verify the content the resultant keystore file
+ * <pre>keytool -list -v -keystore my.keystore</pre>
+ * </p>
+ * </li>
+ * </ul>
+ *
+ * @since 4.0
+ */
+@ThreadSafe
+public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactory {
+
+ public static final String TLS = "TLS";
+ public static final String SSL = "SSL";
+ public static final String SSLV2 = "SSLv2";
+
+ public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER
+ = new AllowAllHostnameVerifier();
+
+ public static final X509HostnameVerifier BROWSER_COMPATIBLE_HOSTNAME_VERIFIER
+ = new BrowserCompatHostnameVerifier();
+
+ public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER
+ = new StrictHostnameVerifier();
+
+ /**
+ * Obtains default SSL socket factory with an SSL context based on the standard JSSE
+ * trust material (<code>cacerts</code> file in the security properties directory).
+ * System properties are not taken into consideration.
+ *
+ * @return default SSL socket factory
+ */
+ public static SSLConnectionSocketFactory getSocketFactory() throws SSLInitializationException {
+ return new SSLConnectionSocketFactory(
+ SSLContexts.createDefault(),
+ BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
+ private static String[] split(final String s) {
+ if (TextUtils.isBlank(s)) {
+ return null;
+ }
+ return s.split(" *, *");
+ }
+
+ /**
+ * Obtains default SSL socket factory with an SSL context based on system properties
+ * as described in
+ * <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
+ * "JavaTM Secure Socket Extension (JSSE) Reference Guide for the JavaTM 2 Platform
+ * Standard Edition 5</a>
+ *
+ * @return default system SSL socket factory
+ */
+ public static SSLConnectionSocketFactory getSystemSocketFactory() throws SSLInitializationException {
+ return new SSLConnectionSocketFactory(
+ (javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory.getDefault(),
+ split(System.getProperty("https.protocols")),
+ split(System.getProperty("https.cipherSuites")),
+ BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
+ private final javax.net.ssl.SSLSocketFactory socketfactory;
+ private final X509HostnameVerifier hostnameVerifier;
+ private final String[] supportedProtocols;
+ private final String[] supportedCipherSuites;
+
+ public SSLConnectionSocketFactory(final SSLContext sslContext) {
+ this(sslContext, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
+ public SSLConnectionSocketFactory(
+ final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier) {
+ this(Args.notNull(sslContext, "SSL context").getSocketFactory(),
+ null, null, hostnameVerifier);
+ }
+
+ public SSLConnectionSocketFactory(
+ final SSLContext sslContext,
+ final String[] supportedProtocols,
+ final String[] supportedCipherSuites,
+ final X509HostnameVerifier hostnameVerifier) {
+ this(Args.notNull(sslContext, "SSL context").getSocketFactory(),
+ supportedProtocols, supportedCipherSuites, hostnameVerifier);
+ }
+
+ public SSLConnectionSocketFactory(
+ final javax.net.ssl.SSLSocketFactory socketfactory,
+ final X509HostnameVerifier hostnameVerifier) {
+ this(socketfactory, null, null, hostnameVerifier);
+ }
+
+ public SSLConnectionSocketFactory(
+ final javax.net.ssl.SSLSocketFactory socketfactory,
+ final String[] supportedProtocols,
+ final String[] supportedCipherSuites,
+ final X509HostnameVerifier hostnameVerifier) {
+ Args.notNull(socketfactory, "SSL socket factory");
+ this.socketfactory = socketfactory;
+ this.supportedProtocols = supportedProtocols;
+ this.supportedCipherSuites = supportedCipherSuites;
+ this.hostnameVerifier = hostnameVerifier;
+ }
+
+ /**
+ * 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 javax.net.ssl.SSLSocket#setEnabledCipherSuites(String[])}.
+ */
+ protected void prepareSocket(final SSLSocket socket) throws IOException {
+ }
+
+ private void internalPrepareSocket(final SSLSocket socket) throws IOException {
+ if (supportedProtocols != null) {
+ socket.setEnabledProtocols(supportedProtocols);
+ }
+ if (supportedCipherSuites != null) {
+ socket.setEnabledCipherSuites(supportedCipherSuites);
+ }
+ prepareSocket(socket);
+ }
+
+ public Socket createSocket(final HttpContext context) throws IOException {
+ final SSLSocket sock = (SSLSocket) this.socketfactory.createSocket();
+ internalPrepareSocket(sock);
+ return sock;
+ }
+
+ public Socket connectSocket(
+ final int connectTimeout,
+ final Socket socket,
+ final HttpHost host,
+ final InetSocketAddress remoteAddress,
+ final InetSocketAddress localAddress,
+ final HttpContext context) throws IOException {
+ Args.notNull(host, "HTTP host");
+ Args.notNull(remoteAddress, "Remote address");
+ final Socket sock = socket != null ? socket : createSocket(context);
+ if (localAddress != null) {
+ sock.bind(localAddress);
+ }
+ try {
+ sock.connect(remoteAddress, connectTimeout);
+ } catch (final IOException ex) {
+ try {
+ sock.close();
+ } catch (final IOException ignore) {
+ }
+ throw ex;
+ }
+ // Setup SSL layering if necessary
+ if (sock instanceof SSLSocket) {
+ final SSLSocket sslsock = (SSLSocket) sock;
+ sslsock.startHandshake();
+ verifyHostname(sslsock, host.getHostName());
+ return sock;
+ } else {
+ return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), context);
+ }
+ }
+
+ public Socket createLayeredSocket(
+ final Socket socket,
+ final String target,
+ final int port,
+ final HttpContext context) throws IOException {
+ final SSLSocket sslsock = (SSLSocket) this.socketfactory.createSocket(
+ socket,
+ target,
+ port,
+ true);
+ internalPrepareSocket(sslsock);
+ sslsock.startHandshake();
+ verifyHostname(sslsock, target);
+ return sslsock;
+ }
+
+ private void verifyHostname(final SSLSocket sslsock, final String hostname) throws IOException {
+ if (this.hostnameVerifier != null) {
+ try {
+ this.hostnameVerifier.verify(hostname, sslsock);
+ // verifyHostName() didn't blowup - good!
+ } catch (final IOException iox) {
+ // close the socket before re-throwing the exception
+ try { sslsock.close(); } catch (final Exception x) { /*ignore*/ }
+ throw iox;
+ }
+ }
+ }
+
+}
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java Sat Jul 27 15:59:36 2013
@@ -73,9 +73,9 @@ import org.apache.http.conn.SchemePortRe
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContexts;
-import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.cookie.CookieSpecProvider;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
@@ -476,16 +476,16 @@ public class HttpClientBuilder {
LayeredConnectionSocketFactory sslSocketFactory = this.sslSocketFactory;
if (sslSocketFactory == null) {
if (sslcontext != null) {
- sslSocketFactory = new SSLSocketFactory(sslcontext, hostnameVerifier);
+ sslSocketFactory = new SSLConnectionSocketFactory(sslcontext, hostnameVerifier);
} else {
if (systemProperties) {
- sslSocketFactory = new SSLSocketFactory(
+ sslSocketFactory = new SSLConnectionSocketFactory(
(javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory.getDefault(),
split(System.getProperty("https.protocols")),
split(System.getProperty("https.cipherSuites")),
hostnameVerifier);
} else {
- sslSocketFactory = new SSLSocketFactory(
+ sslSocketFactory = new SSLConnectionSocketFactory(
SSLContexts.createDefault(),
hostnameVerifier);
}
@@ -494,7 +494,7 @@ public class HttpClientBuilder {
@SuppressWarnings("resource")
final PoolingHttpClientConnectionManager poolingmgr = new PoolingHttpClientConnectionManager(
RegistryBuilder.<ConnectionSocketFactory>create()
- .register("http", PlainSocketFactory.getSocketFactory())
+ .register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslSocketFactory)
.build());
if (defaultSocketConfig != null) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java Sat Jul 27 15:59:36 2013
@@ -52,8 +52,8 @@ import org.apache.http.conn.SchemePortRe
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainSocketFactory;
-import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
import org.apache.http.util.Asserts;
@@ -112,8 +112,8 @@ public class BasicHttpClientConnectionMa
private static Registry<ConnectionSocketFactory> getDefaultRegistry() {
return RegistryBuilder.<ConnectionSocketFactory>create()
- .register("http", PlainSocketFactory.getSocketFactory())
- .register("https", SSLSocketFactory.getSocketFactory())
+ .register("http", PlainConnectionSocketFactory.getSocketFactory())
+ .register("https", SSLConnectionSocketFactory.getSocketFactory())
.build();
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java Sat Jul 27 15:59:36 2013
@@ -55,8 +55,8 @@ import org.apache.http.conn.SchemePortRe
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainSocketFactory;
-import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.pool.ConnFactory;
import org.apache.http.pool.ConnPoolControl;
import org.apache.http.pool.PoolStats;
@@ -94,8 +94,8 @@ public class PoolingHttpClientConnection
private static Registry<ConnectionSocketFactory> getDefaultRegistry() {
return RegistryBuilder.<ConnectionSocketFactory>create()
- .register("http", PlainSocketFactory.getSocketFactory())
- .register("https", SSLSocketFactory.getSocketFactory())
+ .register("http", PlainConnectionSocketFactory.getSocketFactory())
+ .register("https", SSLConnectionSocketFactory.getSocketFactory())
.build();
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java Sat Jul 27 15:59:36 2013
@@ -202,7 +202,7 @@ public class TestHostnameVerifier {
final InputStream in = new ByteArrayInputStream(CertificatesToPlayWith.X509_MULTIPLE_SUBJECT_ALT);
final X509Certificate x509 = (X509Certificate) cf.generateCertificate(in);
- final X509HostnameVerifier verifier = SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
+ final X509HostnameVerifier verifier = SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
Assert.assertEquals("CN=localhost, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=CH",
x509.getSubjectDN().getName());
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java Sat Jul 27 15:59:36 2013
@@ -53,7 +53,7 @@ import org.junit.Before;
import org.junit.Test;
/**
- * Unit tests for {@link SSLSocketFactory}.
+ * Unit tests for {@link SSLConnectionSocketFactory}.
*/
public class TestSSLSocketFactory extends LocalServerTestBase {
@@ -124,7 +124,8 @@ public class TestSSLSocketFactory extend
final HttpHost host = new HttpHost("localhost", 443, "https");
final HttpContext context = new BasicHttpContext();
final TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
- final SSLSocketFactory socketFactory = new SSLSocketFactory(clientSSLContext, hostVerifier);
+ final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
+ clientSSLContext, hostVerifier);
SSLSocket socket = (SSLSocket) socketFactory.createSocket(context);
final InetSocketAddress remoteAddress = this.localServer.getServiceAddress();
socket = (SSLSocket) socketFactory.connectSocket(0, socket, host, remoteAddress, null, context);
@@ -154,7 +155,7 @@ public class TestSSLSocketFactory extend
final HttpHost host = new HttpHost("localhost", 443, "https");
final HttpContext context = new BasicHttpContext();
final TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
- final SSLSocketFactory socketFactory = new SSLSocketFactory(clientSSLContext, hostVerifier);
+ final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(clientSSLContext, hostVerifier);
SSLSocket socket = (SSLSocket) socketFactory.createSocket(context);
final InetSocketAddress remoteAddress = this.localServer.getServiceAddress();
socket = (SSLSocket) socketFactory.connectSocket(0, socket, host, remoteAddress, null, context);
@@ -183,7 +184,7 @@ public class TestSSLSocketFactory extend
final HttpHost host = new HttpHost("localhost", 443, "https");
final HttpContext context = new BasicHttpContext();
final TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
- final SSLSocketFactory socketFactory = new SSLSocketFactory(clientSSLContext, hostVerifier);
+ final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(clientSSLContext, hostVerifier);
SSLSocket socket = (SSLSocket) socketFactory.createSocket(context);
final InetSocketAddress remoteAddress = this.localServer.getServiceAddress();
socket = (SSLSocket) socketFactory.connectSocket(0, socket, host, remoteAddress, null, context);
@@ -225,7 +226,7 @@ public class TestSSLSocketFactory extend
final HttpHost host = new HttpHost("localhost", 443, "https");
final HttpContext context = new BasicHttpContext();
final TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
- final SSLSocketFactory socketFactory = new SSLSocketFactory(clientSSLContext, hostVerifier);
+ final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(clientSSLContext, hostVerifier);
SSLSocket socket = (SSLSocket) socketFactory.createSocket(context);
final InetSocketAddress remoteAddress = this.localServer.getServiceAddress();
socket = (SSLSocket) socketFactory.connectSocket(0, socket, host, remoteAddress, null, context);
@@ -256,8 +257,8 @@ public class TestSSLSocketFactory extend
// Use default SSL context
final SSLContext defaultsslcontext = SSLContexts.createDefault();
- final SSLSocketFactory socketFactory = new SSLSocketFactory(defaultsslcontext,
- SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(defaultsslcontext,
+ SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
final SSLSocket socket = (SSLSocket) socketFactory.createSocket(context);
final InetSocketAddress remoteAddress = this.localServer.getServiceAddress();
@@ -290,9 +291,9 @@ public class TestSSLSocketFactory extend
final SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(null, trustStrategy)
.build();
- final SSLSocketFactory socketFactory = new SSLSocketFactory(
+ final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
sslcontext,
- SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
final SSLSocket socket = (SSLSocket) socketFactory.createSocket(context);
final InetSocketAddress remoteAddress = this.localServer.getServiceAddress();
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java?rev=1507677&r1=1507676&r2=1507677&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java Sat Jul 27 15:59:36 2013
@@ -51,7 +51,7 @@ import org.apache.http.conn.ConnectionRe
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.localserver.LocalServerTestBase;
import org.apache.http.message.BasicHttpRequest;
@@ -436,7 +436,7 @@ public class TestConnectionManagement ex
public void testAbortDuringConnecting() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
- connectLatch, WaitPolicy.BEFORE_CONNECT, PlainSocketFactory.getSocketFactory());
+ connectLatch, WaitPolicy.BEFORE_CONNECT, PlainConnectionSocketFactory.getSocketFactory());
final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", stallingSocketFactory)
.build();
@@ -491,7 +491,7 @@ public class TestConnectionManagement ex
public void testAbortBeforeSocketCreate() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
- connectLatch, WaitPolicy.BEFORE_CREATE, PlainSocketFactory.getSocketFactory());
+ connectLatch, WaitPolicy.BEFORE_CREATE, PlainConnectionSocketFactory.getSocketFactory());
final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", stallingSocketFactory)
.build();
@@ -547,7 +547,7 @@ public class TestConnectionManagement ex
public void testAbortAfterSocketConnect() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
- connectLatch, WaitPolicy.AFTER_CONNECT, PlainSocketFactory.getSocketFactory());
+ connectLatch, WaitPolicy.AFTER_CONNECT, PlainConnectionSocketFactory.getSocketFactory());
final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", stallingSocketFactory)
.build();