|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The ICryptography interface specifies the methods necessary for the key handling as well as to sign and verify messages.
A class implementing the ICryptography interface should provide a constructor taking no parameters. In the constructor get a Signature object with the MD5withRSA algorithm. Throw a ShareMeException if it could not get a signature object.
Method Summary | |
byte[] |
convertSerializableToByteArray(java.io.Serializable obj)
Convert/Serialize an object into a byte array. |
java.security.PublicKey |
initialize(java.lang.String owner,
java.lang.String keyFile)
Read the key pair from keyFile. |
byte[] |
sign(java.io.Serializable obj)
Return the signature of the object obj. |
boolean |
verify(java.io.Serializable obj,
byte[] signature,
java.security.PublicKey pubKey)
Verify the signature of a given object. |
Method Detail |
public java.security.PublicKey initialize(java.lang.String owner, java.lang.String keyFile) throws ShareMeException
owner
- the owner of the key pair (can be ignored)keyFile
- the file to read the key pair from.
null
if the key pair is read from keyFile;
the public key otherwise.
ShareMeException
- If it an error occurs while reading
the key pair from file.public byte[] sign(java.io.Serializable obj) throws ShareMeException
obj
- the object to create the signature of.
ShareMeException
- If it could not sign the object.public boolean verify(java.io.Serializable obj, byte[] signature, java.security.PublicKey pubKey) throws ShareMeException
obj
- the object whose signature has to be verifiedsignature
- the signature to verifypubKey
- the public key of the person who has signed the
object
ShareMeException
- If an error occured while
verifying.public byte[] convertSerializableToByteArray(java.io.Serializable obj) throws ShareMeException
obj
- the object to be serialized
ShareMeException
- If an error occurs during the
serialization.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |