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.
 
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.
 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.
 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

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
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

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