anon.proxy
Class AnonProxy

java.lang.Object
  extended by anon.proxy.AnonProxy
All Implemented Interfaces:
AnonServiceEventListener, java.lang.Runnable

public final class AnonProxy
extends java.lang.Object
implements java.lang.Runnable, AnonServiceEventListener

This calls implements a proxy one can use for convienient access to the provided anonymous communication primitives. Below you find an example which creates a proxy which uses the AN.ON mix cascade for anonymous web surfing. AnonProxy theProxy=new AnonProxy(serverSocket,null); theProxy.setMixCascade(new MixCascade(null, null, hostNameOfMixCascade, portNumberOfMixCascade)); theProxy.start();


Nested Class Summary
private  class AnonProxy.DummyMixCascadeContainer
           
private  class AnonProxy.EncapsulatedMixCascadeContainer
           
private  class AnonProxy.OpenSocketRequester
           
 
Field Summary
private  boolean bShuttingDown
           
static int E_BIND
           
static int E_MIX_PROTOCOL_NOT_SUPPORTED
           
static int E_SIGNATURE_CHECK_FIRSTMIX_FAILED
           
static int E_SIGNATURE_CHECK_OTHERMIX_FAILED
           
private  AnonService m_Anon
           
private  java.util.Vector m_anonServiceListener
           
private  boolean m_bReconnecting
           
private  ProxyCallbackHandler m_callbackHandler
           
private  AbstractMixCascadeContainer m_currentMixCascade
          Stores the MixCascade we are connected to.
private  MixminionServiceDescription m_currentMixminionParams
          Stores the Mixminion params.
private  TorAnonServerDescription m_currentTorParams
          Stores the Tor params.
private  DecompressionProxyCallback m_decompressionProxyCallback
           
private  boolean m_forwardedConnection
          Stores, whether we use a forwarded connection (already active, when AnonProxy is created) or not.
private  HTTPProxyCallback m_httpProxyCallback
           
private  int m_maxDummyTrafficInterval
          Stores the maximum dummy traffic interval in milliseconds -> we need dummy traffic with at least that rate.
private  int m_maxRequests
           
private  AnonService m_Mixminion
           
private  int m_numChannels
           
private  IMutableProxyInterface m_proxyInterface
           
private  IProxyListener m_ProxyListener
           
private  java.net.ServerSocket m_socketListener
           
private  AnonService m_Tor
           
static int MIN_REQUESTS
           
private static int RECONNECT_INTERVAL
           
private  java.lang.Object SHUTDOWN_SYNC
           
private  TermsAndConditionConfirmation termsConfirmation
           
private  java.lang.Object THREAD_SYNC
           
private  java.lang.Thread threadRun
           
static int UNLIMITED_REQUESTS
           
 
Constructor Summary
AnonProxy(java.net.ServerSocket a_listener, IMutableProxyInterface a_proxyInterface, TermsAndConditionConfirmation termsConfirmation)
          Creates a new AnonProxy.
AnonProxy(java.net.ServerSocket a_listener, IStreamConnection a_proxyConnection, int a_maxDummyTrafficInterval, TermsAndConditionConfirmation termsConfirmation)
          Creates a new AnonProxy with an already active mix connection.
AnonProxy(java.net.ServerSocket a_listener, TermsAndConditionConfirmation termsConfirmation)
          Creates a new AnonProxy.
 
Method Summary
 void addEventListener(AnonServiceEventListener l)
           
 void addHTTPConnectionListener(AbstractHTTPConnectionListener listener)
           
 void connecting(AnonServerDescription a_serverDescription)
           
 void connectionError()
           
 void connectionEstablished(AnonServerDescription a_serverDescription)
           
(package private)  AnonChannel createChannel(int type)
           
 void dataChainErrorSignaled()
           
protected  void decNumChannels()
           
 void disableProxyCallback(ProxyCallback callback)
           
 void disconnected()
           
 void enableProxyCallback(ProxyCallback callback)
           
private  void fireConnecting(AnonServerDescription a_serverDescription)
           
private  void fireConnectionError()
           
private  void fireConnectionEstablished(AnonServerDescription a_serverDescription)
           
private  void fireDisconnected()
           
 int getMaxConcurrentRequests()
           
 MixCascade getMixCascade()
          Returns the current Mix cascade
 MixminionServiceDescription getMixminionParams()
           
 TorAnonServerDescription getTorParams()
           
protected  void incNumChannels()
           
 boolean isConnected()
           
 void packetMixed(long a_totalBytes)
           
(package private)  void reconnect()
           
 void removeEventListener(AnonServiceEventListener l)
           
 void removeHTTPConnectionListener(AbstractHTTPConnectionListener listener)
           
 void run()
           
 void setDummyTraffic(int a_interval)
          Changes the dummy traffic interval on the connection to the server.
 void setHTTPDecompressionEnabled(boolean enable)
           
 void setHTTPHeaderProcessingEnabled(boolean enable)
           
 void setMaxConcurrentRequests(int a_maxRequests)
           
 void setMixminionParams(MixminionServiceDescription newMixminionParams)
          Sets the parameter for Mixminion (anonymous remailer).
 void setProxyListener(IProxyListener l)
           
 void setTorParams(TorAnonServerDescription newTorParams)
          Sets the parameter for TOR (anonymous SOCKS).
 int start(AbstractMixCascadeContainer a_newMixCascade)
           
 void stop()
           
protected  void transferredBytes(long bytes, int protocolType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNLIMITED_REQUESTS

public static final int UNLIMITED_REQUESTS
See Also:
Constant Field Values

MIN_REQUESTS

public static final int MIN_REQUESTS
See Also:
Constant Field Values

E_BIND

public static final int E_BIND
See Also:
Constant Field Values

E_MIX_PROTOCOL_NOT_SUPPORTED

public static final int E_MIX_PROTOCOL_NOT_SUPPORTED
See Also:
Constant Field Values

E_SIGNATURE_CHECK_FIRSTMIX_FAILED

public static final int E_SIGNATURE_CHECK_FIRSTMIX_FAILED
See Also:
Constant Field Values

E_SIGNATURE_CHECK_OTHERMIX_FAILED

public static final int E_SIGNATURE_CHECK_OTHERMIX_FAILED
See Also:
Constant Field Values

RECONNECT_INTERVAL

private static final int RECONNECT_INTERVAL
See Also:
Constant Field Values

m_maxRequests

private int m_maxRequests

m_Anon

private AnonService m_Anon

m_Tor

private AnonService m_Tor

m_Mixminion

private AnonService m_Mixminion

m_anonServiceListener

private java.util.Vector m_anonServiceListener

threadRun

private java.lang.Thread threadRun

m_socketListener

private java.net.ServerSocket m_socketListener

m_proxyInterface

private IMutableProxyInterface m_proxyInterface

m_ProxyListener

private IProxyListener m_ProxyListener

m_numChannels

private volatile int m_numChannels

m_bReconnecting

private boolean m_bReconnecting

THREAD_SYNC

private final java.lang.Object THREAD_SYNC

SHUTDOWN_SYNC

private final java.lang.Object SHUTDOWN_SYNC

bShuttingDown

private boolean bShuttingDown

m_callbackHandler

private final ProxyCallbackHandler m_callbackHandler

m_httpProxyCallback

private HTTPProxyCallback m_httpProxyCallback

m_decompressionProxyCallback

private DecompressionProxyCallback m_decompressionProxyCallback

termsConfirmation

private TermsAndConditionConfirmation termsConfirmation

m_currentMixCascade

private AbstractMixCascadeContainer m_currentMixCascade
Stores the MixCascade we are connected to.


m_currentTorParams

private TorAnonServerDescription m_currentTorParams
Stores the Tor params.


m_currentMixminionParams

private MixminionServiceDescription m_currentMixminionParams
Stores the Mixminion params.


m_forwardedConnection

private boolean m_forwardedConnection
Stores, whether we use a forwarded connection (already active, when AnonProxy is created) or not.


m_maxDummyTrafficInterval

private int m_maxDummyTrafficInterval
Stores the maximum dummy traffic interval in milliseconds -> we need dummy traffic with at least that rate. If this value is -1, there is no need for dummy traffic on a forwarded connection on the server side. This value is only meaningful, if m_forwardedConnection is true.

Constructor Detail

AnonProxy

public AnonProxy(java.net.ServerSocket a_listener,
                 TermsAndConditionConfirmation termsConfirmation)
Creates a new AnonProxy. This proxy uses as default only the AN.ON service. If you also want to use TOR and Mixminion you have to enable them by calling setTorParams() and setMixmininoParams().

Parameters:
a_listener - A ServerSocket, where the AnonProxy listens for new requests (e.g. from a web browser).
See Also:
setTorParams(), setMixminionParams()

AnonProxy

public AnonProxy(java.net.ServerSocket a_listener,
                 IMutableProxyInterface a_proxyInterface,
                 TermsAndConditionConfirmation termsConfirmation)
Creates a new AnonProxy. This proxy uses as default only the AN.ON service. If you also want to use TOR and Mixminion you have to enable them by calling setTorParams() and setMixmininoParams().

Parameters:
a_listener - A ServerSocket, where the AnonProxy listens for new requests (e.g. from a web browser).
a_proxyInterface - describes a proxy the AnonProxy should use to establish connections to the anon servers (e.g. if you are behind some firewall etc.)
See Also:
setTorParams(), setMixminionParams()

AnonProxy

public AnonProxy(java.net.ServerSocket a_listener,
                 IStreamConnection a_proxyConnection,
                 int a_maxDummyTrafficInterval,
                 TermsAndConditionConfirmation termsConfirmation)
Creates a new AnonProxy with an already active mix connection.

Parameters:
a_listener - A ServerSocket, where the AnonProxy listens for new requests (e.g. from a web browser).
a_proxyConnection - An already open connection to a mix (but not initialized, like keys exchanged, ...).
a_maxDummyTrafficInterval - The minimum dummy traffic rate the connection needs. The value is the maximum dummy traffic interval in milliseconds. Any call of setDummyTraffic(), will respect this maximum interval value -> bigger values set with setDummyTraffic (especially -1) result in that maximum dummy traffic interval value. If this value is -1, there is no need for dummy traffic on that connection on the server side.
Method Detail

enableProxyCallback

public void enableProxyCallback(ProxyCallback callback)

disableProxyCallback

public void disableProxyCallback(ProxyCallback callback)

setHTTPHeaderProcessingEnabled

public void setHTTPHeaderProcessingEnabled(boolean enable)

setHTTPDecompressionEnabled

public void setHTTPDecompressionEnabled(boolean enable)

removeHTTPConnectionListener

public void removeHTTPConnectionListener(AbstractHTTPConnectionListener listener)

addHTTPConnectionListener

public void addHTTPConnectionListener(AbstractHTTPConnectionListener listener)

getMixCascade

public MixCascade getMixCascade()
Returns the current Mix cascade


setTorParams

public void setTorParams(TorAnonServerDescription newTorParams)
Sets the parameter for TOR (anonymous SOCKS). If NULL TOR proxy is disabled.

Parameters:
newTorParams - The new parameters for TOR.
See Also:
TorAnonServerDescription

getTorParams

public TorAnonServerDescription getTorParams()

setMixminionParams

public void setMixminionParams(MixminionServiceDescription newMixminionParams)
Sets the parameter for Mixminion (anonymous remailer). If NULL Mixminion proxy is disabled.

Parameters:
newMixminionParams - The new parameters for Mixminion. If NULL the Mixminion proxy is disabled.
See Also:
MixminionServiceDescription

getMixminionParams

public MixminionServiceDescription getMixminionParams()

setMaxConcurrentRequests

public void setMaxConcurrentRequests(int a_maxRequests)

getMaxConcurrentRequests

public int getMaxConcurrentRequests()

setDummyTraffic

public void setDummyTraffic(int a_interval)
Changes the dummy traffic interval on the connection to the server. This method respects dummy traffic restrictions on a forwarded connection. If there is a minimum dummy traffic rate needed by the server, the dummy traffic interval gets never bigger than that needed rate on a forwarded connection (especially a interval value of -1 is ignored).

Parameters:
a_interval - The interval for dummy traffic on the connection to the server in milliseconds.

stop

public void stop()

run

public void run()
Specified by:
run in interface java.lang.Runnable

createChannel

AnonChannel createChannel(int type)
                    throws NotConnectedToMixException,
                           java.lang.Exception
Throws:
NotConnectedToMixException
java.lang.Exception

reconnect

void reconnect()

setProxyListener

public void setProxyListener(IProxyListener l)

start

public int start(AbstractMixCascadeContainer a_newMixCascade)

decNumChannels

protected void decNumChannels()

incNumChannels

protected void incNumChannels()

transferredBytes

protected void transferredBytes(long bytes,
                                int protocolType)

fireDisconnected

private void fireDisconnected()

fireConnecting

private void fireConnecting(AnonServerDescription a_serverDescription)

fireConnectionEstablished

private void fireConnectionEstablished(AnonServerDescription a_serverDescription)

fireConnectionError

private void fireConnectionError()

connecting

public void connecting(AnonServerDescription a_serverDescription)
Specified by:
connecting in interface AnonServiceEventListener

connectionEstablished

public void connectionEstablished(AnonServerDescription a_serverDescription)
Specified by:
connectionEstablished in interface AnonServiceEventListener

disconnected

public void disconnected()
Specified by:
disconnected in interface AnonServiceEventListener

connectionError

public void connectionError()
Specified by:
connectionError in interface AnonServiceEventListener

addEventListener

public void addEventListener(AnonServiceEventListener l)

removeEventListener

public void removeEventListener(AnonServiceEventListener l)

isConnected

public boolean isConnected()

packetMixed

public void packetMixed(long a_totalBytes)
Specified by:
packetMixed in interface AnonServiceEventListener

dataChainErrorSignaled

public void dataChainErrorSignaled()
Specified by:
dataChainErrorSignaled in interface AnonServiceEventListener