public class GenericProxyHandler extends java.lang.Object implements Handler
AclSwitchHandler
to provide authenticated access to selected web sites.
Properties:
[token].name
and [token].value
define a new http header.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
host |
static java.lang.String |
HOST
Handler configuration property host.
|
protected MapPage |
mapper |
static java.lang.String |
NL |
protected boolean |
noErrorReturn |
protected boolean |
passHost |
protected int |
port |
static java.lang.String |
PORT
Handler configuration property port.
|
protected java.lang.String |
prefix |
static java.lang.String |
PREFIX
Handler configuration property prefix.
|
static java.lang.String |
PROXY_HOST
Handler configuration property proxyHost.
|
static java.lang.String |
PROXY_PORT
Handler configuration property proxyPort.
|
protected java.lang.String |
proxyHost |
protected int |
proxyPort |
protected java.lang.String |
requestPrefix |
protected java.lang.String |
tokens |
protected java.lang.String |
urlPrefix |
Constructor and Description |
---|
GenericProxyHandler() |
Modifier and Type | Method and Description |
---|---|
MapPage |
getMapper()
Return a reference to our page mapper, to allow futzing with the page
maps from the outside
|
boolean |
init(Server server,
java.lang.String prefix)
Do one-time setup.
|
boolean |
isMine(Request request)
See if this is one of my requests.
|
byte[] |
modifyContent(Request request,
byte[] content)
Rewrite the links in an html file so they resolve correctly
in proxy mode.
|
boolean |
respond(Request request)
If this is one of "our" url's, fetch the document from
the destination server, and return it as if it was local.
|
protected boolean |
shouldFilter(MimeHeaders headers)
See if the content needs to be filtered.
|
protected java.lang.String prefix
protected MapPage mapper
protected java.lang.String host
protected int port
protected java.lang.String proxyHost
protected int proxyPort
protected java.lang.String urlPrefix
protected java.lang.String requestPrefix
protected java.lang.String tokens
protected boolean passHost
protected boolean noErrorReturn
public static final java.lang.String PREFIX
public static final java.lang.String HOST
public static final java.lang.String PORT
public static final java.lang.String PROXY_HOST
public static final java.lang.String PROXY_PORT
public static final java.lang.String NL
public boolean init(Server server, java.lang.String prefix)
init
in interface Handler
server
- The HTTP server that created this Handler
.
Typical Handler
s will use Server.props
to obtain run-time configuration information.prefix
- The handlers name.
The string this Handler
may prepend to all
of the keys that it uses to extract configuration information
from Server.props
. This is set (by the Server
and ChainHandler
) to help avoid configuration parameter
namespace collisions.true
if this Handler
initialized
successfully, false
otherwise. If
false
is returned, this Handler
should not be used.public boolean respond(Request request) throws java.io.IOException
respond
in interface Handler
request
- The Request
object that represents the HTTP
request.true
if the request was handled. A request was
handled if a response was supplied to the client, typically
by calling Request.sendResponse()
or
Request.sendError
.java.io.IOException
- if there was an I/O error while sending the response to
the client. Typically, in that case, the Server
will (try to) send an error message to the client and then
close the client's connection.
The IOException
should not be used to silently
ignore problems such as being unable to access some
server-side resource (for example getting a
FileNotFoundException
due to not being able
to open a file). In that case, the Handler
's
duty is to turn that IOException
into a
HTTP response indicating, in this case, that a file could
not be found.
protected boolean shouldFilter(MimeHeaders headers)
headers
- Vector of mime headers for data to proxypublic boolean isMine(Request request)
request
- The standard request objectpublic MapPage getMapper()
public byte[] modifyContent(Request request, byte[] content)
request
- The original request to this "proxy"headers
- The vector of mime headers for the proxy request