Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.ProxyClient


            throw new ProtocolException("Incorrect parameters to build tunnel.");  
        }
        logger.debug("Creating socket for Proxy : " + proxyAddress.getAddress() + ":" + proxyAddress.getPort());
        Socket socket;
        try {
            ProxyClient client = new ProxyClient();
            client.getParams().setParameter("http.useragent", "java-apns");
            client.getHostConfiguration().setHost(host, port);
            String proxyHost = proxyAddress.getAddress().toString().substring(0, proxyAddress.getAddress().toString().indexOf("/"));
            client.getHostConfiguration().setProxy(proxyHost, proxyAddress.getPort());
           
       
            ProxyClient.ConnectResponse response = client.connect();
            socket = response.getSocket();
            if (socket == null) {
                ConnectMethod method = response.getConnectMethod();
                // Read the proxy's HTTP response.
                if(method.getStatusLine().toString().matches("HTTP/1\\.\\d 407 Proxy Authentication Required")) {
View Full Code Here


*/
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {
       
        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        //
        // Note:  By default port 80 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new AuthScope("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                // go ahead and do an HTTP GET using the socket
View Full Code Here

*/
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {
       
        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        //
        // Note:  By default port 80 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new AuthScope("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                // go ahead and do an HTTP GET using the socket
View Full Code Here

    @Override
    public Socket createSocket() throws IOException {
        //FIXME won't work..
        log.debug("Creating socket! with proxy: " + proxy.address());
        InetSocketAddress addr = (InetSocketAddress) proxy.address();
        ProxyClient proxyClient = new ProxyClient();
        proxyClient.getHostConfiguration().setHost("imap.gmail.com", 993);
        proxyClient.getHostConfiguration().setProxy(addr.getHostName(),
                addr.getPort());
        if (proxyCredentials != null) {
            proxyClient.getState().setProxyCredentials(
                    AuthScope.ANY,
                    new UsernamePasswordCredentials(proxyCredentials.getUsername(),
                        new String(proxyCredentials.getPasword())));
        }
        log.debug("Trying to connect to proxy");
        ProxyClient.ConnectResponse resp = proxyClient.connect();
        if (resp.getConnectMethod().getStatusCode() != HttpStatus.SC_OK) {
            log.error("Failed to connect. " + resp.getConnectMethod().getStatusLine());
            throw new GmailException("Failed connecting to IMAP through proxy: "
                    + resp.getConnectMethod().getStatusLine());
        }
View Full Code Here

*/
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {
       
        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        //
        // Note:  By default port 80 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new AuthScope("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                // go ahead and do an HTTP GET using the socket
View Full Code Here

*/
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {
       
        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        //
        // Note:  By default port 80 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new HttpAuthRealm("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                // go ahead and do an HTTP GET using the socket
View Full Code Here

*/
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {
       
        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        //
        // Note:  By default port 80 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new AuthScope("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                // go ahead and do an HTTP GET using the socket
View Full Code Here

*/
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {
       
        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        //
        // Note:  By default port 80 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new AuthScope("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                // go ahead and do an HTTP GET using the socket
View Full Code Here

*/
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {
       
        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        //
        // Note:  By default port 80 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new AuthScope("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                // go ahead and do an HTTP GET using the socket
View Full Code Here

    @Override
    public Socket createSocket() throws IOException {
        //FIXME won't work..
        log.debug("Creating socket! with proxy: " + proxy.address());
        InetSocketAddress addr = (InetSocketAddress) proxy.address();
        ProxyClient proxyClient = new ProxyClient();
        proxyClient.getHostConfiguration().setHost("imap.gmail.com", 993);
        proxyClient.getHostConfiguration().setProxy(addr.getHostName(),
                addr.getPort());
        if (proxyCredentials != null) {
            proxyClient.getState().setProxyCredentials(
                    AuthScope.ANY,
                    new UsernamePasswordCredentials(proxyCredentials.getUsername(),
                        new String(proxyCredentials.getPasword())));
        }
        log.debug("Trying to connect to proxy");
        ProxyClient.ConnectResponse resp = proxyClient.connect();
        if (resp.getConnectMethod().getStatusCode() != HttpStatus.SC_OK) {
            log.error("Failed to connect. " + resp.getConnectMethod().getStatusLine());
            throw new GmailException("Failed connecting to IMAP through proxy: "
                    + resp.getConnectMethod().getStatusLine());
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.ProxyClient

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.