Package java.net

Examples of java.net.Proxy


     * Client Side Policy.
     *
     * @return The proxy server or null, if not set.
     */
    private Proxy getProxy(HTTPClientPolicy policy) {
        Proxy proxy = null;
        if (policy != null
            && policy.isSetProxyServer()
            && !StringUtils.isEmpty(policy.getProxyServer())) {
            proxy = new Proxy(
                    Proxy.Type.valueOf(policy.getProxyServerType().toString()),
                    new InetSocketAddress(policy.getProxyServer(),
                                          policy.getProxyServerPort()));
        }
        return proxy;
View Full Code Here


    /**
     * Construct a new {@code Proxy} instance from the given policy.
     */
    private Proxy createProxy(final HTTPClientPolicy policy) {
        return new Proxy(Proxy.Type.valueOf(policy.getProxyServerType().toString()),
                         new InetSocketAddress(policy.getProxyServer(),
                                               policy.getProxyServerPort()));
    }
View Full Code Here

     * Client Side Policy.
     *
     * @return The proxy server or null, if not set.
     */
    private Proxy getProxy(HTTPClientPolicy policy) {
        Proxy proxy = null;
        if (policy != null && policy.isSetProxyServer()) {
            proxy = new Proxy(
                    Proxy.Type.valueOf(policy.getProxyServerType().toString()),
                    new InetSocketAddress(policy.getProxyServer(),
                                          policy.getProxyServerPort()));
        }
        return proxy;
View Full Code Here

        HttpURLConnection connection = null;
        ClientConfig config = request.getAttribute(ClientConfig.class);

        // setup proxy
        if (config.getProxyHost() != null) {
            Proxy proxy =
                new Proxy(Proxy.Type.HTTP, new InetSocketAddress(config.getProxyHost(), config
                    .getProxyPort()));
            connection = (HttpURLConnection)url.openConnection(proxy);
        } else {
            connection = (HttpURLConnection)url.openConnection();
        }
View Full Code Here

            UnknownHostException {
        String socksHost = System.getProperty("socksProxyHost");
        Socket s;
        InetSocketAddress addr = new InetSocketAddress(host, port);
        if (socksHost != null) {
            Proxy proxy = new Proxy(Type.SOCKS, new InetSocketAddress(
                    socksHost, 1080));
            s = new Socket(proxy);
            s.connect(addr);
        } else {
            log.error(addr);
View Full Code Here

  final HttpURLConnection httpOpen(URL u) throws IOException {
    return httpOpen(METHOD_GET, u);
  }

  final HttpURLConnection httpOpen(String method, URL u) throws IOException {
    final Proxy proxy = HttpSupport.proxyFor(proxySelector, u);
    HttpURLConnection conn = (HttpURLConnection) u.openConnection(proxy);

    if (!http.sslVerify && "https".equals(u.getProtocol())) {
      disableSslVerify(conn);
    }
View Full Code Here

    HttpMethod httpMethod;
    String methodType = request.getMethod();
    String requestUri = request.getUri().toString();

    // Select a proxy based on the URI. May be Proxy.NO_PROXY
    Proxy proxy = ProxySelector.getDefault().select(request.getUri().toJavaUri()).get(0);

    if (proxy != Proxy.NO_PROXY) {
      InetSocketAddress address = (InetSocketAddress) proxy.address();
      httpClient.getHostConfiguration().setProxy(address.getHostName(), address.getPort());
    }

    if ("POST".equals(methodType) || "PUT".equals(methodType)) {
      EntityEnclosingMethod enclosingMethod = ("POST".equals(methodType))
View Full Code Here

            });
        }

        if (proxy != null) {
            Proxy thisProxy = new Proxy(proxy.getProxyType(), new InetSocketAddress(proxy.getProxyHost(), proxy.getProxyPort()));
            conn = new URL(url).openConnection(thisProxy);
        } else {
            conn = new URL(url).openConnection();
        }
View Full Code Here

    return errorCode;
  }
  //TODO pobierac serwery proxy z innej strony
  private URLConnection getConnection(URL url, int proxyNum) throws Exception{
    SocketAddress addr = null;
    Proxy proxy = null;
   
    switch (proxyNum) {
    case 0:
      System.out.println("Get default gateway");
      return url.openConnection();
    case 1:  
      System.out.println("Get 91.204.161.125 gateway");
      addr = new InetSocketAddress("91.204.161.125", 80);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy)
    case 2:  
      System.out.println("Get 203.160.1.75 gateway");
      addr = new InetSocketAddress("203.160.1.75", 80);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy)
    case 3:  
      System.out.println("Get 212.95.49.87 gateway");
      addr = new InetSocketAddress("212.95.49.87", 80);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy);
    case 4:  
      System.out.println("Get 193.173.119.83 gateway");
      addr = new InetSocketAddress("193.173.119.83", 8080);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy);
    case 5:  
      System.out.println("Get 159.148.82.3 gateway");
      addr = new InetSocketAddress("159.148.82.3", 3128);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy);
    case 6:
      System.out.println("Get 194.44.170.81 gateway");
      addr = new InetSocketAddress("194.44.170.81", 3128);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy);
    default:
      System.out.println("No another gateway");
      return null;
    }
View Full Code Here

    return errorCode;
  }
  //TODO pobierac serwery proxy z innej strony
  private URLConnection getConnection(URL url, int proxyNum) throws Exception{
    SocketAddress addr = null;
    Proxy proxy = null;
   
    switch (proxyNum) {
    case 0:
      System.out.println("Get default gateway");
      return url.openConnection();
    case 1:  
      System.out.println("Get 91.204.161.125 gateway");
      addr = new InetSocketAddress("91.204.161.125", 80);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy)
    case 2:  
      System.out.println("Get 203.160.1.75 gateway");
      addr = new InetSocketAddress("203.160.1.75", 80);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy)
    case 3:  
      System.out.println("Get 212.95.49.87 gateway");
      addr = new InetSocketAddress("212.95.49.87", 80);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy);
    case 4:  
      System.out.println("Get 193.173.119.83 gateway");
      addr = new InetSocketAddress("193.173.119.83", 8080);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy);
    case 5:  
      System.out.println("Get 159.148.82.3 gateway");
      addr = new InetSocketAddress("159.148.82.3", 3128);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy);
    case 6:
      System.out.println("Get 194.44.170.81 gateway");
      addr = new InetSocketAddress("194.44.170.81", 3128);
      proxy = new Proxy(Proxy.Type.HTTP, addr);
      return url.openConnection(proxy);
    default:
      System.out.println("No another gateway");
      return null;
    }
View Full Code Here

TOP

Related Classes of java.net.Proxy

Copyright © 2018 www.massapicom. 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.