edu.harvard.deas.hyperenc
Class HyperMessage

java.lang.Object
  extended by edu.harvard.deas.hyperenc.HyperMessage
All Implemented Interfaces:
Serializable

public class HyperMessage
extends Object
implements Serializable

A HyperMessage is a hyper-encrypted message sent from one HyperEncryption client to another. It encompasses reconciliation and other protocol messages, as well as actual encrypted messages containing user-specified content.

A HyperMessage has several abstract fields:

HyperMessages are immutable.

See Also:
Serialized Form

Method Summary
 boolean equals(Object o)
          Compares this HyperMessage to the specified object.
 String getContent()
          Returns the content of this message.
 Date getDate()
          Returns the date of this message.
 int getID()
          Returns the unique ID of this message.
static HyperMessage getInstance(HyperMessageType type, Contact sender, Contact recipient, String subject, String content, List<Integer> padsUsed, HyperMAC hemac, Date date)
          Creates and returns a new HyperMessage.
 HyperMAC getMac()
          Returns the HEMAC for this message.
protected static int getNextID()
          Returns the ID that should be assigned to the next new HyperMessage created.
 List<Integer> getPadsUsed()
          Returns a list of IDs of blocks used to encrypt this message.
 Contact getRecipient()
          Returns the recipient of this message.
 Contact getSender()
          Returns the sender of this message.
 String getSubject()
          Returns the subject of this message.
 HyperMessageType getType()
          Returns the type of this message.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNextID

protected static final int getNextID()
Returns the ID that should be assigned to the next new HyperMessage created. The first time this method is called, it returns 0; every subsequent time, the return value increases by 1.

Returns:
the next ID that should be allocated to a new HyperMessage.

getInstance

public static HyperMessage getInstance(HyperMessageType type,
                                       Contact sender,
                                       Contact recipient,
                                       String subject,
                                       String content,
                                       List<Integer> padsUsed,
                                       HyperMAC hemac,
                                       Date date)
Creates and returns a new HyperMessage. The only arguments that may be null are padsUsed and hemac. A null value for padsUsed indicates that the message content is not encrypted. A null value for hemac indicates that no authentication information is included.

padsUsed is copied before it is stored in this HyperMessage.

Parameters:
type - The type of this message.
sender - The sender of this message.
recipient - The recipient of this message.
subject - The subject of this message.
content - The content of this message.
padsUsed - An ordered list of the IDs of the one-time pad blocks that were used to encrypt this message.
date - The date of this message.
Returns:
a new HyperMessage with the given parameters
Throws:
NullPointerException - if any argument other than padsUsed is null

getID

public int getID()
Returns the unique ID of this message.

Returns:
The unique ID of this message.

getType

public HyperMessageType getType()
Returns the type of this message.

Returns:
The type of this message.

getSender

public Contact getSender()
Returns the sender of this message.

Returns:
The sender of this message.

getRecipient

public Contact getRecipient()
Returns the recipient of this message.

Returns:
The recipient of this message.

getSubject

public String getSubject()
Returns the subject of this message.

Returns:
The subject of this message.

getContent

public String getContent()
Returns the content of this message.

Returns:
The content of this message.

getPadsUsed

public List<Integer> getPadsUsed()
Returns a list of IDs of blocks used to encrypt this message. The list is a copy; callers are free to mutate the returned list.

Returns:
The IDs of blocks used to encrypt this message.

getMac

public HyperMAC getMac()
Returns the HEMAC for this message.

Returns:
the HEMAC for this message

getDate

public Date getDate()
Returns the date of this message.

Returns:
The date of this message.

equals

public boolean equals(Object o)
Compares this HyperMessage to the specified object. The result is true if and only if the argument is not null and is a HyperMessage object with the same ID as this HyperMessage.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object