core
Interface IMessage

All Known Subinterfaces:
IMessageKey, INonce
All Known Implementing Classes:
Message, MessageKey, MessageKeyT, Nonce, NonceT

public interface IMessage

Author:
Xavier Didelot

Method Summary
 void addMessage(Message msg)
          This method concats two messages and put an 'at' symbol between them so that we can divide it later with the method getAllFields for example This means that a Message should never contain the symbol 'at' It is advised to only use Base64 string in the message to avoid any issue
 void decrypt(java.lang.String algorithm, java.security.Key key)
          Decrypt the message with a given key, using the given algorithm.
 void encrypt(java.lang.String algorithm, java.security.Key key)
          Encrypts the message with the given key, using the given algorithm, and put the result in Base64 format
 boolean equals(Message other)
          Check if the Message is equal to another one
 IMessage[] getAllFields()
          Returns an array containing the different parts of a message, ie the different messages that have been concatenated in order to build this message
 java.lang.String getString()
          This method returns the value of the protected member string It is especially useful to send a message to another host
 void hash()
          This method hashes the Message
 void setString(java.lang.String string)
          Change the value of the private member string into the given string It is advised to only use Base64 string in the message to avoid any issue
 

Method Detail

getString

public java.lang.String getString()
This method returns the value of the protected member string It is especially useful to send a message to another host

Returns:
the content of the message

setString

public void setString(java.lang.String string)
Change the value of the private member string into the given string It is advised to only use Base64 string in the message to avoid any issue

Parameters:
string - new value for the content of the message

addMessage

public void addMessage(Message msg)
This method concats two messages and put an 'at' symbol between them so that we can divide it later with the method getAllFields for example This means that a Message should never contain the symbol 'at' It is advised to only use Base64 string in the message to avoid any issue

Parameters:
msg -

getAllFields

public IMessage[] getAllFields()
Returns an array containing the different parts of a message, ie the different messages that have been concatenated in order to build this message

Returns:
an array containing the different parts of a message

encrypt

public void encrypt(java.lang.String algorithm,
                    java.security.Key key)
             throws java.lang.Exception
Encrypts the message with the given key, using the given algorithm, and put the result in Base64 format

Parameters:
algorithm - algorithm to use for encryption
key - key to use for encryption
Throws:
java.lang.Exception

decrypt

public void decrypt(java.lang.String algorithm,
                    java.security.Key key)
             throws java.lang.Exception
Decrypt the message with a given key, using the given algorithm. The message has to be in Base64 format.

Parameters:
algorithm - algorithm to use for decryption
key - key to use for decryption
Throws:
java.lang.Exception

hash

public void hash()
          throws java.security.NoSuchAlgorithmException
This method hashes the Message

Throws:
java.security.NoSuchAlgorithmException

equals

public boolean equals(Message other)
Check if the Message is equal to another one

Parameters:
other - the other Message
Returns:
true if the messages are the same, false otherwise