return url.substring(0, url.indexOf("/card/search/") + 19);
}
private static HttpClient getHttpClient(String url, Integer connectionTimeout, Integer soTimeout) throws NoSuchAlgorithmException, KeyManagementException
{
Scheme httpsScheme = null;
if (url.startsWith("https"))
{
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers()
{
return null;
}
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException
{
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException
{
}
}}, new SecureRandom());
SSLSocketFactory sf = new SSLSocketFactory(sslContext, new AllowAllHostnameVerifier());
httpsScheme = new Scheme("https", 443, sf);
}
else
httpsScheme = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
HttpParams params = getHttpParams(connectionTimeout, soTimeout);
ClientConnectionManager cm = new ThreadSafeClientConnManager(schemeRegistry);
return new DefaultHttpClient(cm, params);