Examples of Scheme


Examples of org.apache.http.conn.scheme.Scheme

    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);
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

    return map;
  }

  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);
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

    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);
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

                }
                try {
                    final SSLSocketFactory socketFactory = new SSLSocketFactory(
                        sslContextParameters.createSSLContext(),
                        SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
                    schemeRegistry.register(new Scheme("https", socketFactory, 443));
                } catch (GeneralSecurityException e) {
                    throw ObjectHelper.wrapRuntimeCamelException(e);
                } catch (IOException e) {
                    throw ObjectHelper.wrapRuntimeCamelException(e);
                }
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

  private HttpClient httpClient;

  public SparkTestUtil(int port) {
    this.port = port;
    Scheme http = new Scheme("http", port, PlainSocketFactory.getSocketFactory());
    Scheme https = new Scheme("https", port, new org.apache.http.conn.ssl.SSLSocketFactory(getSslFactory(), null));
    SchemeRegistry sr = new SchemeRegistry();
    sr.register(http);
    sr.register(https);
    ClientConnectionManager connMrg = new BasicClientConnectionManager(sr);
    this.httpClient = new DefaultHttpClient(connMrg);
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

      } catch (GeneralSecurityException e) {
        throw new IllegalArgumentException("Error building SSL client", e);
      }

      SchemeRegistry schemeRegistry = new SchemeRegistry();
      schemeRegistry.register(new Scheme("https", 443, schemeSocketFactory));

      connectionManager = buildConnectionManager(schemeRegistry);
    } else {
      SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault();
      connectionManager = buildConnectionManager(schemeRegistry);
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

            CookieSpecParamBean cookieParams = new CookieSpecParamBean(params);
            cookieParams.setSingleHeader(true);

            // Create and initialize scheme registry
            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
            SSLSocketFactory sf = null;

            for (String contextName : SSL_CONTEXT_NAMES) {
                try {
                    SSLContext sslContext = SSLContext.getInstance(contextName);
                    sslContext.init(null, new TrustManager[] { new DummyX509TrustManager(null) }, null);
                    sf = new SSLSocketFactory(sslContext);
                    break;
                } catch (NoSuchAlgorithmException e) {
                    LOGGER.debug("SSLContext algorithm not available: " + contextName);
                } catch (Exception e) {
                    LOGGER.debug("SSLContext can't be initialized: " + contextName, e);
                }
            }
           
            if (sf != null) {
                sf.setHostnameVerifier(new DummyX509HostnameVerifier());
                schemeRegistry.register(new Scheme("https", sf, 443));
            } else {
                LOGGER.warn("No valid SSLContext found for https");
            }

            // Use ThreadSafeClientConnManager since more than one thread will be using the HttpClient.
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

    } catch (GeneralSecurityException e) {
      throw new IllegalArgumentException("Error building SSL client", e);
    }

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("https", port, schemeSocketFactory));

    PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry);

    HttpClient httpClient = new DefaultHttpClient(connectionManager);
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

    paramsBean.setVersion(HttpVersion.HTTP_1_1);
    paramsBean.setContentCharset("UTF-8");
    paramsBean.setUseExpectContinue(false);
   
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));

    if (config.isIncludeHttpsPages())
      schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

    connectionManager = new ThreadSafeClientConnManager(schemeRegistry);
    connectionManager.setMaxTotal(config.getMaxTotalConnections());
    connectionManager.setDefaultMaxPerRoute(config.getMaxConnectionsPerHost());
    httpClient = new DefaultHttpClient(connectionManager, params);
View Full Code Here

Examples of org.apache.http.conn.scheme.Scheme

    public static Scheme getMockedScheme() throws NoSuchAlgorithmException, KeyManagementException {
  SSLContext sslcontext = SSLContext.getInstance("TLS");

  sslcontext.init(null, new TrustManager[] { new DummyX509TrustManager() }, null);
  SSLSocketFactory sf = new SSLSocketFactory(sslcontext);
  Scheme https = new Scheme("https", 443, sf);

  return https;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.