message
Class ChannelMessage

java.lang.Object
  extended by message.Message
      extended by message.ChannelMessage
All Implemented Interfaces:
java.lang.Comparable<Message>, BasicMessage, ExternalMessage, Request

public final class ChannelMessage
extends Message
implements Request, ExternalMessage

ExternalMessage used to transmit data on an existing channel. The parts this message consists of are defined in the enumeration ChannelMessagePart. A pair of set and get methods is present for each defined part.

Author:
Karl-Peter Fuchs

Field Summary
static byte IDENTIFIER
          Identifier for this type of message.
private static InternalInformationPortController internalInformationPort
          Reference on component InternalInformationPort.
private static java.util.logging.Logger LOGGER
          Logger used to log and display information.
private  int NUMBER_OF_FURTHER_HOPS
          Number of further hops (= mixes), this message must pass to reach its destination.
 
Constructor Summary
ChannelMessage(byte[] byteMesssage, int numberOfFurtherHops)
          Message constructor used by client.
ChannelMessage(byte[] byteMesssage, User channel, int numberOfFurtherHops)
          Message constructor used by a mix.
 
Method Summary
 byte[] getMAC()
          Returns the MessagePart MAC = The Message Authentication Code (MAC) of this message.
 int getMessageID()
          Returns the MessagePart MESSAGE_ID = An identifieing number, which is the same for every envelope of a mix message.
private  byte[] getPart(ChannelMessagePart messagePart)
          Returns a byte representation of a MessagePart.
 Payload getPayload()
          Returns the MessagePart PAYLOAD.
 byte[] getSignedData()
          Returns the MessagePart SIGNED_DATA.
 void setMAC(byte[] mac)
          Sets the MessagePart MAC to the bypassed value.
 void setMessageID(int newID)
          Sets the MessagePart MESSAGE_ID to the bypassed value.
private  void setPart(ChannelMessagePart messagePart, byte[] data)
          Saves a byte representation of a MessagePart.
 void setPayload(Payload newPayload)
          Sets the MessagePart PAYLOAD to the bypassed value.
 void setSignedData(byte[] newSignedData)
          Sets the MessagePart SIGNED_DATA to the bypassed value.
 java.lang.String toString()
          Returns a simple String representation of this class featuring several message parts.
 
Methods inherited from class message.Message
compareTo, getByteMessage, getChannel, getChannelID, getNextMixChannelID, getTimeOfReceival, setByteMessage, setPayloadRange, setTimeOfReceival
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface message.BasicMessage
getByteMessage, getChannel, getChannelID, getNextMixChannelID, getTimeOfReceival, setByteMessage, setPayloadRange, setTimeOfReceival
 

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.


IDENTIFIER

public static final byte IDENTIFIER
Identifier for this type of message. Necessary since messages are transmitted as byte streams which don't support the instanceOf operator.

See Also:
Constant Field Values

NUMBER_OF_FURTHER_HOPS

private final int NUMBER_OF_FURTHER_HOPS
Number of further hops (= mixes), this message must pass to reach its destination. Used to find a MessagePart's position in the byteMessage which has (a) dynamic start- and/or end-position(s). Note: Message length isn't constant in a cascade.

See Also:
Message.byteMessage, ChannelEstablishMessagePart
Constructor Detail

ChannelMessage

public ChannelMessage(byte[] byteMesssage,
                      User channel,
                      int numberOfFurtherHops)
Message constructor used by a mix.

Constructs a new ChannelMessage with the submitted content (byteMesssage) for the specified user/channel.

Parameters:
byteMesssage - Byte representation of the message (as received from the client/previous mix).
channel - User/channel the message shall be created for.
numberOfFurtherHops - Number of further hops (= mixes), this message must pass.

ChannelMessage

public ChannelMessage(byte[] byteMesssage,
                      int numberOfFurtherHops)
Message constructor used by client.

Constructs a new ChannelMessage with the submitted content (byteMesssage).

Parameters:
byteMesssage - Byte representation of the message (can be empty).
numberOfFurtherHops - Number of mixes in the cascade.
Method Detail

getMAC

public byte[] getMAC()
Returns the MessagePart MAC = The Message Authentication Code (MAC) of this message.

Returns:
MessagePart MAC.
See Also:
ChannelMessagePart, ChannelMessagePart.MAC

setMAC

public void setMAC(byte[] mac)
            throws MessagePartHasWrongSizeException
Sets the MessagePart MAC to the bypassed value.

Parameters:
mac - The Message Authentication Code (MAC) of this message.
Throws:
MessagePartHasWrongSizeException
See Also:
ChannelMessagePart, ChannelMessagePart.MAC

getMessageID

public int getMessageID()
Returns the MessagePart MESSAGE_ID = An identifieing number, which is the same for every envelope of a mix message. Used to trace messages for debugging. Can only be read correctly, when current envelope is decrypted! Note: For testing only (MAKES MIX INSECURE)!

Specified by:
getMessageID in interface BasicMessage
Overrides:
getMessageID in class Message
Returns:
MessagePart MESSAGE_ID.
See Also:
ChannelMessagePart, ChannelMessagePart.MESSAGE_ID

setMessageID

public void setMessageID(int newID)
Sets the MessagePart MESSAGE_ID to the bypassed value.

Specified by:
setMessageID in interface BasicMessage
Overrides:
setMessageID in class Message
Parameters:
newID - An identifieing number, which is the same for every envelope of a mix message. Used to trace messages for debugging. Can only be set correctly, when current envelope is decrypted! Note: For testing only (MAKES MIX INSECURE)!
See Also:
ChannelMessagePart, ChannelMessagePart.MESSAGE_ID

getPayload

public Payload getPayload()
Returns the MessagePart PAYLOAD.

Returns:
MessagePart PAYLOAD.
See Also:
ChannelMessagePart, ChannelMessagePart.PAYLOAD

setPayload

public void setPayload(Payload newPayload)
                throws MessagePartHasWrongSizeException
Sets the MessagePart PAYLOAD to the bypassed value.

Parameters:
newPayload - Payload to be set.
Throws:
MessagePartHasWrongSizeException
See Also:
ChannelMessagePart, ChannelMessagePart.PAYLOAD

getSignedData

public byte[] getSignedData()
Returns the MessagePart SIGNED_DATA.

Returns:
MessagePart SIGNED_DATA.
See Also:
ChannelMessagePart, ChannelMessagePart.SIGNED_DATA

setSignedData

public void setSignedData(byte[] newSignedData)
                   throws MessagePartHasWrongSizeException
Sets the MessagePart SIGNED_DATA to the bypassed value.

Parameters:
newSignedData - The signed data to be set.
Throws:
MessagePartHasWrongSizeException
See Also:
ChannelMessagePart, ChannelMessagePart.SIGNED_DATA

getPart

private byte[] getPart(ChannelMessagePart messagePart)
Returns a byte representation of a MessagePart. Example of usage: getPart(ChannelMessagePart.NAME_OF_ENUM_CONSTANT);

Parameters:
messagePart - Enum constant who's byte representation shall be retrieved (= "type" of the part).
Returns:
Byte representation of the MessagePart suiting the bypassed enum constant.
See Also:
ChannelMessagePart

setPart

private void setPart(ChannelMessagePart messagePart,
                     byte[] data)
              throws MessagePartHasWrongSizeException
Saves a byte representation of a MessagePart. Example of usage: setPart(ChannelMessagePart.NAME_OF_ENUM_CONSTANT, data);

Parameters:
messagePart - Enum constant who's byte representation shall be saved.
data - Byte representation of the MessagePart to be saved.
Throws:
MessagePartHasWrongSizeException - Thrown when a MessagePart that shall be assigned is of wrong size.
See Also:
ChannelMessagePart

toString

public java.lang.String toString()
Returns a simple String representation of this class featuring several message parts. Note: Output is only correct for decrypted messages.

Overrides:
toString in class java.lang.Object
Returns:
A simple String representation of this class featuring several message parts