Class SunProxy
- All Implemented Interfaces:
UseProxy, Handler, SocketFactory
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)
-
Field Summary
Fields inherited from interface SocketFactory
defaultFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCalled when theServeris being initialized to install this object as theSocketFactoryfor theHttpRequest.Creates a newSocketthat talks to the specified port on the named host.booleanHandler http requests - doesn't do anything yetbooleanDetermines if the user should use an HTTP proxy when sending an HTTP request to the specified host and port.
-
Constructor Details
-
SunProxy
public SunProxy()
-
-
Method Details
-
init
Called when theServeris being initialized to install this object as theSocketFactoryfor theHttpRequest.This procedure is very specific and specialized to the Brazil server. This functionality should probably be moved into a separate "Init" class that:
- examines the configuration properties.
- creates a new instace of the
SunProxyclass. - installs this object as the
SocketFactory.
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 theProxyHandlerinstantiate this object as aUseProxydecider, but in that case, no configuration properties need to be examined.- Specified by:
initin interfaceHandler- Parameters:
server- The http server that owns this object. This object usesServer.propsto obtain run time configuration information.prefix- A prefix to prepend to all of the keys that this object uses to extract configuration information out ofServer.props.- Returns:
truealways, indicating success.
-
respond
Handler http requests - doesn't do anything yet -
useProxy
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
SocketFactoryif this method returnstrue.Observed behavior:
- DNS is messed up, and can resolve the hostname of some machines that are not accessible. Simplifying assumption: all #.#.#.# must be proxied
- pangaea.eng(.sun.com) is inside the firewall and accessible via
a direct socket. Return
false. - www.sgi.com and www.microsoft.com are outside the firewall but
accessible via an itelnet socket. Return
false. - www.sun.com and docs.sun.com are outside the firewall but not
accessible via an itelnet socket. Return
true.
-
newSocket
Description copied from interface:SocketFactoryCreates a newSocketthat talks to the specified port on the named host.The implementation may choose any way it wants to provide a socket-like object (essentially any mechanism that supports bidirectional communication). The returned
Socket(or subclass ofSocket) might not be based on TCP/IP, or it might involve running a TCP/IP stack over some other protocol, or it might actually redirect all connections via some other proxy machine, etc.- Specified by:
newSocketin interfaceSocketFactory- Parameters:
host- The host name.port- The port number.- Returns:
- An object that provides socket-like communication.
- Throws:
IOException- If there is some problem establishing the socket to the specified port on the named host.
-