sunlabs.brazil.proxy

Class SunProxy

public class SunProxy extends Object implements SocketFactory, UseProxy, Handler

Sun Specific implementation of a SocketFactory and proxy-decider that work together to decipher the specifics of the Sun Internet setup.

NOTE: The mechanism used by this class has been disabled; it is included here to illustrate how to write a custom proxy.

Version: 2.3

Author: Stephen Uhler (stephen.uhler@sun.com) Colin Stevens (colin.stevens@sun.com)

Method Summary
booleaninit(Server server, String prefix)
Called when the Server is being initialized to install this object as the SocketFactory for the HttpRequest.
SocketnewSocket(String host, int port)
booleanrespond(Request request)
Handler http requests - doesn't do anything yet
booleanuseProxy(String host, int port)
Determines if the user should use an HTTP proxy when sending an HTTP request to the specified host and port.

Method Detail

init

public boolean init(Server server, String prefix)
Called when the Server is being initialized to install this object as the SocketFactory for the HttpRequest.

This procedure is very specific and specialized to the Brazil server. This functionality should probably be moved into a separate "Init" class that:

That would disentangle this class from the Brazil server, since nothing else in this class is tied to the implementation.

As it stands now, the first time this method is called, the side effect is to install itself as the SocketFactory. This method will also be called subsequently when instances of the ProxyHandler instantiate this object as a UseProxy decider, but in that case, no configuration properties need to be examined.

Parameters: server The http server that owns this object. This object uses Server.props to obtain run time configuration information. prefix A prefix to prepend to all of the keys that this object uses to extract configuration information out of Server.props.

Returns: true always, indicating success.

newSocket

public Socket newSocket(String host, int port)

respond

public boolean respond(Request request)
Handler http requests - doesn't do anything yet

useProxy

public boolean useProxy(String host, int port)
Determines if the user should use an HTTP proxy when sending an HTTP request to the specified host and port.

Whether or not to proxy may depend upon the HTTP proxy the caller is using. Currently, there is no way to capture and use this information.

The decision is different than deciding if the host is local, because using the itelnet tunnelling trick we can reach some external hosts from within the firewall. This routine is therefore in cohoots with the itelnet behavior, and requires that the caller use this object as the SocketFactory if this method returns true.

Observed behavior:

Parameters: host The host name. port The port number.

Returns: true if the user should send the HTTP request via an HTTP proxy, false if the user can send the HTTP request directly to the specified named host.

UNKNOWN: UseProxy#useProxy