Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.ProxyHost


            httpClientGatekeeper = initHttpConnection();
        }
       
        // Try to detect any necessary proxy configurations.
        try {
            ProxyHost proxyHost = PluginProxyUtil.detectProxy(new URL(gatekeeperUrl));
            if (proxyHost != null) {
                HostConfiguration hostConfig = new HostConfiguration();
                hostConfig.setProxyHost(proxyHost);
                httpClientGatekeeper.setHostConfiguration(hostConfig);
               
View Full Code Here


            httpClientGatekeeper = initHttpConnection();
        }
       
        // Try to detect any necessary proxy configurations.
        try {
            ProxyHost proxyHost = PluginProxyUtil.detectProxy(new URL(gatekeeperUrl));
            if (proxyHost != null) {
                HostConfiguration hostConfig = new HostConfiguration();
                hostConfig.setProxyHost(proxyHost);
                httpClientGatekeeper.setHostConfiguration(hostConfig);
            }
View Full Code Here

            hostConfig.setProxy(proxyHostAddress, proxyPort);
        }
        // If no explicit settings are available, try autodetecting proxies (unless autodetect is disabled)
        else if (proxyAutodetect) {       
            // Try to detect any proxy settings from applet.
            ProxyHost proxyHost = null;
            try {           
                proxyHost = PluginProxyUtil.detectProxy(new URL("http://" + Constants.S3_HOSTNAME));
                if (proxyHost != null) {
                    log.info("Using Proxy: " + proxyHost.getHostName() + ":" + proxyHost.getPort());
                    hostConfig.setProxyHost(proxyHost);
                }               
            } catch (Throwable t) {
                log.debug("Unable to set proxy configuration", t);
            }       
View Full Code Here

            httpClientGatekeeper = initHttpConnection();
        }
       
        // Try to detect any necessary proxy configurations.
        try {
            ProxyHost proxyHost = PluginProxyUtil.detectProxy(new URL(gatekeeperUrl));
            if (proxyHost != null) {
                HostConfiguration hostConfig = new HostConfiguration();
                hostConfig.setProxyHost(proxyHost);
                httpClientGatekeeper.setHostConfiguration(hostConfig);
               
View Full Code Here

        if (!urlString.startsWith("http://")) {
            urlString = "http://" + urlString;
        }
        try {
            URL url = new URL(urlString);
            ProxyHost hostInfo = PluginProxyUtil.detectProxy(url);
            if (hostInfo != null) {
                hostLabel.setText(hostInfo.getHostName());
                portLabel.setText(""+hostInfo.getPort());
            } else {
                hostLabel.setText("none");
                portLabel.setText("none");
            }
            grid.validate();
View Full Code Here

   
    public String getProxyHost(String urlString) {
        String result = urlString;
        try {
            URL url = new URL(urlString);
            ProxyHost hostInfo = PluginProxyUtil.detectProxy(url);
            if (hostInfo != null) {
                result = hostInfo.getHostName();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
View Full Code Here

    public int getProxyPort(String urlString) {
        int result = 80;
        try {
            URL url = new URL(urlString);
            ProxyHost hostInfo = PluginProxyUtil.detectProxy(url);
            if (hostInfo != null) {
                result = hostInfo.getPort();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
View Full Code Here

            httpClientGatekeeper = initHttpConnection();
        }
       
        // Try to detect any necessary proxy configurations.
        try {
            ProxyHost proxyHost = PluginProxyUtil.detectProxy(new URL(gatekeeperUrl));
            if (proxyHost != null) {
                HostConfiguration hostConfig = new HostConfiguration();
                hostConfig.setProxyHost(proxyHost);
                httpClientGatekeeper.setHostConfiguration(hostConfig);
               
View Full Code Here

     */
    public static ProxyHost detectProxy(URL sampleURL)
        throws ProxyDetectionException
    {
       
        ProxyHost result = null;
        String javaVers = System.getProperty("java.runtime.version");
       
        if (LOG.isDebugEnabled()) {
            LOG.debug("About to attempt auto proxy detection under Java " +
                      "version:"+javaVers);
View Full Code Here

     * @throws ProxyDetectionException if detection failed
     */
    private static ProxyHost detectProxySettingsJDK13(URL sampleURL)
        throws ProxyDetectionException
    {
        ProxyHost result = null;
        try {
            // Attempt to discover proxy info by asking internal plugin
            // code to locate proxy path to server sampleURL...
            Class pluginProxyHandler =
                Class.forName("sun.plugin.protocol.PluginProxyHandler");
            Method getDefaultProxyHandlerMethod =
                pluginProxyHandler.getDeclaredMethod("getDefaultProxyHandler",
                                                     null);
            Object proxyHandlerObj =
                getDefaultProxyHandlerMethod.invoke(null, null);
            if (proxyHandlerObj != null) {
                Class proxyHandlerClass = proxyHandlerObj.getClass();
                Method getProxyInfoMethod =
                    proxyHandlerClass.getDeclaredMethod("getProxyInfo",
                                                        new Class[]{URL.class});
                Object proxyInfoObject =
                    getProxyInfoMethod.invoke(proxyHandlerObj,
                                              new Object[] { sampleURL });
                if (proxyInfoObject != null) {
                    Class proxyInfoClass = proxyInfoObject.getClass();
                    Method getProxyMethod =
                        proxyInfoClass.getDeclaredMethod("getProxy", null);
                    boolean useProxy =
                        (getProxyMethod.invoke(proxyInfoObject, null) != null);
                    if (useProxy) {
                        String proxyIP =
                            (String)getProxyMethod.invoke(proxyInfoObject, null);
                        Method getProxyPortMethod =
                            proxyInfoClass.getDeclaredMethod("getPort", null);
                        Integer portInteger =
                            (Integer)getProxyPortMethod.invoke(proxyInfoObject, null);
                        int proxyPort = portInteger.intValue();
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("1.3.X: proxy=" + proxyIP+
                                      " port=" + proxyPort);
                        }
                        result = new ProxyHost(proxyIP, proxyPort);
                    } else {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("1.3.X reported NULL for " +
                                      "proxyInfo.getProxy (no proxy assumed)");
                        }
View Full Code Here

TOP

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

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.