testEnvironment
Class ClientSimulator

java.lang.Object
  extended by java.lang.Thread
      extended by testEnvironment.ClientSimulator
All Implemented Interfaces:
java.lang.Runnable

final class ClientSimulator
extends java.lang.Thread

Simulates a Clients behavior using its InputStream and OutputStream according to the following logic: "Send K bytes of data with a delay of L ms between sending, M times."

K, L and M are taken from the property file (TestEnvironmentProperties.txt).

Author:
Karl-Peter Fuchs

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static InternalInformationPortController internalInformationPort
          Reference on component InternalInformationPort.
private static java.util.logging.Logger LOGGER
          Logger used to log and display information.
private  java.security.Key[] publicKeysOfMixes
          Public keys of the mix used to encrypt messages.
private static java.util.Random random
          Random number generator.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected ClientSimulator()
          Generates a new ClientSimulator that can be used to simulates a Clients behavior using its InputStream and OutputStream according to the following logic: "Send K bytes of data with a delay of L ms between sending, M times."
 
Method Summary
private  byte[] generateRandomMessage(int size)
          Generates a random byte message (each byte represents a number between 0 and 9 (both inclusive; ANSI)).
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.
private static int getUpperBound(java.lang.String expression)
          Returns x from a bypassed String of from RANDOM-x, where x is a number (e. g.
protected static int getVariable(java.lang.String variableKey)
          Returns the value of one of the variables X, Y, Z, K, L, or M from property file (as specified by the bypassed value).
 void run()
          Simulates a Client's behavior.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

internalInformationPort

private static InternalInformationPortController internalInformationPort
Reference on component InternalInformationPort. Used to display and/or log data and read general settings.


LOGGER

private static final java.util.logging.Logger LOGGER
Logger used to log and display information.


random

private static java.util.Random random
Random number generator.


publicKeysOfMixes

private java.security.Key[] publicKeysOfMixes
Public keys of the mix used to encrypt messages.

Constructor Detail

ClientSimulator

protected ClientSimulator()
Generates a new ClientSimulator that can be used to simulates a Clients behavior using its InputStream and OutputStream according to the following logic: "Send K bytes of data with a delay of L ms between sending, M times."

K, L and M are taken from the property file (TestEnvironmentProperties.txt).

Method Detail

run

public void run()
Simulates a Client's behavior.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

generateRandomMessage

private byte[] generateRandomMessage(int size)
Generates a random byte message (each byte represents a number between 0 and 9 (both inclusive; ANSI)).

Parameters:
size - Length of the random byte message to be created.
Returns:
A random byte message.

getVariable

protected static int getVariable(java.lang.String variableKey)
Returns the value of one of the variables X, Y, Z, K, L, or M from property file (as specified by the bypassed value).

Parameters:
variableKey - Name (=key) of the variable (=property) to be returned.
Returns:
Value of the specified variable.

getUpperBound

private static int getUpperBound(java.lang.String expression)
Returns x from a bypassed String of from RANDOM-x, where x is a number (e. g. "RANDOM-1000"). Used to get the upper bound for a randomly chosen value for one of the variables X, Y, Z, K, L, or M as specified by the user in property file.

Parameters:
expression - String containing the upper bound.
Returns:
Upper bound extracted from the bypassed String.

getPublicKeys

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.

Returns:
The public keys of all mixes in the cascade.