|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--core.Message
|
+--core.MessageKey
This class represents a Message which is a Key. It is useful for protocols in which a Key is sent from one Agent to another.
| Field Summary |
| Fields inherited from class core.Message |
|
| Constructor Summary | |
MessageKey()
Create an empty MessageKey |
|
MessageKey(java.security.Key key)
Create a MessageKey containing a Key |
|
MessageKey(Message msg)
|
|
MessageKey(java.lang.String algo)
Create a new MessageKey containing a fresh key generated with the given algorithm |
|
| Method Summary | |
static java.security.Key |
createKey(java.lang.String algo)
This static method returns a fresh Key created with the given algorithm |
static java.security.Key |
keyFromFile(java.lang.String file)
Reads a key from a file |
static void |
main(java.lang.String[] args)
This sample method shows how to store a Key in a file |
static void |
storeKeyToFile(java.security.Key key,
java.lang.String file)
Store a Key into a File |
java.security.Key |
toKey()
Convert this MessageKey into a Key |
| Methods inherited from class core.Message |
addMessage, clone, decrypt, encrypt, equals, getAllFields, getString, hash, setString |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface core.IMessage |
addMessage, decrypt, encrypt, equals, getAllFields, getString, hash, setString |
| Constructor Detail |
public MessageKey()
public MessageKey(java.lang.String algo)
throws java.io.IOException,
java.security.NoSuchAlgorithmException
algo - algorithm to use for generation of the fresh key
java.io.IOException
java.security.NoSuchAlgorithmException
public MessageKey(java.security.Key key)
throws java.io.IOException
key - Key that has to be contained in the Message
java.io.IOExceptionpublic MessageKey(Message msg)
| Method Detail |
public java.security.Key toKey()
throws java.io.IOException,
java.lang.ClassNotFoundException
toKey in interface IMessageKeyjava.io.IOException
java.lang.ClassNotFoundException
public static java.security.Key keyFromFile(java.lang.String file)
throws java.io.IOException,
java.lang.ClassNotFoundException
file - file where is stored the key
java.io.IOException
java.lang.ClassNotFoundException
public static void storeKeyToFile(java.security.Key key,
java.lang.String file)
throws java.io.IOException
key - Key to store in the Filefile - file where the Key has to be stored
java.io.IOException
public static java.security.Key createKey(java.lang.String algo)
throws java.security.NoSuchAlgorithmException
algo - algoritm to use for creation of a fresh key
java.security.NoSuchAlgorithmExceptionpublic static void main(java.lang.String[] args)
args - the Array args must contain two fields: firstly the algorithm to use to create a fresh Key and secondly the name of the file where to store the generated key
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||