|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectclient.Client
public final class Client
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.
Nested Class Summary | |
---|---|
private class |
Client.CascadeInputOutputHandler
Internal class used to communicate with the mix cascade. |
Field Summary | |
---|---|
private java.net.InetAddress |
CASCADE_ADDRESS
Address of the cascade (cascade's first mix) used to transmit messages. |
private int |
CASCADE_PORT
Port number of the cascade (cascade's first mix) used to transmit messages. |
private int |
CASCADE_TIMEOUT
Period of time, a client waits for the cascade to accept his connection request in ms. |
private ClientInputStream |
clientInputStream
ClientInputStream for client communication. |
private ClientOutputStream |
clientOutputStream
ClientOutputStream for client communication. |
private Cryptography |
cryptography
Used to perform cryptographic operations (decrypting, encrypting, generating session keys, MACs... ). |
private static InternalInformationPortController |
internalInformationPort
Reference on component InternalInformationPort . |
private boolean |
isChannelEstablished
Indicates whether a channel to the cascade is established or not. |
private boolean |
isDisconnectRequested
Indicates whether the user (application) called disconnect()
and therefore wants to release his/its connection to the
cascade. |
private boolean |
isFirstWriteDone
Indicates whether the user (application) has already put data in the OutputStream (used to start the ). |
private boolean |
isReadMethodReturnForced
Indicates whether the method receiveDataFromCascade() shall
return all data received so far, no matter how much data it is waiting
for (since no further data can be expected from the cascade). |
private boolean |
isReadMethodWaiting
Indicates whether the method receiveDataFromCascade() is
waiting for new data from the cascade (used for synchronization). |
private boolean |
isWriteMethodWaiting
Indicates whether the method putInSendBuffer() is
waiting for the CascadeInputOutputHandler to send the
data it gave to it (used for synchronization). |
private static java.util.logging.Logger |
LOGGER
Logger used to log and display information. |
private int |
MAX_CHANNEL_ESTABLISH_MESSAGE_LENGTH
Maximum amount of data (payload), that can be stored in a
ChannelEstablishMessage . |
private int |
MAX_CHANNEL_MESSAGE_LENGTH
Maximum amount of data (payload), that can be stored in a
ChannelMessage . |
private MessageGenerator |
messageGenerator
Used to generate message the mixes are capable of processing. |
private java.net.Socket |
mix
Socket for mix communication. |
private java.io.InputStream |
mixInputStream
MixInputStream for mix communication. |
private java.io.OutputStream |
mixOutputStream
MixOutputStream for mix communication. |
private long |
REACTION_TIME
Period of time to wait between the receival of a Reply
(from the cascade) and the sending of a new Request for
the user (application) to react (= add new data to be sent). |
private int |
RECEIVE_BUFFER_SIZE
Initial size of the receiveBuffer . |
private java.nio.ByteBuffer |
receiveBuffer
Buffer to store incoming data from the cascade. |
private java.lang.Object |
receiveBufferSynchronizer
Object used to synchronize the receiveBuffer . |
private int |
SEND_BUFFER_SIZE
Initial size of the sendBuffer . |
private java.nio.ByteBuffer |
sendBuffer
Buffer to store data that shall be sent to the cascade. |
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. |
private static java.lang.String |
getProperty(java.lang.String key)
Simply used to shorten method calls (calls internalInformationPort.getProperty(key) ). |
private static java.security.PublicKey[] |
getPublicKeys()
Retrieves the public keys of all mixes in the cascade (address of first mix must be specified in property file) for later encryption. |
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. |
private void |
sendMessage(byte[] dataToSend)
Sends the bypassed data to the mix cascade. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static InternalInformationPortController internalInformationPort
InternalInformationPort
.
Used to display and/or log data and read general settings.
private static final java.util.logging.Logger LOGGER
private final java.net.InetAddress CASCADE_ADDRESS
private final int CASCADE_PORT
private final int CASCADE_TIMEOUT
private final int MAX_CHANNEL_ESTABLISH_MESSAGE_LENGTH
ChannelEstablishMessage
.
private final int MAX_CHANNEL_MESSAGE_LENGTH
ChannelMessage
.
private final long REACTION_TIME
Reply
(from the cascade) and the sending of a new Request
for
the user (application) to react (= add new data to be sent). Note: If no
new data or a disconnect request has arrived during this period of time,
a dummy message is sent.
private java.net.Socket mix
private ClientOutputStream clientOutputStream
private ClientInputStream clientInputStream
private java.io.OutputStream mixOutputStream
private java.io.InputStream mixInputStream
private java.nio.ByteBuffer receiveBuffer
private java.lang.Object receiveBufferSynchronizer
receiveBuffer
.
Note: This requires a special object, since the used
ByteBuffer
-object may change during runtime (In Java,
ByteBuffer
s can't be resized. Nevertheless, the buffer's
size must be adjusted in a few cases (when unexpected large
write-requests occur)). Therefore, a permanently available object must
be present.
receiveBuffer
private java.nio.ByteBuffer sendBuffer
private final int RECEIVE_BUFFER_SIZE
receiveBuffer
.
receiveBuffer
private final int SEND_BUFFER_SIZE
sendBuffer
.
sendBuffer
private boolean isChannelEstablished
private boolean isReadMethodWaiting
receiveDataFromCascade()
is
waiting for new data from the cascade (used for synchronization).
receiveDataFromCascade(int)
private boolean isReadMethodReturnForced
receiveDataFromCascade()
shall
return all data received so far, no matter how much data it is waiting
for (since no further data can be expected from the cascade).
receiveDataFromCascade(int)
private boolean isWriteMethodWaiting
putInSendBuffer()
is
waiting for the CascadeInputOutputHandler
to send the
data it gave to it (used for synchronization).
putInSendBuffer(byte[])
private boolean isDisconnectRequested
disconnect()
and therefore wants to release his/its connection to the
cascade.
disconnect()
private boolean isFirstWriteDone
OutputStream
(used to start the ).
called disconnect()
and therefore wants to release his/its connection to the
CascadeInputOutputHandler
at the right time.
disconnect()
private Cryptography cryptography
private MessageGenerator messageGenerator
Constructor Detail |
---|
public Client(java.security.Key[] publicKeysOfMixes)
Client
which uses the bypassed keys to
encrypt messages.
publicKeysOfMixes
- Public keys of the cascade's mixes
(used to encrypt messages).public Client()
Client
which receives the keys (to encrypt
messages) from the cascade's mixes automatically.
Method Detail |
---|
private static java.security.PublicKey[] getPublicKeys()
public ClientInputStream getInputStream()
InputStream
that can be used to receive data
anonymously.
getInputStream
in interface ClientInterface
InputStream
that can be used to receive data
anonymously.
java.io.IOException
- I/O problem occurred.public ClientOutputStream getOutputStream()
OutputStream
that can be used to send data
anonymously.
getOutputStream
in interface ClientInterface
OutputStream
that can be used to send data
anonymously.
java.io.IOException
- I/O problem occurred.public void connect() throws java.io.IOException
connect
in interface ClientInterface
java.io.IOException
- I/O problem occurred.public void disconnect() throws java.io.IOException
disconnect
in interface ClientInterface
java.io.IOException
- I/O problem occurred.protected void putInSendBuffer(byte[] data)
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).
data
- Data to be put in sendBuffer
.private void sendMessage(byte[] dataToSend)
CascadeInputOutputHandler
.
dataToSend
- Data to be sent.protected byte[] receiveDataFromCascade(int amoutOfDataNeeded)
amoutOfDataNeeded
bytes from the mix cascade.
Blocks until amoutOfDataNeeded
bytes are available, or
no further data can be expected from the corresponding communication
partner.
amoutOfDataNeeded
- Number of bytes that shall be read.
private static java.lang.String getProperty(java.lang.String key)
internalInformationPort.getProperty(key)
). Returns the
property with the specified key from the property file.
key
- The property key.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |