Package java.net

Examples of java.net.Proxy


   * @param host
   * @param proxyType
   * @return proxy or null if it cannot be resolved
   */
  public static Proxy getProxy(String host, String proxyType) {
    Proxy foundProxy = null;
    try {

      URI uri = new URI(proxyType, "//" + host, null);
      List<Proxy> proxies = ProxySelector.getDefault().select(uri);

View Full Code Here


    this.url = url;
    this.requestMethod = method;
  }

  private Proxy createProxy() {
    return new Proxy(HTTP, new InetSocketAddress(httpProxyHost, httpProxyPort));
  }
View Full Code Here

    public Socket createSocket(final String host, final int port, final InetAddress localAddress, final int localPort, final HttpConnectionParams params)
            throws IOException, UnknownHostException, ConnectTimeoutException {

        InetSocketAddress socksAddr = new InetSocketAddress(socksHost, socksPort);
        Proxy proxy = new Proxy(Proxy.Type.SOCKS, socksAddr);
        int timeout = params.getConnectionTimeout();

        Socket socket = new Socket(proxy);
        socket.setSoTimeout(timeout);
View Full Code Here

     * @param host  the hostname of the SOCKS proxy
     * @param port  the port of the SOCKS proxy server
     * @return  this
     */
    public ApnsServiceBuilder withSocksProxy(String host, int port) {
        Proxy proxy = new Proxy(Proxy.Type.SOCKS,
                new InetSocketAddress(host, port));
        return withProxy(proxy);
    }
View Full Code Here

     * @param proxySocket   the underlying socket for connections
     * @return  this
     */
    @Deprecated
    public ApnsServiceBuilder withProxySocket(Socket proxySocket) {
        return this.withProxy(new Proxy(Proxy.Type.SOCKS,
                proxySocket.getRemoteSocketAddress()));
    }
View Full Code Here

    deleteItem(aptCache);
  }

  private String testProxy(InetSocketAddress proxySocketAddress, String fetchUrl) throws IOException {
    Proxy proxy = new Proxy(Proxy.Type.HTTP, proxySocketAddress);
    URL url = new URL(fetchUrl);
    HttpURLConnection uc = (HttpURLConnection) url.openConnection(proxy);
    uc.connect();

    InputStream is = uc.getInputStream();
View Full Code Here

            } finally {
                s.close();
            }
            if (proxyAddr != null) {
                SocketAddress sa = new InetSocketAddress(proxyAddr, proxyPort);
                setProxy(new Proxy(Type.HTTP, sa));
            }
        }
    }
View Full Code Here

      int portNum = 80;
      if (proxyPort != null && proxyPort.length() > 0) {
        portNum = Integer.parseInt(proxyPort);
      }
      InetSocketAddress sa = new InetSocketAddress(proxyHost, portNum);
      setProxy(new Proxy(Proxy.Type.HTTP, sa));
    }
   
    // check for authentication
    String proxyUserName = System.getProperty("http.proxyUser");
    String proxyPassword = System.getProperty("http.proxyPassword");
View Full Code Here

        return false;
    }

    public Socket createSocket(HttpParams params) throws IOException {
        InetSocketAddress socksaddr = new InetSocketAddress(proxyHost, proxyPort);
        Proxy proxy = new Proxy(Proxy.Type.SOCKS, socksaddr);
        Socket sock = new Socket(proxy);
        return sock;
    }
View Full Code Here

    String host = connection.getHost();
    int port = connection.getPort();
    TSocket trans;
    Socket socket;
    if (connection.isProxy()) {
      Proxy proxy = new Proxy(Type.SOCKS, new InetSocketAddress(connection.getProxyHost(), connection.getProxyPort()));
      socket = new Socket(proxy);
    } else {
      socket = new Socket();
    }
    int timeout = connection.getTimeout();
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.