|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
inputOutputHandler.NextMixConnectionHandler
final class NextMixConnectionHandler
Handles communication with the next mix in the cascade.
Establishes a (TCP) connection with the next mix which is used to transmit
messages (Request
s and Reply
ies) of all users
connected to the cascade's fist mix (multiplex channel).
(De-)multiplexes Request
s/Reply
ies using an
(encrypted) header (see generateInterMixHeader()).
Reply
ies are put in the
InputOutputHandlerController
's
replyInputQueue
(see InputOutputHandlerController.addUnprocessedReply()
).
Request
s are taken from the
InputOutputHandlerController
's
requestOutputQueue
(see InputOutputHandlerController.getProcessedRequest()
).
Note: Authentication is NOT implemented!
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private ExternalInformationPortController |
externalInformationPort
Reference on component ExternalInformationPort (Used to
provide the cryptographic key used to encrypt/decrypt multiplex-headers
to the previous mix. |
private java.util.concurrent.atomic.AtomicBoolean |
handleRepliesIsWaitingForConnection
Indicates that method handleReplies() wants to send
replies (to next mix), but the connection is lost (Used for
synchronization, when reestablishing connection). |
private InputOutputHandlerController |
inputOutputHandler
Reference on InputOutputHandlerController() (Used to get
processed replies and add unprocessed requests). |
private int |
INTER_MIX_BLOCK_SIZE
Block size of the cryptographic algorithm used to encrypt the multiplex-header. |
private javax.crypto.Cipher |
interMixDecryptCipherWithNextMix
Cipher for decrypting multiplex-headers of replies. |
private javax.crypto.Cipher |
interMixEncryptCipherWithNextMix
Cipher for encrypting multiplex-headers of requests. |
private javax.crypto.spec.IvParameterSpec |
interMixIVWithNextMix
Initialization vector used to encrypt data between this mix and the next one. |
private javax.crypto.SecretKey |
interMixKeyWithNextMix
Key used to encrypt data between this mix and the next one. |
private static InternalInformationPortController |
internalInformationPort
Reference on component InternalInformationPort . |
private static java.util.logging.Logger |
LOGGER
Logger used to log and display information. |
private java.net.InetAddress |
NEXT_MIX_ADDRESS
Address of the next mix (in the cascade). |
private int |
NEXT_MIX_INFO_PORT
Port number of the next mix' ExternalInformationProvider
component (used to receive key for enrypting/decrypting
multiplex-headers). |
private int |
NEXT_MIX_PORT
Port number of the next mix (in the cascade). |
private java.io.InputStream |
nextMixInputStream
InputStream for communicating with next mix. |
private java.io.OutputStream |
nextMixOutputStream
OutputStream for communicating with next mix. |
private java.net.Socket |
nextMixSocket
Socket for communicating with next mix. |
private int |
POSITION_OF_MIX_IN_CASCADE
The mix' position in the cascade this object belongs to. "1" means "first mix", "2" means "a middle mix" and "3" means "last mix" of cascade. |
private UserDatabaseController |
userDatabase
Reference on component UserDatabase (Used to add/remove
users). |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
protected |
NextMixConnectionHandler(InputOutputHandlerController inputOutputHandler,
UserDatabaseController userDatabase,
ExternalInformationPortController externalInformationPort)
Constructs a new NextMixConnectionHandler which handles
communication with the next mix in the cascade. |
Method Summary | |
---|---|
private void |
connectToNextMix()
Establishes a (permanent) connection to the next mix of the cascade. |
private byte[] |
encryptInterMixHeader(byte[] message)
Encrypts the block containing the multiplex-header of the bypassed message. |
private byte[] |
generateInterMixHeader(Request request)
Adds an (encrypted) header to a Request containing
an identifier for the suiting channel (the identifier is unique for any
neighboured mixes). |
private byte[] |
getPayload(Request request)
Returns the payload of the bypassed Request . |
private static java.lang.String |
getProperty(java.lang.String key)
Simply used to shorten method calls (calls internalInformationPort.getProperty(key) ). |
private void |
handleReplies()
Waits for Reply ies sent by next mix. |
private void |
resetInterMixCiphers()
Resets the Cipher s used to encrypt data between this mix
and the next one. |
void |
run()
Sends processed messages (Requests) to next mix. |
private void |
setUpInterMixCiphers()
Receives a cryptographic key, that is used to encrypt multiplex-headers (between this mix an the next mix) from the next mix and sets up suiting Cipher s. |
private void |
waitForConnection()
Waits until a connection to the next mix is (re)established. |
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 |
---|
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 int POSITION_OF_MIX_IN_CASCADE
private final int INTER_MIX_BLOCK_SIZE
private final java.net.InetAddress NEXT_MIX_ADDRESS
private final int NEXT_MIX_PORT
private final int NEXT_MIX_INFO_PORT
ExternalInformationProvider
component (used to receive key for enrypting/decrypting
multiplex-headers).
private UserDatabaseController userDatabase
UserDatabase
(Used to add/remove
users).
private InputOutputHandlerController inputOutputHandler
InputOutputHandlerController()
(Used to get
processed replies and add unprocessed requests).
InputOutputHandlerController.addUnprocessedRequest(Request)
,
InputOutputHandlerController.getProcessedReply()
private ExternalInformationPortController externalInformationPort
ExternalInformationPort
(Used to
provide the cryptographic key used to encrypt/decrypt multiplex-headers
to the previous mix.
private java.net.Socket nextMixSocket
private java.io.InputStream nextMixInputStream
private java.io.OutputStream nextMixOutputStream
private javax.crypto.Cipher interMixEncryptCipherWithNextMix
private javax.crypto.Cipher interMixDecryptCipherWithNextMix
private javax.crypto.SecretKey interMixKeyWithNextMix
private javax.crypto.spec.IvParameterSpec interMixIVWithNextMix
private java.util.concurrent.atomic.AtomicBoolean handleRepliesIsWaitingForConnection
handleReplies()
wants to send
replies (to next mix), but the connection is lost (Used for
synchronization, when reestablishing connection).
handleReplies()
,
connectToNextMix()
Constructor Detail |
---|
protected NextMixConnectionHandler(InputOutputHandlerController inputOutputHandler, UserDatabaseController userDatabase, ExternalInformationPortController externalInformationPort)
NextMixConnectionHandler
which handles
communication with the next mix in the cascade.
Establishes a (TCP) connection with the next mix which is used to transmit
messages (Request
s and Reply
ies) of all users
connected to the cascade's fist mix (multiplex channel).
(De-)multiplexes Request
s/Reply
ies using an
(encrypted) header (see generateInterMixHeader()).
Reply
ies are put in the
InputOutputHandlerController
's
replyInputQueue
(see InputOutputHandlerController.addUnprocessedReply()
).
Request
s are taken from the
InputOutputHandlerController
's
requestOutputQueue
(see InputOutputHandlerController.getProcessedRequest()
).
Note: Authentication is NOT implemented!
Method Detail |
---|
private void handleReplies()
Reply
ies sent by next mix.
private void waitForConnection()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
InputOutputHandlerController.getProcessedRequest()
private void connectToNextMix()
private byte[] generateInterMixHeader(Request request)
Request
containing
an identifier for the suiting channel (the identifier is unique for any
neighboured mixes).
request
- Request
without header.
Request
with header.private byte[] getPayload(Request request)
Request
.
request
- Request
containing the payload to be
returned.
Request
.private byte[] encryptInterMixHeader(byte[] message)
message
- Message with plaintext multiplex-header.
private void setUpInterMixCiphers()
Cipher
s.
Note: Authentication NOT implemented!
private void resetInterMixCiphers()
Cipher
s used to encrypt data between this mix
and the next one. Must be called when connection was lost, since
Cipher
s might be out of sync in that case.
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 |