Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.http.handler
Class ProxyHandler  view ProxyHandler download ProxyHandler.java

java.lang.Object
  extended byorg.mortbay.http.handler.AbstractHttpHandler
      extended byorg.mortbay.http.handler.ProxyHandler
All Implemented Interfaces:
org.mortbay.http.HttpHandler, org.mortbay.util.LifeCycle, java.io.Serializable

public class ProxyHandler
extends AbstractHttpHandler

Proxy request handler. A HTTP/1.1 Proxy. This implementation uses the JVMs URL implementation to make proxy requests.

The HttpTunnel mechanism is also used to implement the CONNECT method.

Version:
$Id: ProxyHandler.java,v 1.25 2003/10/05 23:46:27 gregwilkins Exp $

Field Summary
protected  java.util.HashSet _allowedConnectPorts
          Set of allowed CONNECT ports.
protected  org.mortbay.util.StringMap _DontProxyHeaders
          Map of leg by leg headers (not end to end).
protected  java.util.Set _proxyHostsBlackList
           
protected  java.util.Set _proxyHostsWhiteList
           
protected  org.mortbay.util.StringMap _ProxySchemes
          Map of allows schemes to proxy Should be a set, but more efficient string map is used instead.
protected  int _tunnelTimeoutMs
           
private static org.apache.commons.logging.Log log
           
 
Fields inherited from class org.mortbay.http.handler.AbstractHttpHandler
 
Constructor Summary
ProxyHandler()
           
 
Method Summary
protected  void customizeConnection(java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.http.HttpRequest request, java.net.Socket socket)
          Customize proxy Socket connection for CONNECT.
protected  void customizeConnection(java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.http.HttpRequest request, java.net.URLConnection connection)
          Customize proxy URL connection.
 java.lang.String[] getProxyHostsBlackList()
          Get proxy host black list.
 java.lang.String[] getProxyHostsWhiteList()
          Get proxy host white list.
 int getTunnelTimeoutMs()
           
 void handle(java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response)
          Tunnel timeout.
 void handleConnect(java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response)
           
protected  boolean isForbidden(java.lang.String scheme, java.lang.String host, int port, boolean openNonPrivPorts)
          Is scheme,host & port Forbidden.
protected  boolean isForbidden(org.mortbay.util.URI uri)
          Is URL Forbidden.
protected  java.net.URL isProxied(org.mortbay.util.URI uri)
          Is URL Proxied.
protected  void sendForbid(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, org.mortbay.util.URI uri)
          Send Forbidden.
 void setProxyHostsBlackList(java.lang.String[] hosts)
          Set proxy host black list.
 void setProxyHostsWhiteList(java.lang.String[] hosts)
          Set proxy host white list.
 
Methods inherited from class org.mortbay.http.handler.AbstractHttpHandler
getHttpContext, getName, handleTrace, initialize, isStarted, setName, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

_proxyHostsWhiteList

protected java.util.Set _proxyHostsWhiteList

_proxyHostsBlackList

protected java.util.Set _proxyHostsBlackList

_tunnelTimeoutMs

protected int _tunnelTimeoutMs

_DontProxyHeaders

protected org.mortbay.util.StringMap _DontProxyHeaders
Map of leg by leg headers (not end to end). Should be a set, but more efficient string map is used instead.


_ProxySchemes

protected org.mortbay.util.StringMap _ProxySchemes
Map of allows schemes to proxy Should be a set, but more efficient string map is used instead.


_allowedConnectPorts

protected java.util.HashSet _allowedConnectPorts
Set of allowed CONNECT ports.

Constructor Detail

ProxyHandler

public ProxyHandler()
Method Detail

getProxyHostsWhiteList

public java.lang.String[] getProxyHostsWhiteList()
Get proxy host white list.


setProxyHostsWhiteList

public void setProxyHostsWhiteList(java.lang.String[] hosts)
Set proxy host white list.


getProxyHostsBlackList

public java.lang.String[] getProxyHostsBlackList()
Get proxy host black list.


setProxyHostsBlackList

public void setProxyHostsBlackList(java.lang.String[] hosts)
Set proxy host black list.


getTunnelTimeoutMs

public int getTunnelTimeoutMs()

handle

public void handle(java.lang.String pathInContext,
                   java.lang.String pathParams,
                   org.mortbay.http.HttpRequest request,
                   org.mortbay.http.HttpResponse response)
            throws org.mortbay.http.HttpException,
                   java.io.IOException
Tunnel timeout. IE on win2000 has connections issues with normal timeout handling. This timeout should be set to a low value that will expire to allow IE to see the end of the tunnel connection. / public void setTunnelTimeoutMs(int ms) { _tunnelTimeoutMs = ms; } /* ------------------------------------------------------------


handleConnect

public void handleConnect(java.lang.String pathInContext,
                          java.lang.String pathParams,
                          org.mortbay.http.HttpRequest request,
                          org.mortbay.http.HttpResponse response)
                   throws org.mortbay.http.HttpException,
                          java.io.IOException

customizeConnection

protected void customizeConnection(java.lang.String pathInContext,
                                   java.lang.String pathParams,
                                   org.mortbay.http.HttpRequest request,
                                   java.net.Socket socket)
                            throws java.io.IOException
Customize proxy Socket connection for CONNECT. Method to allow derived handlers to customize the tunnel sockets.


customizeConnection

protected void customizeConnection(java.lang.String pathInContext,
                                   java.lang.String pathParams,
                                   org.mortbay.http.HttpRequest request,
                                   java.net.URLConnection connection)
                            throws java.io.IOException
Customize proxy URL connection. Method to allow derived handlers to customize the connection.


isProxied

protected java.net.URL isProxied(org.mortbay.util.URI uri)
                          throws java.net.MalformedURLException
Is URL Proxied. Method to allow derived handlers to select which URIs are proxied and to where.


isForbidden

protected boolean isForbidden(org.mortbay.util.URI uri)
Is URL Forbidden.


isForbidden

protected boolean isForbidden(java.lang.String scheme,
                              java.lang.String host,
                              int port,
                              boolean openNonPrivPorts)
Is scheme,host & port Forbidden.


sendForbid

protected void sendForbid(org.mortbay.http.HttpRequest request,
                          org.mortbay.http.HttpResponse response,
                          org.mortbay.util.URI uri)
                   throws java.io.IOException
Send Forbidden. Method called to send forbidden response. Default implementation calls sendError(403)