client
Class Client

java.lang.Object
  extended by client.Client
All Implemented Interfaces:
ClientInterface

public final class Client
extends java.lang.Object
implements ClientInterface

The Client used to anonymize data (e. g. from a user's application) via a cascade of mixes. Follows the "everything is a stream" concept. See architectureInterfaces.ClientInterface. From a user perspective, this Client behaves quite equal to a socket (java.net.Socket) and therefore abstracts from the underlying technique.

Author:
Karl-Peter Fuchs

Constructor Summary
Client()
          Creates a new Client which receives the keys (to encrypt messages) from the cascade's mixes automatically.
Client(java.security.Key[] publicKeysOfMixes)
          Creates a new Client which uses the bypassed keys to encrypt messages.
 
Method Summary
 void connect()
          Connects client to the mix cascade, specified in property file.
 void disconnect()
          Disconnects client from mix cascade.
 ClientInputStream getInputStream()
          Returns an InputStream that can be used to receive data anonymously.
 ClientOutputStream getOutputStream()
          Returns an OutputStream that can be used to send data anonymously.
protected  void putInSendBuffer(byte[] data)
          Adds the bypassed data to the sendBuffer (from where it gets transmitted to the mix cascade by CascadeInputOutputHandler ).
protected  byte[] receiveDataFromCascade(int amoutOfDataNeeded)
          Tries to read amoutOfDataNeeded bytes from the mix cascade.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Client

public Client(java.security.Key[] publicKeysOfMixes)
Creates a new Client which uses the bypassed keys to encrypt messages.

Parameters:
publicKeysOfMixes - Public keys of the cascade's mixes (used to encrypt messages).

Client

public Client()
Creates a new Client which receives the keys (to encrypt messages) from the cascade's mixes automatically.

Method Detail

getInputStream

public ClientInputStream getInputStream()
Returns an InputStream that can be used to receive data anonymously.

Specified by:
getInputStream in interface ClientInterface
Returns:
InputStream that can be used to receive data anonymously.
Throws:
java.io.IOException - I/O problem occurred.

getOutputStream

public ClientOutputStream getOutputStream()
Returns an OutputStream that can be used to send data anonymously.

Specified by:
getOutputStream in interface ClientInterface
Returns:
OutputStream that can be used to send data anonymously.
Throws:
java.io.IOException - I/O problem occurred.

connect

public void connect()
             throws java.io.IOException
Connects client to the mix cascade, specified in property file.

Specified by:
connect in interface ClientInterface
Throws:
java.io.IOException - I/O problem occurred.

disconnect

public void disconnect()
                throws java.io.IOException
Disconnects client from mix cascade.

Specified by:
disconnect in interface ClientInterface
Throws:
java.io.IOException - I/O problem occurred.

putInSendBuffer

protected void putInSendBuffer(byte[] data)
Adds the bypassed data to the sendBuffer (from where it gets transmitted to the mix cascade by CascadeInputOutputHandler ). Blocks until all data is written (if data doesn't fit in buffer).

Parameters:
data - Data to be put in sendBuffer.

receiveDataFromCascade

protected byte[] receiveDataFromCascade(int amoutOfDataNeeded)
Tries to read amoutOfDataNeeded bytes from the mix cascade. Blocks until amoutOfDataNeeded bytes are available, or no further data can be expected from the corresponding communication partner.

Parameters:
amoutOfDataNeeded - Number of bytes that shall be read.
Returns:
Read data.