11package com .taskadapter .redmineapi .internal .comm ;
22
3- import java .io .IOException ;
4- import java .security .KeyManagementException ;
5- import java .security .KeyStore ;
6- import java .security .KeyStoreException ;
7- import java .security .NoSuchAlgorithmException ;
8- import java .security .UnrecoverableKeyException ;
9- import java .security .cert .CertificateException ;
10-
3+ import com .taskadapter .redmineapi .RedmineConfigurationException ;
4+ import com .taskadapter .redmineapi .internal .comm .naivessl .NaiveSSLFactory ;
115import org .apache .http .Header ;
126import org .apache .http .HttpEntity ;
137import org .apache .http .HttpHost ;
2014import org .apache .http .conn .scheme .SchemeRegistry ;
2115import org .apache .http .conn .ssl .SSLSocketFactory ;
2216import org .apache .http .impl .client .DefaultHttpClient ;
17+ import org .apache .http .impl .conn .PoolingClientConnectionManager ;
2318import org .apache .http .impl .conn .tsccm .ThreadSafeClientConnManager ;
2419import org .apache .http .params .BasicHttpParams ;
2520import org .apache .http .params .HttpParams ;
2621import org .apache .http .params .HttpProtocolParams ;
2722import org .apache .http .protocol .HTTP ;
2823import org .apache .http .util .EntityUtils ;
29- import com .taskadapter .redmineapi .RedmineConfigurationException ;
24+
25+ import java .io .IOException ;
26+ import java .security .KeyManagementException ;
27+ import java .security .KeyStoreException ;
28+ import java .security .NoSuchAlgorithmException ;
29+ import java .security .UnrecoverableKeyException ;
30+ import java .security .cert .CertificateException ;
3031
3132class HttpUtil {
3233 public static DefaultHttpClient getNewHttpClient (
@@ -46,26 +47,20 @@ public static DefaultHttpClient getNewHttpClient(
4647 }
4748 }
4849
49- @ SuppressWarnings ("deprecation" )
50- static ThreadSafeClientConnManager createConnectionManager (
50+ static PoolingClientConnectionManager createConnectionManager (
5151 int maxConnections ) throws KeyStoreException ,
5252 NoSuchAlgorithmException , CertificateException , IOException ,
5353 KeyManagementException , UnrecoverableKeyException {
54- KeyStore trustStore = KeyStore .getInstance (KeyStore .getDefaultType ());
55- trustStore .load (null , null );
56- SSLSocketFactory sf = new FakeSSLSocketFactory (trustStore );
57- sf .setHostnameVerifier (SSLSocketFactory .ALLOW_ALL_HOSTNAME_VERIFIER );
54+ SSLSocketFactory factory = NaiveSSLFactory .createNaiveSSLSocketFactory ();
5855
59- SchemeRegistry registry = new SchemeRegistry ();
60- registry .register (new Scheme ("http" , 80 , PlainSocketFactory
61- .getSocketFactory ()));
62- registry .register (new Scheme ("https" , 443 , sf ));
56+ SchemeRegistry registry = new SchemeRegistry ();
57+ registry .register (new Scheme ("http" , 80 , PlainSocketFactory .getSocketFactory ()));
58+ registry .register (new Scheme ("https" , 443 , factory ));
6359
64- ThreadSafeClientConnManager ccm = new ThreadSafeClientConnManager (
65- registry );
66- ccm .setMaxTotal (maxConnections );
67- ccm .setDefaultMaxPerRoute (maxConnections );
68- return ccm ;
60+ PoolingClientConnectionManager manager = new PoolingClientConnectionManager (registry );
61+ manager .setMaxTotal (maxConnections );
62+ manager .setDefaultMaxPerRoute (maxConnections );
63+ return manager ;
6964 }
7065
7166 private static void configureProxy (DefaultHttpClient httpclient ) {
0 commit comments