anon.client
Class AnonClient

java.lang.Object
  extended by anon.client.AnonClient
All Implemented Interfaces:
AnonService, DataChainErrorListener, java.util.Observer

public class AnonClient
extends java.lang.Object
implements AnonService, java.util.Observer, DataChainErrorListener

Author:
Stefan Lieske

Nested Class Summary
private static interface AnonClient.StatusThread
           
 
Field Summary
private static int CONNECT_TIMEOUT
           
static int DEFAULT_LOGIN_TIMEOUT
           
private static boolean ENABLE_CONTROL_CHANNEL_TEST
           
private static int FAST_LOGIN_TIMEOUT
           
private  IAIEventListener m_aiEventListener
           
private  boolean m_connected
           
private  DummyTrafficControlChannel m_dummyTrafficControlChannel
           
private  int m_dummyTrafficInterval
           
private  java.util.Vector m_eventListeners
           
private  java.lang.Object m_internalSynchronization
           
private  java.lang.Object m_internalSynchronizationForDummyTraffic
           
private  java.lang.Object m_internalSynchronizationForSocket
           
private  KeyExchangeManager m_keyExchangeManager
           
private static int m_loginTimeout
           
private static int m_loginTimeoutFastAvailable
           
private  Multiplexer m_multiplexer
           
private  PacketCounter m_packetCounter
           
private  IMutableProxyInterface m_proxyInterface
           
private  JobQueue m_queuePacketCount
           
private  IServiceContainer m_serviceContainer
           
private  SocketHandler m_socketHandler
           
private  IStreamConnection m_streamConnection
           
private  java.lang.Thread m_threadInitialise
           
private  java.lang.Object SYNC_SHUTDOWN
           
 
Fields inherited from interface anon.AnonService
ANONLIB_VERSION
 
Constructor Summary
AnonClient()
           
AnonClient(IStreamConnection a_theConnection)
           
 
Method Summary
 void addEventListener(AnonServiceEventListener a_eventListener)
          Adds an AnonServiceEventListener.
private  void closeSocketHandler()
           
 void connectionEstablished(AnonServerDescription a_serverDescription)
           
private  IStreamConnection connectMixCascade(MixCascade a_mixCascade, ImmutableProxyInterface a_proxyInterface)
           
 AnonChannel createChannel(int a_type)
          Creates a new AnonChannel, which could be used for transmitting data.
 void dataChainErrorSignaled()
           
private  int finishInitialization(Multiplexer a_multiplexer, KeyExchangeManager a_keyExchangeManager, PacketCounter a_packetCounter, IStreamConnection a_connection, IServiceContainer a_serviceContainer, MixCascade a_cascade)
           
private static int getInternalLoginTimeout(IServiceContainer a_serviceContainer)
           
static int getLoginTimeout()
           
 int initialize(AnonServerDescription a_mixCascade, IServiceContainer a_serviceContainer, TermsAndConditionConfirmation termsConfirmation)
          Initializes this AnonService.
private  int initializeProtocol(IStreamConnection a_connectionToMixCascade, AnonServerDescription a_mixCascade, IServiceContainer a_serviceContainer, TermsAndConditionConfirmation termsConfirmation)
           
 boolean isConnected()
          Returns true if this Anon Service is connected, e.g.
private  void reconnect(java.lang.Object a_argument)
           
 void removeEventListener(AnonServiceEventListener a_eventListener)
          Removes an AnonServiceEventListener.
 void removeEventListeners()
           
private static void resetInternalLoginTimeout()
           
 void setDummyTraffic(int a_interval)
           
static void setLoginTimeout(int a_loginTimeoutMS)
           
 int setProxy(IMutableProxyInterface a_proxyInterface)
          Sets the settings ofr the proxy, which should be used to establish network connections
 void shutdown(boolean a_bResetTransferredBytes)
          Disconnects form the server.
 void update(java.util.Observable a_object, java.lang.Object a_argument)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENABLE_CONTROL_CHANNEL_TEST

private static boolean ENABLE_CONTROL_CHANNEL_TEST

DEFAULT_LOGIN_TIMEOUT

public static final int DEFAULT_LOGIN_TIMEOUT
See Also:
Constant Field Values

FAST_LOGIN_TIMEOUT

private static final int FAST_LOGIN_TIMEOUT
See Also:
Constant Field Values

CONNECT_TIMEOUT

private static final int CONNECT_TIMEOUT
See Also:
Constant Field Values

m_loginTimeout

private static int m_loginTimeout

m_loginTimeoutFastAvailable

private static int m_loginTimeoutFastAvailable

m_multiplexer

private Multiplexer m_multiplexer

m_queuePacketCount

private JobQueue m_queuePacketCount

m_proxyInterface

private IMutableProxyInterface m_proxyInterface

m_internalSynchronization

private java.lang.Object m_internalSynchronization

m_serviceContainer

private IServiceContainer m_serviceContainer

m_threadInitialise

private java.lang.Thread m_threadInitialise

SYNC_SHUTDOWN

private java.lang.Object SYNC_SHUTDOWN

m_internalSynchronizationForSocket

private java.lang.Object m_internalSynchronizationForSocket

m_internalSynchronizationForDummyTraffic

private java.lang.Object m_internalSynchronizationForDummyTraffic

m_socketHandler

private SocketHandler m_socketHandler

m_eventListeners

private java.util.Vector m_eventListeners

m_packetCounter

private PacketCounter m_packetCounter

m_dummyTrafficControlChannel

private DummyTrafficControlChannel m_dummyTrafficControlChannel

m_dummyTrafficInterval

private int m_dummyTrafficInterval

m_keyExchangeManager

private KeyExchangeManager m_keyExchangeManager

m_streamConnection

private IStreamConnection m_streamConnection

m_connected

private boolean m_connected

m_aiEventListener

private IAIEventListener m_aiEventListener
Constructor Detail

AnonClient

public AnonClient()

AnonClient

public AnonClient(IStreamConnection a_theConnection)
Method Detail

initialize

public int initialize(AnonServerDescription a_mixCascade,
                      IServiceContainer a_serviceContainer,
                      TermsAndConditionConfirmation termsConfirmation)
Description copied from interface: AnonService
Initializes this AnonService. Depending on the AnonService, this may establish a connection to an AnonServer, which is described through the anonService parameter. This method must be called before any Channels could be created.

Specified by:
initialize in interface AnonService
Parameters:
a_mixCascade - AnonServer to use
Returns:
E_SUCCESS, if the connection could be established

setLoginTimeout

public static void setLoginTimeout(int a_loginTimeoutMS)

resetInternalLoginTimeout

private static void resetInternalLoginTimeout()

getInternalLoginTimeout

private static int getInternalLoginTimeout(IServiceContainer a_serviceContainer)

getLoginTimeout

public static int getLoginTimeout()

setProxy

public int setProxy(IMutableProxyInterface a_proxyInterface)
Description copied from interface: AnonService
Sets the settings ofr the proxy, which should be used to establish network connections

Specified by:
setProxy in interface AnonService
Returns:
E_SUCCESS, if ok

shutdown

public void shutdown(boolean a_bResetTransferredBytes)
Description copied from interface: AnonService
Disconnects form the server.

Specified by:
shutdown in interface AnonService

isConnected

public boolean isConnected()
Description copied from interface: AnonService
Returns true if this Anon Service is connected, e.g. initialized and useable

Specified by:
isConnected in interface AnonService

createChannel

public AnonChannel createChannel(int a_type)
                          throws java.net.ConnectException
Description copied from interface: AnonService
Creates a new AnonChannel, which could be used for transmitting data. There is a limit of 50 channels per AnonService-connection, in order to prevent Denial of Service-attacks See AnonChannel for more information.

Specified by:
createChannel in interface AnonService
Parameters:
a_type - the type of the created channel
Returns:
AnonChannel, usefull for data transmisson
Throws:
java.net.ConnectException

addEventListener

public void addEventListener(AnonServiceEventListener a_eventListener)
Description copied from interface: AnonService
Adds an AnonServiceEventListener. This listener will receive events like: ... For more information see AnonServiceEventListener.

Specified by:
addEventListener in interface AnonService
Parameters:
a_eventListener - Listener to add

removeEventListeners

public void removeEventListeners()
Specified by:
removeEventListeners in interface AnonService

removeEventListener

public void removeEventListener(AnonServiceEventListener a_eventListener)
Description copied from interface: AnonService
Removes an AnonServiceEventListener. This Listener will not receive any Events anymore.

Specified by:
removeEventListener in interface AnonService
Parameters:
a_eventListener - Listener, which will be removed

reconnect

private void reconnect(java.lang.Object a_argument)

update

public void update(java.util.Observable a_object,
                   java.lang.Object a_argument)
Specified by:
update in interface java.util.Observer

dataChainErrorSignaled

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

setDummyTraffic

public void setDummyTraffic(int a_interval)

connectMixCascade

private IStreamConnection connectMixCascade(MixCascade a_mixCascade,
                                            ImmutableProxyInterface a_proxyInterface)
                                     throws java.io.InterruptedIOException
Throws:
java.io.InterruptedIOException

initializeProtocol

private int initializeProtocol(IStreamConnection a_connectionToMixCascade,
                               AnonServerDescription a_mixCascade,
                               IServiceContainer a_serviceContainer,
                               TermsAndConditionConfirmation termsConfirmation)

connectionEstablished

public void connectionEstablished(AnonServerDescription a_serverDescription)

finishInitialization

private int finishInitialization(Multiplexer a_multiplexer,
                                 KeyExchangeManager a_keyExchangeManager,
                                 PacketCounter a_packetCounter,
                                 IStreamConnection a_connection,
                                 IServiceContainer a_serviceContainer,
                                 MixCascade a_cascade)

closeSocketHandler

private void closeSocketHandler()