|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openqa.jetty.http.handler.AbstractHttpHandler
org.openqa.selenium.server.ProxyHandler
public class ProxyHandler
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.
Nested Class Summary | |
---|---|
static class |
ProxyHandler.SslRelay
|
Field Summary | |
---|---|
protected java.util.HashSet<java.lang.Integer> |
_allowedConnectPorts
Set of allowed CONNECT ports. |
protected StringMap |
_DontProxyHeaders
Map of leg by leg headers (not end to end). |
protected 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 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,
int port)
|
Method Summary | |
---|---|
protected void |
customizeConnection(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest request,
java.net.Socket socket)
Customize proxy Socket connection for CONNECT. |
protected void |
customizeConnection(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest request,
java.net.URLConnection connection)
Customize proxy URL connection. |
void |
generateSSLCertsForLoggingHosts(HttpServer server)
|
java.lang.String[] |
getProxyHostsBlackList()
Get proxy host black list. |
java.lang.String[] |
getProxyHostsWhiteList()
Get proxy host white list. |
protected ProxyHandler.SslRelay |
getSslRelayOrCreateNew(URI uri,
InetAddrPort addrPort,
HttpServer server)
|
int |
getTunnelTimeoutMs()
|
void |
handle(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest request,
HttpResponse response)
Handle a request. |
void |
handleConnect(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest request,
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(URI uri)
Is URL Forbidden. |
protected java.net.URL |
isProxied(URI uri)
Is URL Proxied. |
static void |
main(java.lang.String[] args)
|
protected HttpTunnel |
newHttpTunnel(HttpRequest request,
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,
HttpRequest request,
HttpResponse response)
|
protected void |
sendForbid(HttpRequest request,
HttpResponse response,
URI uri)
Send Forbidden. |
protected void |
sendNotFound(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()
Start the LifeCycle. |
protected void |
wireUpSslWithCyberVilliansCA(java.lang.String host,
ProxyHandler.SslRelay listener)
|
protected void |
wireUpSslWithRemoteService(java.lang.String host,
ProxyHandler.SslRelay listener)
|
Methods inherited from class org.openqa.jetty.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 |
---|
protected java.util.Set<java.lang.String> _proxyHostsWhiteList
protected java.util.Set<java.lang.String> _proxyHostsBlackList
protected int _tunnelTimeoutMs
protected StringMap _DontProxyHeaders
protected StringMap _ProxyAuthHeaders
protected StringMap _ProxySchemes
protected java.util.HashSet<java.lang.Integer> _allowedConnectPorts
Constructor Detail |
---|
public ProxyHandler(boolean trustAllSSLCertificates, java.lang.String dontInjectRegex, java.lang.String debugURL, boolean proxyInjectionMode, boolean forceProxyChain, int port)
Method Detail |
---|
public void start() throws java.lang.Exception
LifeCycle
start
in interface LifeCycle
start
in class AbstractHttpHandler
java.lang.Exception
- An arbitrary exception may be thrown.public java.lang.String[] getProxyHostsWhiteList()
public void setProxyHostsWhiteList(java.lang.String[] hosts)
hosts
- Array of hostnames and IPs that are proxied, or null if all hosts are proxied.public java.lang.String[] getProxyHostsBlackList()
public void setProxyHostsBlackList(java.lang.String[] hosts)
hosts
- Array of hostnames and IPs that are NOT proxied.public int getTunnelTimeoutMs()
public void setTunnelTimeoutMs(int ms)
public void handle(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, HttpResponse response) throws HttpException, java.io.IOException
HttpHandler
pathInContext
- The context pathpathParams
- Path parameters such as encoded Session IDrequest
- The HttpRequest requestresponse
- The HttpResponse response
HttpException
java.io.IOException
protected long proxyPlainTextRequest(java.net.URL url, java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, HttpResponse response) throws java.io.IOException
java.io.IOException
public boolean shouldInject(java.lang.String path)
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public void generateSSLCertsForLoggingHosts(HttpServer server)
public void handleConnect(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, HttpResponse response) throws HttpException, java.io.IOException
HttpException
java.io.IOException
protected ProxyHandler.SslRelay getSslRelayOrCreateNew(URI uri, InetAddrPort addrPort, HttpServer server) throws java.lang.Exception
java.lang.Exception
protected void wireUpSslWithRemoteService(java.lang.String host, ProxyHandler.SslRelay listener) throws java.io.IOException
java.io.IOException
protected void wireUpSslWithCyberVilliansCA(java.lang.String host, ProxyHandler.SslRelay listener)
protected HttpTunnel newHttpTunnel(HttpRequest request, HttpResponse response, java.net.InetAddress iaddr, int port, int timeoutMS) throws java.io.IOException
java.io.IOException
protected void customizeConnection(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, java.net.Socket socket)
protected void customizeConnection(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, java.net.URLConnection connection)
protected java.net.URL isProxied(URI uri) throws java.net.MalformedURLException
uri
- The requested URI, which should include a scheme, host and port.
java.net.MalformedURLException
protected boolean isForbidden(URI uri)
protected boolean isForbidden(java.lang.String scheme, java.lang.String host, int port, boolean openNonPrivPorts)
scheme
- A scheme that mast be in the proxySchemes StringMap.host
- A host that must pass the white and black listsport
- A port that must in the allowedConnectPorts SetopenNonPrivPorts
- If true ports greater than 1024 are allowed.
protected void sendForbid(HttpRequest request, HttpResponse response, URI uri) throws java.io.IOException
java.io.IOException
protected void sendNotFound(HttpResponse response) throws java.io.IOException
java.io.IOException
public boolean isAnonymous()
public void setAnonymous(boolean anonymous)
anonymous
- The anonymous to set.public void setSslKeystorePath(java.lang.String sslKeystorePath)
public void setShutdownLock(java.lang.Object shutdownLock)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |