Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.openqa.selenium.server
Class ProxyHandler

    java.lang.Object
      org.mortbay.http.handler.AbstractHttpHandler
          org.openqa.selenium.server.ProxyHandler

All Implemented Interfaces:
  java.io.Serializable, org.mortbay.http.HttpHandler, org.mortbay.util.LifeCycle

    public class ProxyHandler

extends org.mortbay.http.handler.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.34 2005/10/05 13:32:59 gregwilkins Exp $
Author:
  Greg Wilkins (gregw), giacof@tiscali.it (chained proxy)
See Also:
  Serialized Form

Field Summary
`protected java.util.HashSet<java.lang.Integer>` | `_allowedConnectPorts` Set of allowed CONNECT ports.
`protected org.mortbay.util.StringMap` | `_DontProxyHeaders` Map of leg by leg headers (not end to end).
`protected org.mortbay.util.StringMap` | `_ProxyAuthHeaders` Map of leg by leg headers (not end to end).
`protected java.util.Set<java.lang.String>` | `_proxyHostsBlackList`
`protected java.util.Set<java.lang.String>` | `_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`

Constructor Summary
`ProxyHandler(boolean trustAllSSLCertificates, java.lang.String dontInjectRegex, java.lang.String debugURL, boolean proxyInjectionMode, boolean forceProxyChain)`

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.
`void` | `generateSSLCertsForLoggingHosts(org.mortbay.http.HttpServer server)`
`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)`
`void` | `handleConnect(java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response)`
`boolean` | `isAnonymous()`
`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.
`static void` | `main(java.lang.String[] args)`
`protected org.mortbay.http.HttpTunnel` | `newHttpTunnel(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, java.net.InetAddress iaddr, int port, int timeoutMS)`
`protected long` | `proxyPlainTextRequest(java.net.URL url, java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response)`
`protected void` | `sendForbid(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, org.mortbay.util.URI uri)` Send Forbidden.
`protected void` | `sendNotFound(org.mortbay.http.HttpResponse response)` Send not found.
`void` | `setAnonymous(boolean anonymous)`
`void` | `setProxyHostsBlackList(java.lang.String[] hosts)` Set proxy host black list.
`void` | `setProxyHostsWhiteList(java.lang.String[] hosts)` Set proxy host white list.
`void` | `setShutdownLock(java.lang.Object shutdownLock)`
`void` | `setSslKeystorePath(java.lang.String sslKeystorePath)`
`void` | `setTunnelTimeoutMs(int ms)` Tunnel timeout.
`boolean` | `shouldInject(java.lang.String path)`
`void` | `start()`

Methods inherited from class org.mortbay.http.handler.AbstractHttpHandler
`getHttpContext, getName, handleTrace, initialize, isStarted, setName, stop, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### _proxyHostsWhiteList

    protected java.util.Set<java.lang.String> _proxyHostsWhiteList

### _proxyHostsBlackList

    protected java.util.Set<java.lang.String> _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.

### _ProxyAuthHeaders

    protected org.mortbay.util.StringMap _ProxyAuthHeaders

  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<java.lang.Integer> _allowedConnectPorts

  Set of allowed CONNECT ports.

Constructor Detail

### ProxyHandler

    public ProxyHandler(boolean trustAllSSLCertificates,
                        java.lang.String dontInjectRegex,
                        java.lang.String debugURL,
                        boolean proxyInjectionMode,
                        boolean forceProxyChain)

Method Detail

### start

    public void start()
               throws java.lang.Exception

  Specified by:
    `start` in interface `org.mortbay.util.LifeCycle`
  Overrides:
    `start` in class `org.mortbay.http.handler.AbstractHttpHandler`
  Throws:
    `java.lang.Exception`

### getProxyHostsWhiteList

    public java.lang.String[] getProxyHostsWhiteList()

  Get proxy host white list.

  Returns:
    Array of hostnames and IPs that are proxied, or an empty array if all hosts are proxied.

### setProxyHostsWhiteList

    public void setProxyHostsWhiteList(java.lang.String[] hosts)

  Set proxy host white list.

  Parameters:
    `hosts` - Array of hostnames and IPs that are proxied, or null if all hosts are proxied.

### getProxyHostsBlackList

    public java.lang.String[] getProxyHostsBlackList()

  Get proxy host black list.

  Returns:
    Array of hostnames and IPs that are NOT proxied.

### setProxyHostsBlackList

    public void setProxyHostsBlackList(java.lang.String[] hosts)

  Set proxy host black list.

  Parameters:
    `hosts` - Array of hostnames and IPs that are NOT proxied.

### getTunnelTimeoutMs

    public int getTunnelTimeoutMs()

### setTunnelTimeoutMs

    public void setTunnelTimeoutMs(int ms)

  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.

### 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

  Throws:
    `org.mortbay.http.HttpException`
    `java.io.IOException`

### proxyPlainTextRequest

    protected long proxyPlainTextRequest(java.net.URL url,
                                         java.lang.String pathInContext,
                                         java.lang.String pathParams,
                                         org.mortbay.http.HttpRequest request,
                                         org.mortbay.http.HttpResponse response)
                                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### shouldInject

    public boolean shouldInject(java.lang.String path)

### main

    public static void main(java.lang.String[] args)
                     throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### generateSSLCertsForLoggingHosts

    public void generateSSLCertsForLoggingHosts(org.mortbay.http.HttpServer server)

### 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

  Throws:
    `org.mortbay.http.HttpException`
    `java.io.IOException`

### newHttpTunnel

    protected org.mortbay.http.HttpTunnel newHttpTunnel(org.mortbay.http.HttpRequest request,
                                                        org.mortbay.http.HttpResponse response,
                                                        java.net.InetAddress iaddr,
                                                        int port,
                                                        int timeoutMS)
                                                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### customizeConnection

    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. 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)

  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.

  Parameters:
    `uri` - The requested URI, which should include a scheme, host and port.
  Returns:
    The URL to proxy to, or null if the passed URI should not be proxied. The default implementation returns the passed uri if isForbidden() returns true.
  Throws:
    `java.net.MalformedURLException`

### isForbidden

    protected boolean isForbidden(org.mortbay.util.URI uri)

  Is URL Forbidden.

  Returns:
    True if the URL is not forbidden. Calls isForbidden(scheme,host,port,true);

### isForbidden

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

  Is scheme,host & port Forbidden.

  Parameters:
    `scheme` - A scheme that mast be in the proxySchemes StringMap.
    `host` - A host that must pass the white and black lists
    `port` - A port that must in the allowedConnectPorts Set
    `openNonPrivPorts` - If true ports greater than 1024 are allowed.
  Returns:
    True if the request to the scheme,host and port is not 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)

  Throws:
    `java.io.IOException`

### sendNotFound

    protected void sendNotFound(org.mortbay.http.HttpResponse response)
                         throws java.io.IOException

  Send not found. Method called to send not found response. Default implementation calls sendError(404)

  Throws:
    `java.io.IOException`

### isAnonymous

    public boolean isAnonymous()

  Returns:
    Returns the anonymous.

### setAnonymous

    public void setAnonymous(boolean anonymous)

  Parameters:
    `anonymous` - The anonymous to set.

### setSslKeystorePath

    public void setSslKeystorePath(java.lang.String sslKeystorePath)

### setShutdownLock

    public void setShutdownLock(java.lang.Object shutdownLock)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009. All Rights Reserved.