You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2009/07/25 13:21:48 UTC

svn commit: r797750 - in /maven/plugins/trunk/maven-javadoc-plugin: ./ src/main/java/org/apache/maven/plugin/javadoc/ src/test/java/org/apache/maven/plugin/javadoc/ src/test/resources/unit/proxy-test/

Author: vsiveton
Date: Sat Jul 25 11:21:48 2009
New Revision: 797750

URL: http://svn.apache.org/viewvc?rev=797750&view=rev
Log:
MJAVADOC-238: No timeout set for URLConnection which can cause build to get stuck

o added more tests to test real proxy with Jetty
o note: using Jetty in tests implies an enforcer rule for jdk 1.5

Added:
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/ProxyServer.java   (with props)
Modified:
    maven/plugins/trunk/maven-javadoc-plugin/pom.xml
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml

Modified: maven/plugins/trunk/maven-javadoc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/pom.xml?rev=797750&r1=797749&r2=797750&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/pom.xml Sat Jul 25 11:21:48 2009
@@ -208,6 +208,18 @@
       <version>1.2</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <version>6.1.19</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty-client</artifactId>
+      <version>6.1.19</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
@@ -218,6 +230,12 @@
           <artifactId>modello-maven-plugin</artifactId>
           <version>1.0.2</version>
         </plugin>
+        <!-- only used for tests, extends Jetty classes need 1.5 -->
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-enforcer-plugin</artifactId>
+          <version>1.0-beta-1</version>
+        </plugin>
       </plugins>
     </pluginManagement>
     <plugins>
@@ -238,6 +256,27 @@
           </models>
         </configuration>
       </plugin>
+      <!-- only used for tests, extends Jetty classes need 1.5 -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>enforce-jdk</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <requireJavaVersion>
+                  <version>[1.5.0,]</version>
+                </requireJavaVersion>
+              </rules>
+              <fail>true</fail>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java?rev=797750&r1=797749&r2=797750&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java Sat Jul 25 11:21:48 2009
@@ -83,6 +83,9 @@
  */
 public class JavadocUtil
 {
+    /** The default timeout used when fetching url, i.e. 2000. */
+    public static int DEFAULT_TIMEOUT = 2000;
+
     /**
      * Method that removes the invalid directories in the specified directories.
      * <b>Note</b>: All elements in <code>dirs</code> could be an absolute or relative against the project's base
@@ -711,6 +714,7 @@
      * @param settings the user settings used to fetch the url with an active proxy, if defined.
      * @param url the url to fetch
      * @throws IOException if any
+     * @see #DEFAULT_TIMEOUT
      */
     protected static void fetchURL( Settings settings, URL url )
         throws IOException
@@ -724,7 +728,8 @@
         if ( !"file".equals( url.getProtocol() ) )
         {
             httpClient = new HttpClient();
-            httpClient.getHttpConnectionManager().getParams().setConnectionTimeout( 1000 );
+            httpClient.getHttpConnectionManager().getParams().setConnectionTimeout( DEFAULT_TIMEOUT );
+            httpClient.getHttpConnectionManager().getParams().setSoTimeout( DEFAULT_TIMEOUT );
 
             if ( settings != null )
             {

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java?rev=797750&r1=797749&r2=797750&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java Sat Jul 25 11:21:48 2009
@@ -24,12 +24,17 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.Reader;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang.SystemUtils;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.javadoc.ProxyServer.AuthAsyncProxyServlet;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.settings.Proxy;
+import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
@@ -893,8 +898,22 @@
     public void testProxy()
         throws Exception
     {
+        Settings settings = new Settings();
+        Proxy proxy = new Proxy();
+
+        //dummy proxy
+        proxy.setActive( true );
+        proxy.setHost( "http://localhost" );
+        proxy.setPort( 80 );
+        proxy.setUsername( "toto" );
+        proxy.setPassword( "toto" );
+        proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
+        settings.addProxy( proxy );
+
         File testPom = new File( getBasedir(), "src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml" );
         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
+        assertNotNull( mojo );
+        setVariableValueToObject( mojo, "settings", settings );
         mojo.execute();
 
         File commandLine = new File( getBasedir(), "target/test/unit/proxy-test/target/site/apidocs/javadoc." + ( SystemUtils.IS_OS_WINDOWS ? "bat" : "sh" ) );
@@ -906,6 +925,98 @@
         assertTrue( readed.indexOf( "-J-Dhttp.proxyUser=\\\"toto\\\"" ) != -1 );
         assertTrue( readed.indexOf( "-J-Dhttp.proxyPassword=\\\"toto\\\"" ) != -1 );
         assertTrue( readed.indexOf( "-J-Dhttp.nonProxyHosts=\\\"www.google.com|*.somewhere.com\\\"" ) != -1 );
+
+        File options = new File( getBasedir(), "target/test/unit/proxy-test/target/site/apidocs/options" );
+        assertTrue( FileUtils.fileExists( options.getAbsolutePath() ) );
+        String optionsContent = readFile( options );
+        // NO -link http://java.sun.com/j2se/1.5.0/docs/api/package-list
+        assertTrue( optionsContent.indexOf( "-link" ) == -1 );
+
+        // real proxy
+        ProxyServer proxyServer = null;
+        AuthAsyncProxyServlet proxyServlet = null;
+        try
+        {
+            proxyServlet = new AuthAsyncProxyServlet();
+            proxyServer = new ProxyServer( proxyServlet );
+            proxyServer.start();
+
+            settings = new Settings();
+            proxy = new Proxy();
+            proxy.setActive( true );
+            proxy.setHost( proxyServer.getHostName() );
+            proxy.setPort( proxyServer.getPort() );
+            settings.addProxy( proxy );
+
+            mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
+            setVariableValueToObject( mojo, "settings", settings );
+            mojo.execute();
+            readed = readFile( commandLine );
+            assertTrue( readed.indexOf( "-J-Dhttp.proxySet=true" ) != -1 );
+            assertTrue( readed.indexOf( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) != -1 );
+            assertTrue( readed.indexOf( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) != -1 );
+
+            optionsContent = readFile( options );
+            // -link http://java.sun.com/j2se/1.5.0/docs/api/package-list
+            assertTrue( optionsContent.indexOf( "-link" ) != -1 );
+            assertTrue( true );
+        }
+        catch ( Exception e )
+        {
+            assertTrue( false );
+        }
+        finally
+        {
+            if ( proxyServer != null )
+            {
+                proxyServer.stop();
+            }
+        }
+
+        // auth proxy
+        Map authentications = new HashMap();
+        authentications.put( "foo", "bar" );
+        try
+        {
+            proxyServlet = new AuthAsyncProxyServlet();
+            proxyServer = new ProxyServer( proxyServlet );
+            proxyServer.start();
+
+            settings = new Settings();
+            proxy = new Proxy();
+            proxy.setActive( true );
+            proxy.setHost( proxyServer.getHostName() );
+            proxy.setPort( proxyServer.getPort() );
+            proxy.setUsername( "foo" );
+            proxy.setPassword( "bar" );
+            settings.addProxy( proxy );
+
+            mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
+            setVariableValueToObject( mojo, "settings", settings );
+            mojo.execute();
+            readed = readFile( commandLine );
+            assertTrue( readed.indexOf( "-J-Dhttp.proxySet=true" ) != -1 );
+            assertTrue( readed.indexOf( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) != -1 );
+            assertTrue( readed.indexOf( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) != -1 );
+            assertTrue( readed.indexOf( "-J-Dhttp.proxyUser=\\\"foo\\\"" ) != -1 );
+            assertTrue( readed.indexOf( "-J-Dhttp.proxyPassword=\\\"bar\\\"" ) != -1 );
+
+            optionsContent = readFile( options );
+            // -link http://java.sun.com/j2se/1.5.0/docs/api/package-list
+            assertTrue( optionsContent.indexOf( "-link" ) != -1 );
+            assertTrue( true );
+        }
+        catch ( Exception e )
+        {
+            assertTrue( false );
+        }
+        finally
+        {
+            if ( proxyServer != null )
+            {
+                proxyServer.stop();
+            }
+        }
     }
 
     /**

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java?rev=797750&r1=797749&r2=797750&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocUtilTest.java Sat Jul 25 11:21:48 2009
@@ -20,13 +20,18 @@
  */
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.net.SocketTimeoutException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.regex.PatternSyntaxException;
 
 import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.maven.plugin.javadoc.ProxyServer.AuthAsyncProxyServlet;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.PlexusTestCase;
@@ -265,8 +270,10 @@
         throws Exception
     {
         Settings settings = null;
-        URL url = null;
+        Proxy proxy = null;
 
+        URL url = null;
+        URL wrongUrl = null;
         try
         {
             JavadocUtil.fetchURL( settings, url );
@@ -285,10 +292,10 @@
         JavadocUtil.fetchURL( settings, url );
         assertTrue( true );
 
-        url = new URL( "http://maven.apache.org/plugins/maven-javadoc-plugin/apidocs/package-list2" );
+        wrongUrl = new URL( "http://maven.apache.org/plugins/maven-javadoc-plugin/apidocs/package-list2" );
         try
         {
-            JavadocUtil.fetchURL( settings, url );
+            JavadocUtil.fetchURL( settings, wrongUrl );
             assertTrue( false );
         }
         catch ( IOException e )
@@ -296,30 +303,147 @@
             assertTrue( true );
         }
 
-        settings = new Settings();
-        Proxy proxy = new Proxy();
-        proxy.setActive( true );
-        proxy.setHost( "140.211.11.10" ); // Apache's HTTP proxy
-        proxy.setPort( 80 );
-        proxy.setUsername( "toto" );
-        proxy.setPassword( "toto" );
-        proxy.setNonProxyHosts( "www.google.com" );
-        settings.addProxy( proxy );
+        // real proxy
+        ProxyServer proxyServer = null;
+        AuthAsyncProxyServlet proxyServlet = null;
+        try
+        {
+            proxyServlet = new AuthAsyncProxyServlet();
+            proxyServer = new ProxyServer( proxyServlet );
+            proxyServer.start();
 
-        url = new URL( "http://maven.apache.org/plugins/maven-javadoc-plugin/apidocs/package-list" );
-        JavadocUtil.fetchURL( settings, url );
-        assertTrue( true );
+            settings = new Settings();
+
+            JavadocUtil.fetchURL( settings, url );
+            assertTrue( true );
+
+            try
+            {
+                JavadocUtil.fetchURL( settings, wrongUrl );
+                assertTrue( false );
+            }
+            catch ( IOException e )
+            {
+                assertTrue( true );
+            }
+        }
+        catch ( Exception e )
+        {
+            assertTrue( false );
+        }
+        finally
+        {
+            if ( proxyServer != null )
+            {
+                proxyServer.stop();
+            }
+        }
 
-        url = new URL( "http://maven.apache.org/plugins/maven-javadoc-plugin/apidocs/package-list2" );
+        Map authentications = new HashMap();
+        authentications.put( "foo", "bar" );
+        // wrong auth
         try
         {
+            proxyServlet = new AuthAsyncProxyServlet( authentications );
+            proxyServer = new ProxyServer( proxyServlet );
+            proxyServer.start();
+
+            settings = new Settings();
+            proxy = new Proxy();
+            proxy.setActive( true );
+            proxy.setHost( proxyServer.getHostName() );
+            proxy.setPort( proxyServer.getPort() );
+            settings.addProxy( proxy );
+
             JavadocUtil.fetchURL( settings, url );
             assertTrue( false );
         }
-        catch ( IOException e )
+        catch ( FileNotFoundException e )
+        {
+            assertTrue( true );
+        }
+        catch ( Exception e )
+        {
+            assertTrue( false );
+        }
+        finally
+        {
+            if ( proxyServer != null )
+            {
+                proxyServer.stop();
+            }
+        }
+
+        // auth proxy
+        try
+        {
+            proxyServlet = new AuthAsyncProxyServlet( authentications );
+            proxyServer = new ProxyServer( proxyServlet );
+            proxyServer.start();
+
+            settings = new Settings();
+            proxy = new Proxy();
+            proxy.setActive( true );
+            proxy.setHost( proxyServer.getHostName() );
+            proxy.setPort( proxyServer.getPort() );
+            proxy.setUsername( "foo" );
+            proxy.setPassword( "bar" );
+            settings.addProxy( proxy );
+
+            JavadocUtil.fetchURL( settings, url );
+            assertTrue( true );
+
+            try
+            {
+                JavadocUtil.fetchURL( settings, wrongUrl );
+                assertTrue( false );
+            }
+            catch ( IOException e )
+            {
+                assertTrue( true );
+            }
+        }
+        catch ( FileNotFoundException e )
+        {
+            assertTrue( false );
+        }
+        finally
+        {
+            if ( proxyServer != null )
+            {
+                proxyServer.stop();
+            }
+        }
+
+        // timeout
+        try
+        {
+            proxyServlet = new AuthAsyncProxyServlet( authentications, 3000 ); // more than 2000, see fetchURL
+            proxyServer = new ProxyServer( proxyServlet );
+            proxyServer.start();
+
+            settings = new Settings();
+            proxy = new Proxy();
+            proxy.setActive( true );
+            proxy.setHost( proxyServer.getHostName() );
+            proxy.setPort( proxyServer.getPort() );
+            proxy.setUsername( "foo" );
+            proxy.setPassword( "bar" );
+            settings.addProxy( proxy );
+            JavadocUtil.fetchURL( settings, url );
+            assertTrue( false );
+        }
+        catch ( SocketTimeoutException e )
         {
             assertTrue( true );
         }
+        finally
+        {
+            if ( proxyServer != null )
+            {
+                proxyServer.stop();
+            }
+        }
     }
 
     /**

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/ProxyServer.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/ProxyServer.java?rev=797750&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/ProxyServer.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/ProxyServer.java Sat Jul 25 11:21:48 2009
@@ -0,0 +1,242 @@
+package org.apache.maven.plugin.javadoc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.bio.SocketConnector;
+import org.mortbay.jetty.security.B64Code;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.proxy.AsyncProxyServlet;
+
+/**
+ * A Proxy server.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 2.6
+ */
+class ProxyServer
+{
+    private Server proxyServer;
+
+    /**
+     * @param proxyServlet the wanted auth proxy servlet
+     */
+    public ProxyServer( AuthAsyncProxyServlet proxyServlet )
+    {
+        this( null, 0, proxyServlet );
+    }
+
+    /**
+     * @param hostName the server name
+     * @param port the server port
+     * @param debug true to display System.err, false otherwise.
+     * @param proxyServlet the wanted auth proxy servlet
+     */
+    public ProxyServer( String hostName, int port, AuthAsyncProxyServlet proxyServlet )
+    {
+        proxyServer = new Server();
+
+        proxyServer.addConnector( getDefaultConnector( hostName, port ) );
+
+        Context context = new Context( proxyServer, "/", 0 );
+
+        context.addServlet( new ServletHolder( proxyServlet ), "/" );
+    }
+
+    /**
+     * @return the host name
+     */
+    public String getHostName()
+    {
+        Connector connector = proxyServer.getConnectors()[0];
+        return connector.getHost();
+    }
+
+    /**
+     * @return the host port
+     */
+    public int getPort()
+    {
+        Connector connector = proxyServer.getConnectors()[0];
+        return ( connector.getLocalPort() <= 0 ? connector.getPort() : connector.getLocalPort() );
+    }
+
+    /**
+     * @throws Exception if any
+     */
+    public void start()
+        throws Exception
+    {
+        if ( proxyServer != null )
+        {
+            proxyServer.start();
+        }
+    }
+
+    /**
+     * @throws Exception if any
+     */
+    public void stop()
+        throws Exception
+    {
+        if ( proxyServer != null )
+        {
+            proxyServer.stop();
+        }
+        proxyServer = null;
+    }
+
+    private Connector getDefaultConnector( String hostName, int port )
+    {
+        Connector connector = new SocketConnector();
+        if ( hostName != null )
+        {
+            connector.setHost( hostName );
+        }
+        else
+        {
+            try
+            {
+                connector.setHost( InetAddress.getLocalHost().getCanonicalHostName() );
+            }
+            catch ( UnknownHostException e )
+            {
+                // nop
+            }
+        }
+        if ( port > 0 )
+        {
+            connector.setPort( port );
+        }
+
+        return connector;
+    }
+
+    /**
+     * A proxy servlet with authentication support.
+     */
+    static class AuthAsyncProxyServlet
+        extends AsyncProxyServlet
+    {
+        private Map authentications;
+
+        private long sleepTime = 0;
+
+        /**
+         * Constructor for non authentication servlet.
+         */
+        public AuthAsyncProxyServlet()
+        {
+            super();
+        }
+
+        /**
+         * Constructor for authentication servlet.
+         *
+         * @param authentications a map of user/password
+         */
+        public AuthAsyncProxyServlet( Map authentications )
+        {
+            this();
+
+            this.authentications = authentications;
+        }
+
+        /**
+         * Constructor for authentication servlet.
+         *
+         * @param authentications a map of user/password
+         * @param sleepTime a positive time to sleep the service thread (for timeout)
+         */
+        public AuthAsyncProxyServlet( Map authentications, long sleepTime )
+        {
+            this();
+
+            this.authentications = authentications;
+            this.sleepTime = sleepTime;
+        }
+
+        /** {@inheritDoc} */
+        public void service( ServletRequest req, ServletResponse res )
+            throws ServletException, IOException
+        {
+            final HttpServletRequest request = (HttpServletRequest) req;
+            final HttpServletResponse response = (HttpServletResponse) res;
+
+            if ( this.authentications != null && !this.authentications.isEmpty() )
+            {
+                String proxyAuthorization = request.getHeader( "Proxy-Authorization" );
+                if ( proxyAuthorization != null && proxyAuthorization.startsWith( "Basic " ) )
+                {
+                    String proxyAuth = proxyAuthorization.substring( 6 );
+                    String authorization = B64Code.decode( proxyAuth );
+                    String[] authTokens = authorization.split( ":" );
+                    String user = authTokens[0];
+                    String password = authTokens[1];
+
+                    if ( this.authentications.get( user ) == null )
+                    {
+                        throw new IllegalArgumentException( user + " not found in the map!" );
+                    }
+
+                    if ( sleepTime > 0 )
+                    {
+                        try
+                        {
+                            Thread.sleep( sleepTime );
+                        }
+                        catch ( InterruptedException e )
+                        {
+                            // nop
+                        }
+                    }
+                    String authPass = this.authentications.get( user ).toString();
+                    if ( password.equals( authPass ) )
+                    {
+                        // could throw exceptions...
+                        super.service( req, res );
+                        return;
+                    }
+                }
+
+                // Proxy-Authenticate Basic realm="CCProxy Authorization"
+                response.addHeader( "Proxy-Authenticate", "Basic realm=\"Jetty Proxy Authorization\"" );
+                response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
+                return;
+            }
+
+            super.service( req, res );
+        }
+    }
+}
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/ProxyServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/ProxyServer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml?rev=797750&r1=797749&r2=797750&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml Sat Jul 25 11:21:48 2009
@@ -42,6 +42,7 @@
           <groups/>
           <tags/>
           <stylesheet>java</stylesheet>
+          <detectJavaApiLink>true</detectJavaApiLink>
           <quiet>true</quiet>
           <debug>true</debug>
           <failOnError>true</failOnError>