You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2005/07/19 23:11:11 UTC

svn commit: r219775 - in /jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy: ./ PluginProxyTest.html PluginProxyTestApplet.java PluginProxyUtil.java ProxyDetectionException.java

Author: olegk
Date: Tue Jul 19 14:11:09 2005
New Revision: 219775

URL: http://svn.apache.org/viewcvs?rev=219775&view=rev
Log:
A utility class that gives applets the ability to detect proxy host settings.
This was adapted from a post from Chris Forster on 20030227 to a Sun Java 
forum here:
http://forum.java.sun.com/thread.jspa?threadID=364342&tstart=120

Contributed by Rob Manning <manningr at spamcop.net>

Added:
    jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/
    jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTest.html   (with props)
    jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java   (with props)
    jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java   (with props)
    jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java   (with props)

Added: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTest.html
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTest.html?rev=219775&view=auto
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTest.html (added)
+++ jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTest.html Tue Jul 19 14:11:09 2005
@@ -0,0 +1,50 @@
+<html>
+<head><title>Java Plugin Proxy Detection Test Applet Page</title></head>
+<body bgcolor="#FFFFFF">
+<h1>Java Plugin Proxy Detection Test Applet Page</h1>
+
+<hr>
+
+<!--"CONVERTED_APPLET"-->
+<!-- HTML CONVERTER -->
+<OBJECT 
+    classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
+    codebase = "http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"
+    WIDTH = 300 HEIGHT = 200 >
+    <PARAM NAME = CODE VALUE = PluginProxyTestApplet >
+    <PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.4">
+    <PARAM NAME = "scriptable" VALUE = "false">
+    <PARAM NAME = "bogus" VALUE="just testing">
+
+    <COMMENT>
+	<EMBED 
+            type = "application/x-java-applet;version=1.4" \
+            CODE = PluginProxyTestApplet \
+            WIDTH = 300 \
+            HEIGHT = 200 \
+            bogus ="just testing" \
+	    scriptable = false \
+	    pluginspage = "http://java.sun.com/products/plugin/index.html#download">
+	    <NOEMBED>
+            
+            </NOEMBED>
+	</EMBED>
+    </COMMENT>
+</OBJECT>
+
+<!--
+<APPLET CODE = PluginProxyTestApplet WIDTH = 300 HEIGHT = 200>
+<PARAM NAME = "bogus" VALUE="just testing">
+
+
+</APPLET>
+-->
+
+
+<!--"END_CONVERTED_APPLET"-->
+
+
+<hr>
+
+</body>
+</html>
\ No newline at end of file

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTest.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTest.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java?rev=219775&view=auto
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java (added)
+++ jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java Tue Jul 19 14:11:09 2005
@@ -0,0 +1,193 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.commons.httpclient.contrib.proxy;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.FlowLayout;
+import java.awt.GridLayout;
+import java.awt.LayoutManager;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.URL;
+
+import javax.swing.JApplet;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.httpclient.ProxyHost;
+
+/**
+ * A description of this class goes here...
+ */
+
+public class PluginProxyTestApplet extends JApplet {
+
+    
+    private JTextField urlTextField = new JTextField();
+    private JPanel grid = null;
+    private JLabel hostLabel = null;
+    private JLabel portLabel = null;
+    
+    
+    public PluginProxyTestApplet() {
+        
+    }
+    
+    public void init() {
+        Container content = getContentPane();
+        content.setLayout(new BorderLayout());
+        
+        // Proxy info table
+        grid = getPanel(new GridLayout(2,3,2,2));
+        grid.add(getHeaderLabel("URL"));
+        grid.add(getHeaderLabel("Proxy Host"));
+        grid.add(getHeaderLabel("Proxy Port"));
+        grid.add(urlTextField);
+        hostLabel = getLabel("");
+        portLabel = getLabel("");
+        grid.add(hostLabel);
+        grid.add(portLabel);        
+        grid.validate();
+        content.add(grid, BorderLayout.CENTER);
+        
+        // Button panel - SOUTH
+        JPanel buttonPanel = getPanel(new FlowLayout());
+        JButton button = new JButton("Detect Proxy");
+        button.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                SwingUtilities.invokeLater(new Runnable() {
+                    public void run() {
+                        detectProxy();
+                    }
+                });
+            }
+        });
+        buttonPanel.add(button);
+        content.add(buttonPanel, BorderLayout.SOUTH);
+        
+        // version panel - NORTH
+        JPanel versionPanel = getPanel(new FlowLayout());
+        String javaVersion = System.getProperty("java.runtime.version");
+        JLabel versionLabel = getLabel("Java Version: "+javaVersion);
+        versionPanel.add(versionLabel);
+        content.add(versionPanel, BorderLayout.NORTH);
+        validate();
+        
+        super.setSize(400,100);
+    }
+    
+    private JPanel getPanel(LayoutManager layout) {
+        JPanel result = new JPanel(layout);
+        return result;
+    }
+    
+    private JLabel getHeaderLabel(String text) {
+        JLabel result = new JLabel("<html><u><b>" + text + "</b></u></html>");
+        result.setHorizontalAlignment(JLabel.CENTER);
+        return result;
+    }
+    
+    private JLabel getLabel(String text) {
+        JLabel result = new JLabel(text);
+        result.setHorizontalAlignment(JLabel.CENTER);
+        return result;
+    }
+    
+    private void detectProxy() {
+        String urlString = urlTextField.getText();
+        if (urlString == null || "".equals(urlString)) {
+            JOptionPane.showMessageDialog(super.getRootPane(),
+                                          "URL can't be empty", 
+                                          "Missing URL", 
+                                          JOptionPane.ERROR_MESSAGE); 
+            return;
+        }
+        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();
+        } catch (ProxyDetectionException e) { 
+            JOptionPane.showMessageDialog(getRootPane(), 
+                                          e.getMessage() ,
+                                          "Proxy Detection Failed", 
+                                          JOptionPane.ERROR_MESSAGE);
+            e.printStackTrace();
+        } catch (Exception e) {
+            JOptionPane.showMessageDialog(getRootPane(), 
+                    e.getMessage() ,
+                    "Unexpected Exception", 
+                    JOptionPane.ERROR_MESSAGE);            
+            e.printStackTrace();
+        }        
+    }
+    
+    private 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;
+    }
+
+    private 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;
+    }
+
+}

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java?rev=219775&view=auto
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java (added)
+++ jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java Tue Jul 19 14:11:09 2005
@@ -0,0 +1,322 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.commons.httpclient.contrib.proxy;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.httpclient.ProxyHost;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A utility class that gives applets the ability to detect proxy host settings.
+ * This was adapted from a post from Chris Forster on 20030227 to a Sun Java 
+ * forum here:
+ * http://forum.java.sun.com/thread.jspa?threadID=364342&tstart=120
+ * 
+ * The algorithm - which relies on Sun java plugin internal classes in some 
+ * cases - was maintained, but the following changes were made:
+ * 
+ * 1. Logging was used to allow control of debug type messages.
+ * 2. Reflection is used instead of direct references to Sun internal classes
+ *    to avoid the need to have these classes in the CLASSPATH to compile.
+ * 3. Removed the use of global variables to allow this class to be used in 
+ *    a multi-threaded environment.
+ * 4. Add the use of exception to indicate to the caller when proxy detection
+ *    failed as opposed to when no proxy is configured.
+ */
+public class PluginProxyUtil {
+    
+    /** Log object for this class */
+    private static final Log LOG = LogFactory.getLog(PluginProxyUtil.class);  
+    
+    /** 
+     * This is used internally to indicate that no proxy detection succeeded 
+     * and no proxy setting is to be used - failover is unnecessary
+     */
+    private static final ProxyHost NO_PROXY_HOST = new ProxyHost("",80);
+    
+    /**
+     * The system property that is used to convey proxy information in some VM's 
+     */
+    private static final String PLUGIN_PROXY_CONFIG_PROP = 
+                                                "javaplugin.proxy.config.list";
+    
+    /**
+     * Returns the Proxy Host information using settings from the java plugin.
+     * 
+     * @param sampleURL the url target for which proxy host information is
+     *                  required 
+     * @return the proxy host info (name and port) or null if a direct 
+     *         connection is allowed to the target url.  
+     * @throws ProxyDetectionException if detection failed
+     */
+    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);
+        }
+        
+        // If specific, known detection methods fail may try fallback 
+        // detection method
+        boolean invokeFailover = false; 
+     
+        if (javaVers.startsWith("1.3"))  {
+            result = detectProxySettingsJDK13(sampleURL);
+            if (result == null) {
+                invokeFailover = true;
+            }
+        } else if (javaVers.startsWith("1.4"))  {
+            result = detectProxySettingsJDK14(sampleURL);
+            if (result == null) {
+                invokeFailover = true;
+            }
+        } else if (javaVers.startsWith("1.5"))  {
+            invokeFailover = true;
+        } else {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Sun Plugin reported java version not 1.3.X, " +
+                          "1.4.X or 1.5.X - trying failover detection...");
+            }
+            invokeFailover = true;
+        }
+        if (invokeFailover) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Using failover proxy detection...");
+            }
+            result = getPluginProxyConfigSettings();
+        }
+        if (NO_PROXY_HOST.equals(result)) {
+            result = null;
+        }
+        return result;
+    }
+
+    /**
+     * Use Sun-specific internal plugin proxy classes for 1.3.X
+     * Look around for the 1.3.X plugin proxy detection class. Without it, 
+     * cannot autodetect...
+     * 
+     * @param sampleURL the URL to check proxy settings for
+     * @return ProxyHost the host and port of the proxy that should be used
+     * @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)");
+                        }
+                        result = NO_PROXY_HOST;                                            
+                    }
+                } else {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("NULL proxyInfo in 1.3.X auto proxy " +
+                                       "detection, (no proxy assumed)");
+                    }
+                    result = NO_PROXY_HOST;
+                }
+            } else {
+                throw new ProxyDetectionException(
+                  "Sun Plugin 1.3.X failed to provide a default proxy handler");
+            }
+        } catch (Exception e) {
+            LOG.warn("Sun Plugin 1.3.X proxy detection class not " +
+                     "found, will try failover detection, e:"+e);
+        }        
+        return result;
+    }
+    
+    /**
+     * Returns the proxy information for the specified sampleURL using JRE 1.4
+     * specific plugin classes.
+     * 
+     * Notes:
+     *     Plugin 1.4 Final added 
+     *     com.sun.java.browser.net.* classes ProxyInfo & ProxyService... 
+     *     Use those with JREs => 1.4
+     *
+     * @param sampleURL the URL to check proxy settings for
+     * @return ProxyHost the host and port of the proxy that should be used
+     */
+    private static ProxyHost detectProxySettingsJDK14(URL sampleURL) {
+        ProxyHost result = null;
+        try {
+            // Look around for the 1.4.X plugin proxy detection class... 
+            // Without it, cannot autodetect...
+            Class ProxyServiceClass = 
+                Class.forName("com.sun.java.browser.net.ProxyService");
+            Method getProxyInfoMethod = 
+                ProxyServiceClass.getDeclaredMethod("getProxyInfo", 
+                                                    new Class[] {URL.class});
+            Object proxyInfoArrayObj = 
+                getProxyInfoMethod.invoke(null, new Object[] {sampleURL});
+            if (proxyInfoArrayObj == null  
+                    || Array.getLength(proxyInfoArrayObj) == 0) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("1.4.X reported NULL proxy (no proxy assumed)");
+                }
+                result = NO_PROXY_HOST;                    
+            } else {
+                Object proxyInfoObject = Array.get(proxyInfoArrayObj, 0);
+                Class proxyInfoClass = proxyInfoObject.getClass();
+                Method getHostMethod = 
+                    proxyInfoClass.getDeclaredMethod("getHost",null);
+                String proxyIP = 
+                    (String)getHostMethod.invoke(proxyInfoObject, null);
+                Method getPortMethod = 
+                    proxyInfoClass.getDeclaredMethod("getPort",null);
+                Integer portInteger = 
+                    (Integer)getPortMethod.invoke(proxyInfoObject, null);
+                int proxyPort = portInteger.intValue(); 
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("1.4.X Proxy info geProxy:"+proxyIP+ 
+                              " get Port:"+proxyPort);
+                }
+                result = new ProxyHost(proxyIP, proxyPort);
+            }
+        } catch (Exception e) { 
+            LOG.warn("Sun Plugin 1.4.X proxy detection class not found, " +
+                     "will try failover detection, e:"+e);
+        }        
+        return result;
+    }
+    
+    /**
+     * Returns the proxy host information found by inspecting the system 
+     * property "javaplugin.proxy.config.list".
+     * 
+     * @return ProxyHost the host and port of the proxy that should be used
+     * @throws ProxyDetectionException if an exception is encountered while
+     *                                 parsing the value of 
+     *                                 PLUGIN_PROXY_CONFIG_PROP
+     */
+    private static ProxyHost getPluginProxyConfigSettings() 
+        throws ProxyDetectionException
+    {
+        ProxyHost result = null;
+        try {
+            Properties properties = System.getProperties();
+            String proxyList = 
+                properties.getProperty("javaplugin.proxy.config.list");
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Plugin Proxy Config List Property:"+proxyList);
+            }
+            boolean useProxy = (proxyList != null);
+            if (useProxy) {
+                proxyList = proxyList.toUpperCase();
+                //  Using HTTP proxy as proxy for HTTP proxy tunnelled SSL 
+                //  socket (should be listed FIRST)....
+                //  1/14/03 1.3.1_06 appears to omit HTTP portion of 
+                //  reported proxy list... Mod to accomodate this...
+                //  Expecting proxyList of "HTTP=XXX.XXX.XXX.XXX:Port" OR 
+                //  "XXX.XXX.XXX.XXX:Port" & assuming HTTP...
+                String proxyIP="";
+                if (proxyList.indexOf("HTTP=") > -1) {
+                    proxyIP = 
+                        proxyList.substring(proxyList.indexOf("HTTP=")+5, 
+                                            proxyList.indexOf(":"));
+                } else {
+                    proxyIP = proxyList.substring(0, proxyList.indexOf(":"));
+                }
+                int endOfPort = proxyList.indexOf(",");
+                if (endOfPort < 1) endOfPort = proxyList.length();
+                String portString = 
+                    proxyList.substring(proxyList.indexOf(":")+1,endOfPort);
+                int proxyPort = Integer.parseInt(portString);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("proxy " + proxyIP+" port " + proxyPort);
+                }
+                result = new ProxyHost(proxyIP, proxyPort);
+            } else {
+                LOG.debug("No configured plugin proxy list");
+                result = NO_PROXY_HOST;
+            }
+        } catch (Exception e) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Exception during failover auto proxy detection, " +
+                          ", e:"+e);
+                throw new ProxyDetectionException(
+                        "Encountered unexpected exception while attempting " +
+                        "to parse proxy information stored in "+
+                        PLUGIN_PROXY_CONFIG_PROP, e);
+            }
+        }
+        return result;
+    }    
+}

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java?rev=219775&view=auto
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java (added)
+++ jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java Tue Jul 19 14:11:09 2005
@@ -0,0 +1,69 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.commons.httpclient.contrib.proxy;
+
+import org.apache.commons.httpclient.util.ExceptionUtil;
+
+/**
+ * Signals a problem with auto-detecting the proxy information using the java
+ * plugin.
+ */
+public class ProxyDetectionException extends Exception {
+
+    /**
+     * Creates a new ProxyDetectionException with a <tt>null</tt> detail message. 
+     */
+    public ProxyDetectionException() {
+        super();
+    }
+
+    /**
+     * Creates a new ProxyDetectionException with the specified detail message.
+     * 
+     * @param message The exception detail message
+     */
+    public ProxyDetectionException(String message) {
+        super(message);
+    }
+
+    /**
+     * Creates a new ProxyDetectionException with the specified detail message 
+     * and cause.
+     * 
+     * @param message the exception detail message
+     * @param cause the <tt>Throwable</tt> that caused this exception, or 
+     *              <tt>null</tt> if the cause is unavailable, unknown, or not 
+     *              a <tt>Throwable</tt>
+     */
+    public ProxyDetectionException(String message, Throwable cause) {
+        super(message);
+		ExceptionUtil.initCause(this, cause);
+    }
+
+}

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org