au.net.aba.crypto
Class SecuredObject
java.lang.Object
|
+--au.net.aba.crypto.SecuredObject
- public class SecuredObject
- extends java.lang.Object
- implements java.io.Externalizable
a holding class for encrypted objects which have a verification hash
attached.
- See Also:
- Serialized Form
Field Summary |
static java.lang.String |
ident
|
Constructor Summary |
SecuredObject()
base constructor needed for serialisation to work. |
SecuredObject(java.lang.Object obj,
Cipher cipher)
create a secret key secured object. |
Method Summary |
byte[] |
getIV()
returns a copy of the initialisation vector. |
java.lang.Object |
getObject(Cipher cipher)
Return the plain text object. |
void |
readExternal(java.io.ObjectInput in)
serialisation support using Externalizable. |
void |
writeExternal(java.io.ObjectOutput out)
serialisation support using Externalizable. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
ident
public static final java.lang.String ident
SecuredObject
public SecuredObject()
- base constructor needed for serialisation to work.
SecuredObject
public SecuredObject(java.lang.Object obj,
Cipher cipher)
throws java.io.IOException
- create a secret key secured object. The object is appended with
a SHA-1 digest, and the system time is written at the front of
the stream to remove the likelihood of two objects encrypting to
the same or similar streams.
- Parameters:
obj
- the object to be encrypted.cipher
- the cipher to be used to encrypt the object.- Throws:
- java.io.IOException - if the object is not serialisable or some
other error occurs.
getIV
public byte[] getIV()
- returns a copy of the initialisation vector.
- Returns:
- the IV vector for the cipher used to encrypt the object.
getObject
public java.lang.Object getObject(Cipher cipher)
throws java.io.IOException,
java.lang.ClassNotFoundException
- Return the plain text object.
- Parameters:
cipher
- The cipher to be used to decrypt the object.- Returns:
- The object that was encrypted.
- Throws:
- java.lang.ClassNotFoundException - The object class could not be
loaded.
writeExternal
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
- serialisation support using Externalizable.
- Specified by:
- writeExternal in interface java.io.Externalizable
- Parameters:
out
- the object output stream.
readExternal
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
- serialisation support using Externalizable.
- Specified by:
- readExternal in interface java.io.Externalizable
- Parameters:
in
- the object input stream.- Throws:
- java.lang.ClassNotFoundException - - the class definition of
the serialised object could not be loaded.