avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy AbstractHttpProxyServer.java DefaultHttpAuditingProxyServer.java DefaultHttpAuditingProxyServer.xinfo DefaultHttpFilteringProxyServer.java DefaultHttpFilteringProxyServer.xinfo HttpAuditingProxyHandler.java HttpAuditingProxyServer.java HttpBlockedDomainException.java HttpFilteringProxyHandler.java HttpFilteringProxyServer.java HttpGetRequestWrapper.java HttpPostRequestWrapper.java HttpProxyHandler.java HttpProxyServer.java HttpRequestValidationException.java HttpRequestWrapper.java
Date Sat, 20 Apr 2002 08:45:46 GMT
colus       02/04/20 01:45:46

  Modified:    httpproxy/src/java/org/apache/avalon/httpproxy
                        AbstractHttpProxyServer.java
                        DefaultHttpAuditingProxyServer.java
                        DefaultHttpAuditingProxyServer.xinfo
                        DefaultHttpFilteringProxyServer.java
                        DefaultHttpFilteringProxyServer.xinfo
                        HttpAuditingProxyHandler.java
                        HttpAuditingProxyServer.java
                        HttpBlockedDomainException.java
                        HttpFilteringProxyHandler.java
                        HttpFilteringProxyServer.java
                        HttpGetRequestWrapper.java
                        HttpPostRequestWrapper.java HttpProxyHandler.java
                        HttpProxyServer.java
                        HttpRequestValidationException.java
                        HttpRequestWrapper.java
  Log:
  Restyled.
  Apply avalon coding standards.
  
  Revision  Changes    Path
  1.3       +18 -18    jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/AbstractHttpProxyServer.java
  
  Index: AbstractHttpProxyServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/AbstractHttpProxyServer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractHttpProxyServer.java	22 Dec 2001 11:03:27 -0000	1.2
  +++ AbstractHttpProxyServer.java	20 Apr 2002 08:45:46 -0000	1.3
  @@ -20,32 +20,32 @@
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.phoenix.Block;
  +import org.apache.avalon.phoenix.BlockContext;
  +import org.apache.avalon.phoenix.Service;
   import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
   import org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory;
   import org.apache.avalon.cornerstone.services.connection.ConnectionManager;
   import org.apache.avalon.cornerstone.services.sockets.ServerSocketFactory;
   import org.apache.avalon.cornerstone.services.sockets.SocketManager;
  -import org.apache.avalon.phoenix.Block;
  -import org.apache.avalon.phoenix.BlockContext;
  -import org.apache.avalon.phoenix.Service;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public abstract class AbstractHttpProxyServer
       extends AbstractLogEnabled
       implements Block, Contextualizable, Composable, Configurable, Service,
  -               Initializable, ConnectionHandlerFactory
  +    Initializable, ConnectionHandlerFactory
   {
  -    protected SocketManager       m_socketManager;
  -    protected ConnectionManager   m_connectionManager;
  +    protected SocketManager m_socketManager;
  +    protected ConnectionManager m_connectionManager;
   
  -    protected String              m_name;
  -    protected String              m_forwardToAnotherProxy;
  -    protected int                 m_port;
  -    protected InetAddress         m_bindTo;
  -    protected BlockContext        m_context;
  +    protected String m_name;
  +    protected String m_forwardToAnotherProxy;
  +    protected int m_port;
  +    protected InetAddress m_bindTo;
  +    protected BlockContext m_context;
   
       public AbstractHttpProxyServer( final String name )
       {
  @@ -57,7 +57,7 @@
           m_context = (BlockContext)context;
       }
   
  -    public void configure( final Configuration configuration  )
  +    public void configure( final Configuration configuration )
           throws ConfigurationException
       {
           m_port = configuration.getChild( "listen-port" ).getValueAsInteger( 8000 );
  @@ -67,19 +67,19 @@
               final String bindAddress = configuration.getChild( "bind" ).getValue();
               m_bindTo = InetAddress.getByName( bindAddress );
           }
  -        catch( final UnknownHostException unhe )
  +        catch ( final UnknownHostException unhe )
           {
               throw new ConfigurationException( "Malformed bind parameter", unhe );
           }
   
           final Configuration forward = configuration.getChild( "forward-to-another-proxy"
);
  -        m_forwardToAnotherProxy = forward.getValue("");
  +        m_forwardToAnotherProxy = forward.getValue( "" );
       }
   
       public void compose( final ComponentManager componentManager )
           throws ComponentException
       {
  -        getLogger().info( "HttpProxyServer-" + m_name + ".compose()" );
  +        getLogger().debug( "HttpProxyServer-" + m_name + ".compose()" );
   
           m_socketManager = (SocketManager)componentManager.
               lookup( "org.apache.avalon.cornerstone.services.sockets.SocketManager" );
  @@ -98,7 +98,7 @@
           m_connectionManager.connect( "HttpProxyListener-" + m_name, serverSocket, this
);
   
           // This is only to help newbies.....
  -        System.out.println(getShortName() + " HTTP Proxy server running.  Configure your
browser to proxy through localhost:" + m_port + " to use it");
  +        System.out.println( getShortName() + " HTTP Proxy server running.  Configure your
browser to proxy through localhost:" + m_port + " to use it" );
   
       }
   
  @@ -121,7 +121,7 @@
       /**
        * Release a previously created ConnectionHandler e.g. for spooling.
        */
  -    public void releaseConnectionHandler(ConnectionHandler connectionHandler)
  +    public void releaseConnectionHandler( ConnectionHandler connectionHandler )
       {
       }
   
  
  
  
  1.3       +2 -4      jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/DefaultHttpAuditingProxyServer.java
  
  Index: DefaultHttpAuditingProxyServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/DefaultHttpAuditingProxyServer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultHttpAuditingProxyServer.java	28 Feb 2002 21:19:27 -0000	1.2
  +++ DefaultHttpAuditingProxyServer.java	20 Apr 2002 08:45:46 -0000	1.3
  @@ -7,10 +7,9 @@
    */
   package org.apache.avalon.httpproxy;
   
  -import java.net.Socket;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public class DefaultHttpAuditingProxyServer
  @@ -19,11 +18,10 @@
   {
       public DefaultHttpAuditingProxyServer()
       {
  -        super("Auditing");
  +        super( "Auditing" );
       }
   
       /**
  -     * Method createHttpProxyHandler
        * Factory method, overriding that of parent, to create the right handler for
        * an individual request.
        */
  
  
  
  1.3       +19 -19    jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/DefaultHttpAuditingProxyServer.xinfo
  
  Index: DefaultHttpAuditingProxyServer.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/DefaultHttpAuditingProxyServer.xinfo,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultHttpAuditingProxyServer.xinfo	15 Jan 2002 10:42:40 -0000	1.2
  +++ DefaultHttpAuditingProxyServer.xinfo	20 Apr 2002 08:45:46 -0000	1.3
  @@ -1,27 +1,27 @@
   <?xml version="1.0"?>
  -<!DOCTYPE blockinfo PUBLIC "-//PHOENIX/Block Info DTD Version 1.0//EN" 
  +<!DOCTYPE blockinfo PUBLIC "-//PHOENIX/Block Info DTD Version 1.0//EN"
                     "http://jakarta.apache.org/phoenix/blockinfo_1_0.dtd">
   
   <blockinfo>
   
  -  <!-- section to describe block -->
  -  <block>
  -    <version>1.0</version>
  -  </block>
  +    <!-- section to describe block -->
  +    <block>
  +        <version>1.0</version>
  +    </block>
   
  -  <!-- services that are offered by this block -->
  -  <services>
  -    <service name="org.apache.avalon.httpproxy.HttpAuditingProxyServer" 
  -             version="1.0" />
  -  </services>
  -  <dependencies>
  -    <dependency>
  -      <service name="org.apache.avalon.cornerstone.services.connection.ConnectionManager"

  -               version="1.0"/>
  -    </dependency>
  -    <dependency>
  -      <service name="org.apache.avalon.cornerstone.services.sockets.SocketManager" version="1.0"/>
  -    </dependency>
  -  </dependencies>  
  +    <!-- services that are offered by this block -->
  +    <services>
  +        <service name="org.apache.avalon.httpproxy.HttpAuditingProxyServer"
  +            version="1.0" />
  +    </services>
  +    <dependencies>
  +        <dependency>
  +            <service name="org.apache.avalon.cornerstone.services.connection.ConnectionManager"
  +                version="1.0"/>
  +        </dependency>
  +        <dependency>
  +            <service name="org.apache.avalon.cornerstone.services.sockets.SocketManager"
version="1.0"/>
  +        </dependency>
  +    </dependencies>
   
   </blockinfo>
  
  
  
  1.3       +37 -36    jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/DefaultHttpFilteringProxyServer.java
  
  Index: DefaultHttpFilteringProxyServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/DefaultHttpFilteringProxyServer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultHttpFilteringProxyServer.java	28 Feb 2002 21:19:27 -0000	1.2
  +++ DefaultHttpFilteringProxyServer.java	20 Apr 2002 08:45:46 -0000	1.3
  @@ -7,14 +7,12 @@
    */
   package org.apache.avalon.httpproxy;
   
  -import java.net.Socket;
   import java.util.HashSet;
  -import java.util.Iterator;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public class DefaultHttpFilteringProxyServer
  @@ -22,10 +20,10 @@
       implements HttpFilteringProxyServer
   {
       // a site may be x.y.z.p.p.hello.com, only check the last two and three parts
  -    protected HashSet     blockedTwoPartDomains             = new HashSet();
  -    protected HashSet     blockedThreePartDomains           = new HashSet();
  -    protected HashSet     cookiesAllowedForTwoPartDomains   = new HashSet();
  -    protected HashSet     cookiesAllowedForThreePartDomains = new HashSet();
  +    protected HashSet m_blockedTwoPartDomains = new HashSet();
  +    protected HashSet m_blockedThreePartDomains = new HashSet();
  +    protected HashSet m_cookiesAllowedForTwoPartDomains = new HashSet();
  +    protected HashSet m_cookiesAllowedForThreePartDomains = new HashSet();
   
       /**
        * Constructor DefaultHttpFilteringProxyServer
  @@ -47,13 +45,13 @@
   
           // mark some domains as having no cookies sent.
           final Configuration cookieDomains = configuration.getChild( "cookies-allowed-domains"
);
  -        configureCookieDomains( cookieDomains.getChildren("cookies-allowed-domain") );
  +        configureCookieDomains( cookieDomains.getChildren( "cookies-allowed-domain" ) );
       }
   
       protected void configureBlockedDomains( final Configuration[] domains )
           throws ConfigurationException
       {
  -        for( int i = 0; i < domains.length; i++ )
  +        for ( int i = 0; i < domains.length; i++ )
           {
               blockAllContentFrom( domains[ i ].getAttribute( "domain-name" ), true );
           }
  @@ -62,7 +60,7 @@
       protected void configureCookieDomains( final Configuration[] domains )
           throws ConfigurationException
       {
  -        for( int i = 0; i < domains.length; i++ )
  +        for ( int i = 0; i < domains.length; i++ )
           {
               allowCookiesFrom( domains[ i ].getAttribute( "domain-name" ), true );
           }
  @@ -71,15 +69,15 @@
       public boolean domainAllowed( final String domainName )
       {
           return !isDomainInList( domainName,
  -                                blockedTwoPartDomains,
  -                                blockedThreePartDomains );
  +                                m_blockedTwoPartDomains,
  +                                m_blockedThreePartDomains );
       }
   
       public boolean cookieAllowed( final String domainName )
       {
           return isDomainInList( domainName,
  -                               cookiesAllowedForTwoPartDomains,
  -                               cookiesAllowedForThreePartDomains );
  +                               m_cookiesAllowedForTwoPartDomains,
  +                               m_cookiesAllowedForThreePartDomains );
       }
   
       private boolean isDomainInList( String domainName,
  @@ -90,7 +88,7 @@
   
           int dCount = dotCount( domainName );
   
  -        if( 0 == dCount )
  +        if ( 0 == dCount )
           {
               // no dot, must mean it's inside the intranet.
               return false;
  @@ -99,22 +97,22 @@
           {
               String domainName2p = domainName;
   
  -            if( dCount >= 2 )
  +            if ( dCount >= 2 )
               {
                   // three or more parts to the domain name.
  -                String domainName3p = trimToThreePartDomainName(domainName, dCount);
  +                String domainName3p = trimToThreePartDomainName( domainName, dCount );
   
  -                if( threePart.contains(domainName3p) )
  +                if ( threePart.contains( domainName3p ) )
                   {
                       return true; // it's in the three part list
                   }
   
                   // get rid of first part to make a two part domain name.
  -                domainName2p = domainName3p.substring( domainName3p.indexOf('.') + 1,
  +                domainName2p = domainName3p.substring( domainName3p.indexOf( '.' ) + 1,
                                                          domainName3p.length() );
               }
   
  -            if( twoPart.contains( domainName2p ) )
  +            if ( twoPart.contains( domainName2p ) )
               {
                   return true; // it's in the two part list.
               }
  @@ -137,8 +135,8 @@
       {
           addOrRemoveFromList( domainName,
                                onOff,
  -                             blockedTwoPartDomains,
  -                             blockedThreePartDomains );
  +                             m_blockedTwoPartDomains,
  +                             m_blockedThreePartDomains );
           getLogger().debug( "blockAllContentFrom " + domainName );
       }
   
  @@ -147,8 +145,8 @@
       {
           addOrRemoveFromList( domainName,
                                onOff,
  -                             cookiesAllowedForTwoPartDomains,
  -                             cookiesAllowedForThreePartDomains );
  +                             m_cookiesAllowedForTwoPartDomains,
  +                             m_cookiesAllowedForThreePartDomains );
           getLogger().debug( "allowCookiesFrom " + domainName );
       }
   
  @@ -161,18 +159,20 @@
   
           int dCount = dotCount( domainName );
   
  -        if( onOff )
  +        if ( onOff )
           {
  -            if( 1 == dCount ) twoPart.add(domainName);
  -            else if( dCount >= 2 )
  +            if ( 1 == dCount )
  +                twoPart.add( domainName );
  +            else if ( dCount >= 2 )
               {
                   threePart.add( trimToThreePartDomainName( domainName, dCount ) );
               }
           }
           else
           {
  -            if( 1 == dCount ) twoPart.remove( domainName );
  -            else if( dCount >= 2 )
  +            if ( 1 == dCount )
  +                twoPart.remove( domainName );
  +            else if ( dCount >= 2 )
               {
                   threePart.remove( trimToThreePartDomainName( domainName, dCount ) );
               }
  @@ -182,9 +182,9 @@
       private int dotCount( final String domainName )
       {
           int count = 0;
  -        int ix = domainName.indexOf('.', 0);
  +        int ix = domainName.indexOf( '.', 0 );
   
  -        while( -1 != ix )
  +        while ( -1 != ix )
           {
               count++;
               ix = domainName.indexOf( '.', ix + 1 );
  @@ -195,14 +195,15 @@
   
       private String trimToThreePartDomainName( final String domainName, int dotCount )
       {
  -        if( 2 == dotCount ) return domainName;
  +        if ( 2 == dotCount )
  +            return domainName;
           else
           {
               int bIx = 0;
   
  -            while( dotCount-- > 2 )
  +            while ( dotCount-- > 2 )
               {
  -                bIx = domainName.indexOf('.', bIx) + 1;
  +                bIx = domainName.indexOf( '.', bIx ) + 1;
               }
   
               return domainName.substring( bIx, domainName.length() );
  @@ -211,7 +212,7 @@
   
       public String[] getBlockedDomains()
       {
  -        return new String[] {"TODO"}; // TODO PH
  +        return new String[]{"TODO"}; // TODO PH
       }
   
       /**
  @@ -219,7 +220,7 @@
        */
       public String[] getCookieSuppressedDomains()
       {
  -        return new String[] {"TODO"}; // TODO PH
  +        return new String[]{"TODO"}; // TODO PH
       }
   
       protected String getShortName()
  
  
  
  1.3       +19 -19    jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/DefaultHttpFilteringProxyServer.xinfo
  
  Index: DefaultHttpFilteringProxyServer.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/DefaultHttpFilteringProxyServer.xinfo,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultHttpFilteringProxyServer.xinfo	15 Jan 2002 10:42:40 -0000	1.2
  +++ DefaultHttpFilteringProxyServer.xinfo	20 Apr 2002 08:45:46 -0000	1.3
  @@ -1,28 +1,28 @@
   <?xml version="1.0"?>
  -<!DOCTYPE blockinfo PUBLIC "-//PHOENIX/Block Info DTD Version 1.0//EN" 
  +<!DOCTYPE blockinfo PUBLIC "-//PHOENIX/Block Info DTD Version 1.0//EN"
                     "http://jakarta.apache.org/phoenix/blockinfo_1_0.dtd">
   
   <blockinfo>
   
  -  <!-- section to describe block -->
  -  <block>
  -    <version>1.0</version>
  -  </block>
  +    <!-- section to describe block -->
  +    <block>
  +        <version>1.0</version>
  +    </block>
   
  -  <!-- services that are offered by this block -->
  -  <services>
  -    <service name="org.apache.avalon.httpproxy.HttpFilteringProxyServer" 
  -             version="1.0" />
  -  </services>
  -  <dependencies>
  -    <dependency>
  -      <service name="org.apache.avalon.cornerstone.services.connection.ConnectionManager"

  -               version="1.0"/>
  -    </dependency>
  -    <dependency>
  -      <service name="org.apache.avalon.cornerstone.services.sockets.SocketManager" version="1.0"/>
  -    </dependency>
  -  </dependencies>  
  +    <!-- services that are offered by this block -->
  +    <services>
  +        <service name="org.apache.avalon.httpproxy.HttpFilteringProxyServer"
  +            version="1.0" />
  +    </services>
  +    <dependencies>
  +        <dependency>
  +            <service name="org.apache.avalon.cornerstone.services.connection.ConnectionManager"
  +                version="1.0"/>
  +        </dependency>
  +        <dependency>
  +            <service name="org.apache.avalon.cornerstone.services.sockets.SocketManager"
version="1.0"/>
  +        </dependency>
  +    </dependencies>
   
   
   </blockinfo>
  
  
  
  1.3       +5 -5      jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpAuditingProxyHandler.java
  
  Index: HttpAuditingProxyHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpAuditingProxyHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HttpAuditingProxyHandler.java	28 Feb 2002 21:19:27 -0000	1.2
  +++ HttpAuditingProxyHandler.java	20 Apr 2002 08:45:46 -0000	1.3
  @@ -7,11 +7,11 @@
    */
   package org.apache.avalon.httpproxy;
   
  -import java.net.Socket;
   
   /**
  - * This handles an individual incoming request.  It outputs a greeting as html.
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * This handles an individual incoming request. It outputs a greeting as html.
  +
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public class HttpAuditingProxyHandler
  @@ -19,14 +19,14 @@
   {
       protected HttpAuditingProxyHandler( final String forwardToAnotherProxy )
       {
  -        super( forwardToAnotherProxy);
  +        super( forwardToAnotherProxy );
       }
   
       protected void validateRequest()
           throws HttpRequestValidationException
       {
           // no validate, just log.
  -        getLogger().info("Connection to " + httpRequestWrapper.getURL());
  +        getLogger().info( "Connection to " + m_httpRequestWrapper.getURL() );
       }
   }
   
  
  
  
  1.2       +1 -1      jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpAuditingProxyServer.java
  
  Index: HttpAuditingProxyServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpAuditingProxyServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpAuditingProxyServer.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpAuditingProxyServer.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -8,7 +8,7 @@
   package org.apache.avalon.httpproxy;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public interface HttpAuditingProxyServer
  
  
  
  1.2       +1 -1      jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpBlockedDomainException.java
  
  Index: HttpBlockedDomainException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpBlockedDomainException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpBlockedDomainException.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpBlockedDomainException.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -8,7 +8,7 @@
   package org.apache.avalon.httpproxy;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public class HttpBlockedDomainException
  
  
  
  1.2       +11 -10    jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpFilteringProxyHandler.java
  
  Index: HttpFilteringProxyHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpFilteringProxyHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpFilteringProxyHandler.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpFilteringProxyHandler.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -12,14 +12,15 @@
   
   /**
    * This handles an individual incoming request.  It outputs a greeting as html.
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + *
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public class HttpFilteringProxyHandler
       extends HttpProxyHandler
   {
       // used for callbacks
  -    protected HttpFilteringProxyServer   proxyServer;
  +    protected HttpFilteringProxyServer m_proxyServer;
   
       /**
        * Constructor HttpFilteringProxyHandler
  @@ -31,7 +32,7 @@
           super( forwardToAnotherProxy );
   
           // used for callbacks
  -        this.proxyServer = proxyServer;
  +        this.m_proxyServer = proxyServer;
       }
   
       /**
  @@ -44,9 +45,9 @@
       protected void validateRequest()
           throws HttpRequestValidationException
       {
  -        final String domainName = httpRequestWrapper.getServerName();
  +        final String domainName = m_httpRequestWrapper.getServerName();
   
  -        if( !proxyServer.domainAllowed( domainName ) )
  +        if ( !m_proxyServer.domainAllowed( domainName ) )
           {
               throw new HttpBlockedDomainException( domainName );
               // perhaps this should be:
  @@ -67,13 +68,13 @@
        */
       public String getOutgoingHttpRequest( final boolean anotherProxy )
       {
  -        final String domainName = httpRequestWrapper.getServerName();
  +        final String domainName = m_httpRequestWrapper.getServerName();
           final String httpRequest = super.getOutgoingHttpRequest( anotherProxy );
   
  -        if( !proxyServer.cookieAllowed( domainName ) )
  +        if ( !m_proxyServer.cookieAllowed( domainName ) )
           {
               final String request =
  -                getHttpRequestWithoutCookie( httpRequest, httpRequestWrapper.getURL() );
  +                getHttpRequestWithoutCookie( httpRequest, m_httpRequestWrapper.getURL()
);
               return request.trim() + "\r\n\r\n";
           }
           else
  @@ -87,11 +88,11 @@
           final StringBuffer newHttpRequest = new StringBuffer();
           final StringTokenizer rqstTokens = new StringTokenizer( httpRequest, "\n\r" );
   
  -        while( rqstTokens.hasMoreTokens() )
  +        while ( rqstTokens.hasMoreTokens() )
           {
               final String line = rqstTokens.nextToken();
   
  -            if( !line.startsWith("Cookie:") )
  +            if ( !line.startsWith( "Cookie:" ) )
               {
                   newHttpRequest.append( line ).append( "\r\n" );
               }
  
  
  
  1.2       +1 -1      jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpFilteringProxyServer.java
  
  Index: HttpFilteringProxyServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpFilteringProxyServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpFilteringProxyServer.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpFilteringProxyServer.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -8,7 +8,7 @@
   package org.apache.avalon.httpproxy;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public interface HttpFilteringProxyServer
  
  
  
  1.2       +1 -1      jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpGetRequestWrapper.java
  
  Index: HttpGetRequestWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpGetRequestWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpGetRequestWrapper.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpGetRequestWrapper.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -12,7 +12,7 @@
   import org.apache.avalon.framework.logger.Logger;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public class HttpGetRequestWrapper
  
  
  
  1.2       +10 -10    jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpPostRequestWrapper.java
  
  Index: HttpPostRequestWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpPostRequestWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpPostRequestWrapper.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpPostRequestWrapper.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -12,10 +12,10 @@
   import org.apache.avalon.framework.logger.Logger;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
  -public class HttpPostRequestWrapper 
  +public class HttpPostRequestWrapper
       extends HttpRequestWrapper
   {
       protected HttpPostRequestWrapper( final Logger logger, final String rq )
  @@ -31,9 +31,9 @@
   
           String wholeBuffer = "POST";
   
  -        is.read( new byte[1] ); // T from post
  +        is.read( new byte[ 1 ] ); // T from post
   
  -        byte[] bytes = new byte[SEGLEN];
  +        byte[] bytes = new byte[ SEGLEN ];
           int bytesRead = is.read( bytes );
           int contLen;
           int lenAfterContent;
  @@ -47,22 +47,22 @@
               contLen = getContentLength( tmpRqst );
               lenAfterContent = getLengthAfterContent( tmpRqst );
   
  -            if( -1 == wholeBuffer.indexOf( EOF ) )
  +            if ( -1 == wholeBuffer.indexOf( EOF ) )
               {
                   bytesRead = is.read( bytes );
               }
           }
  -        while( ( lenAfterContent < contLen ) &&
  -               ( -1 == wholeBuffer.indexOf( EOF ) ) );
  +        while ( ( lenAfterContent < contLen ) &&
  +            ( -1 == wholeBuffer.indexOf( EOF ) ) );
   
           super.setRequest( wholeBuffer );
       }
   
       private int getContentLength( final String rqst )
       {
  -        int firstDigit = rqst.indexOf("CONTENT-LENGTH:") + 16;
  +        int firstDigit = rqst.indexOf( "CONTENT-LENGTH:" ) + 16;
   
  -        if( -1 != firstDigit )
  +        if ( -1 != firstDigit )
           {
               final int lastDigit = rqst.indexOf( "\n", firstDigit );
               return Integer.parseInt( rqst.substring( firstDigit, lastDigit ).trim() );
  @@ -75,7 +75,7 @@
       {
           int firstDigit = rqst.indexOf( "CONTENT-LENGTH:" ) + 16;
   
  -        if( -1 != firstDigit )
  +        if ( -1 != firstDigit )
           {
               return rqst.length() - firstDigit;
           }
  
  
  
  1.2       +68 -54    jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpProxyHandler.java
  
  Index: HttpProxyHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpProxyHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpProxyHandler.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpProxyHandler.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -7,7 +7,11 @@
    */
   package org.apache.avalon.httpproxy;
   
  -import java.io.*;
  +import java.io.BufferedOutputStream;
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.io.InterruptedIOException;
  +import java.io.PrintWriter;
   import java.net.ConnectException;
   import java.net.Socket;
   import java.net.SocketException;
  @@ -18,23 +22,24 @@
   
   /**
    * This handles an individual incoming request.  It returns a bytes etc from remote server.
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  +
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public abstract class HttpProxyHandler
       extends AbstractLogEnabled
       implements Component, ConnectionHandler
   {
  -    protected Socket              clientSocket;
  -    protected Socket              serverSocket;
  -    protected String              clientHost;
  -    protected String              clientIP;
  -    protected String              forwardToAnotherProxy;
  -    protected HttpRequestWrapper  httpRequestWrapper;
  +    protected Socket m_clientSocket;
  +    protected Socket m_serverSocket;
  +    protected String m_clientHost;
  +    protected String m_clientIp;
  +    protected String m_forwardToAnotherProxy;
  +    protected HttpRequestWrapper m_httpRequestWrapper;
   
       protected HttpProxyHandler( final String forwardToAnotherProxy )
       {
  -        this.forwardToAnotherProxy = forwardToAnotherProxy;
  +        m_forwardToAnotherProxy = forwardToAnotherProxy;
       }
   
       /**
  @@ -47,52 +52,58 @@
       public void handleConnection( final Socket socket )
           throws IOException
       {
  -        this.clientSocket = socket;
  -        clientHost = clientSocket.getInetAddress().getHostName();
  -        clientIP = clientSocket.getInetAddress().getHostAddress();
  +        m_clientSocket = socket;
  +        m_clientHost = m_clientSocket.getInetAddress().getHostName();
  +        m_clientIp = m_clientSocket.getInetAddress().getHostAddress();
   
           try
           {
  -            httpRequestWrapper =
  +            m_httpRequestWrapper =
                   HttpRequestWrapper.createHttpRequestWrapper( getLogger(),
  -                                                             clientSocket.getInputStream()
);
  +                                                             m_clientSocket.getInputStream()
);
   
               validateRequest();
               forwardRequest();
           }
  -        catch( final HttpRequestValidationException hrve )
  +        catch ( final HttpRequestValidationException hrve )
           {
               write403Page();
               getLogger().info( hrve.getMessage() );
           }
  -        catch( final SocketException se )
  +        catch ( final SocketException se )
           {
  -            getLogger().debug( "Socket to " + clientHost + " closed remotely.", se );
  +            getLogger().debug( "Socket to " + m_clientHost + " closed remotely.", se );
           }
  -        catch( final InterruptedIOException iioe )
  +        catch ( final InterruptedIOException iioe )
           {
  -            getLogger().debug( "Socket to " + clientHost + " timeout.", iioe );
  +            getLogger().debug( "Socket to " + m_clientHost + " timeout.", iioe );
           }
  -        catch( final IOException ioe )
  +        catch ( final IOException ioe )
           {
  -            getLogger().debug( "Exception in proxy handling socket to " + clientHost, ioe
);
  +            getLogger().debug( "Exception in proxy handling socket to " + m_clientHost,
ioe );
           }
  -        catch( final Exception e )
  +        catch ( final Exception e )
           {
               getLogger().debug( "Exception in proxy opening socket", e );
           }
           finally
           {
  -            try { clientSocket.close(); }
  -            catch( final IOException ioe )
  +            try
  +            {
  +                m_clientSocket.close();
  +            }
  +            catch ( final IOException ioe )
               {
                   getLogger().error( "Exception closing client socket ", ioe );
               }
   
  -            if( null != serverSocket )
  +            if ( null != m_serverSocket )
               {
  -                try { serverSocket.close(); }
  -                catch( final IOException ioe )
  +                try
  +                {
  +                    m_serverSocket.close();
  +                }
  +                catch ( final IOException ioe )
                   {
                       getLogger().error( "Exception closing server socket ", ioe );
                   }
  @@ -103,66 +114,66 @@
       protected Socket makeOutgoingSocket()
           throws IOException
       {
  -        if( !forwardToAnotherProxy.equals("") )
  +        if ( !m_forwardToAnotherProxy.equals( "" ) )
           {
  -            int colon = forwardToAnotherProxy.indexOf(':');
  -            String toName = forwardToAnotherProxy.substring(0, colon);
  +            int colon = m_forwardToAnotherProxy.indexOf( ':' );
  +            String toName = m_forwardToAnotherProxy.substring( 0, colon );
               int toPort = Integer.
  -                parseInt( forwardToAnotherProxy.substring( colon + 1,
  -                                                           forwardToAnotherProxy.length()
) );
  +                parseInt( m_forwardToAnotherProxy.substring( colon + 1,
  +                                                           m_forwardToAnotherProxy.length()
) );
   
               return new Socket( toName, toPort );
           }
           else
           {
  -            return new Socket( httpRequestWrapper.getServerInetAddress(),
  -                               httpRequestWrapper.getServerPort() );
  +            return new Socket( m_httpRequestWrapper.getServerInetAddress(),
  +                               m_httpRequestWrapper.getServerPort() );
           }
       }
   
       public String getOutgoingHttpRequest( final boolean anotherProxy )
       {
  -        if( anotherProxy )
  +        if ( anotherProxy )
           {
  -            return httpRequestWrapper.getNakedHttpRequest().trim() + "\r\n\r\n";
  +            return m_httpRequestWrapper.getNakedHttpRequest().trim() + "\r\n\r\n";
           }
           else
           {
  -            return httpRequestWrapper.getHttpRequest().trim() + "\r\n\r\n";
  +            return m_httpRequestWrapper.getHttpRequest().trim() + "\r\n\r\n";
           }
       }
   
       public final void forwardRequest()
           throws IOException
       {
  -        String request = getOutgoingHttpRequest( ( !forwardToAnotherProxy.equals("") )
);
  +        String request = getOutgoingHttpRequest( ( !m_forwardToAnotherProxy.equals( ""
) ) );
   
           try
           {
  -            serverSocket = makeOutgoingSocket();
  +            m_serverSocket = makeOutgoingSocket();
   
  -            serverSocket.getOutputStream().write( request.getBytes() );
  +            m_serverSocket.getOutputStream().write( request.getBytes() );
   
  -            byte[] page = new byte[2048];
  +            byte[] page = new byte[ 2048 ];
               int pLength;
               BufferedOutputStream bufToClient =
  -                new BufferedOutputStream( clientSocket.getOutputStream() );
  -            InputStream serverIS = serverSocket.getInputStream();
  +                new BufferedOutputStream( m_clientSocket.getOutputStream() );
  +            InputStream serverIS = m_serverSocket.getInputStream();
   
               do
               {
                   pLength = serverIS.read( page );
   
  -                if( -1 != pLength )
  +                if ( -1 != pLength )
                   {
                       bufToClient.write( page, 0, pLength );
                   }
               }
  -            while( -1 != pLength );
  +            while ( -1 != pLength );
   
               bufToClient.close();
           }
  -        catch( final Exception e )
  +        catch ( final Exception e )
           {
               // general catch is deliberate, see writeErrorPage(..)
               writeErrorPage( e );
  @@ -172,21 +183,21 @@
       private void writeErrorPage( final Exception e )
           throws IOException
       {
  -        final PrintWriter output = new PrintWriter( clientSocket.getOutputStream() );
  +        final PrintWriter output = new PrintWriter( m_clientSocket.getOutputStream() );
   
  -        output.println( "<html><body>Unable to reach <b>" + httpRequestWrapper.getServerName()
+
  -                        ":" + httpRequestWrapper.getServerPort() + "</b> at the moment."
);
  +        output.println( "<html><body>Unable to reach <b>" + m_httpRequestWrapper.getServerName()
+
  +                        ":" + m_httpRequestWrapper.getServerPort() + "</b> at the
moment." );
           output.println( "<br />This Message is bought to you by the Avalon demo proxy
server." );
           output.println( "<br />If you had a direct connection to the net, you would
not see " +
                           "this message, your browser would instead tell you it could not
reach" +
  -                        " the site.<br />");
  +                        " the site.<br />" );
   
  -        if( e instanceof UnknownHostException )
  +        if ( e instanceof UnknownHostException )
           {
               output.println( "<br />The probable cause is that the domain name does
not exist," +
                               " of the route to it is severed." );
           }
  -        else if( e instanceof ConnectException )
  +        else if ( e instanceof ConnectException )
           {
               output.println( "<br />The probable cause is that the machine at domain
name is" +
                               " not running a service at the port number in question (HTTP
or" +
  @@ -209,15 +220,18 @@
       {
           try
           {
  -            final PrintWriter output = new PrintWriter( clientSocket.getOutputStream()
);
  +            final PrintWriter output = new PrintWriter( m_clientSocket.getOutputStream()
);
   
               output.println( "<html><head><title>Blocked</title></head>"
+
                               "<body>Blocked</body></html>" );
               output.flush();
               output.close();
           }
  -        catch( final IOException ioe ) {}
  +        catch ( final IOException ioe )
  +        {
  +        }
       }
  +
       protected abstract void validateRequest()
           throws HttpRequestValidationException;
   }
  
  
  
  1.2       +1 -2      jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpProxyServer.java
  
  Index: HttpProxyServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpProxyServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpProxyServer.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpProxyServer.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -7,10 +7,9 @@
    */
   package org.apache.avalon.httpproxy;
   
  -import org.apache.avalon.phoenix.Service;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public interface HttpProxyServer
  
  
  
  1.2       +1 -1      jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpRequestValidationException.java
  
  Index: HttpRequestValidationException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpRequestValidationException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpRequestValidationException.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpRequestValidationException.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -8,7 +8,7 @@
   package org.apache.avalon.httpproxy;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public class HttpRequestValidationException
  
  
  
  1.2       +13 -13    jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpRequestWrapper.java
  
  Index: HttpRequestWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/httpproxy/src/java/org/apache/avalon/httpproxy/HttpRequestWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpRequestWrapper.java	21 Nov 2001 17:10:41 -0000	1.1
  +++ HttpRequestWrapper.java	20 Apr 2002 08:45:46 -0000	1.2
  @@ -16,17 +16,17 @@
   import org.apache.avalon.framework.logger.Logger;
   
   /**
  - * @author  Paul Hammant <Paul_Hammant@yahoo.com>
  + * @author <a href="Paul_Hammant@yahoo.com">Paul Hammant</a>
    * @version 1.0
    */
   public class HttpRequestWrapper
   {
  -    protected final static String     EOF        = "\r\n\r\n";
  -    protected final static int        SEGLEN     = 2048;
  +    protected static final String EOF = "\r\n\r\n";
  +    protected static final int SEGLEN = 2048;
   
  -    protected final Logger            m_logger;
  -    protected String                  m_request;
  -    protected URL                     m_url;
  +    protected final Logger m_logger;
  +    protected String m_request;
  +    protected URL m_url;
   
       protected HttpRequestWrapper( final Logger logger )
       {
  @@ -49,7 +49,7 @@
           {
               m_url = new URL( getURLFromHttpHeader() );
           }
  -        catch( final MalformedURLException mfue )
  +        catch ( final MalformedURLException mfue )
           {
               m_logger.error( "URL from http header is malformed", mfue );
           }
  @@ -79,7 +79,7 @@
               return m_request.substring( hostStart,
                                           m_request.indexOf( " ", hostStart ) );
           }
  -        catch( final StringIndexOutOfBoundsException sioobe )
  +        catch ( final StringIndexOutOfBoundsException sioobe )
           {
               m_logger.error( "Unable to find URL in http header", sioobe );
           }
  @@ -104,7 +104,7 @@
       {
           final int port = m_url.getPort();
   
  -        return ((port == -1) ? 80 : port);
  +        return ( ( port == -1 ) ? 80 : port );
       }
   
       /**
  @@ -127,7 +127,7 @@
               m_request.indexOf( "/", m_request.indexOf( "//" ) + 2 );
   
           return
  -            m_request.substring( 0, m_request.indexOf("http://") ) + "/" +
  +            m_request.substring( 0, m_request.indexOf( "http://" ) ) + "/" +
               m_request.substring( hostEnd, m_request.length() );
       }
   
  @@ -140,17 +140,17 @@
                                                           final InputStream is )
           throws IOException
       {
  -        byte[] threeBytes = new byte[3];
  +        byte[] threeBytes = new byte[ 3 ];
           int bytes = is.read( threeBytes );
   
  -        if( 3 != bytes )
  +        if ( 3 != bytes )
           {
               throw new RuntimeException( "not three bytes?" );
           }
   
           final String reqType = new String( threeBytes, 0, bytes );
   
  -        if( reqType.equals("POS") )
  +        if ( reqType.equals( "POS" ) )
           {
               return new HttpPostRequestWrapper( logger, is );
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message