au.net.aba.crypto
Class PublicKeySecuredObject

java.lang.Object
  |
  +--au.net.aba.crypto.PublicKeySecuredObject

public class PublicKeySecuredObject
extends java.lang.Object
implements java.io.Externalizable

a holding class for secret key encrypted objects which have their secret keys attached. The secret key is encrypted using some other algorithm.

See Also:
Serialized Form

Field Summary
static java.lang.String ident
           
 
Constructor Summary
PublicKeySecuredObject()
          general constructor used by externalisable.
PublicKeySecuredObject(java.lang.Object obj, Cipher cipher, java.security.SecureRandom random)
          create a public key secured object using the standard algorithm and the standard provider for the secret key.
PublicKeySecuredObject(java.lang.Object obj, Cipher cipher, java.security.SecureRandom random, java.lang.String algorithm, java.lang.String provider)
          create a public key secured object.
 
Method Summary
 Cipher getDecryptor()
          return a Cipher capable of decrypting another object encrypted with the same secret key as this one.
 Cipher getEncryptor()
          return a Cipher capable of encrypting another object with the secret key used to encrypt this one.
 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
 

Field Detail

ident

public static final java.lang.String ident
Constructor Detail

PublicKeySecuredObject

public PublicKeySecuredObject()
general constructor used by externalisable.

PublicKeySecuredObject

public PublicKeySecuredObject(java.lang.Object obj,
                              Cipher cipher,
                              java.security.SecureRandom random,
                              java.lang.String algorithm,
                              java.lang.String provider)
                       throws java.io.IOException
create a public key secured object. The object is encrypted with a secret key and the secret key is encrypted with the cipher passed in.
Parameters:
obj - a serialisable object to be encrypted.
cipher - the cipher to be used for encrypting the secret key.
random - a random source for generating the secret key.
algorithm - the name of the algorithm that the object will be encrypted with.
provider - the provider name for the object encryption algorithm.
Throws:
java.io.IOException - if object not serialisable or some other exception occurs.

PublicKeySecuredObject

public PublicKeySecuredObject(java.lang.Object obj,
                              Cipher cipher,
                              java.security.SecureRandom random)
                       throws java.io.IOException
create a public key secured object using the standard algorithm and the standard provider for the secret key. The object is encrypted with the secret key and the secret key is encrypted with the cipher passed in.
Parameters:
obj - a serialisable object to be encrypted.
cipher - the cipher to be used for encrypting the secret key.
random - a random source for generating the secret key.
Throws:
java.io.IOException - if object not serialisable or some other exception occurs.
Method Detail

getIV

public byte[] getIV()
returns a copy of the initialisation vector.
Returns:
the IV vector for the cipher that encrypted the secret key's

getObject

public java.lang.Object getObject(Cipher cipher)
                           throws java.io.IOException,
                                  java.lang.ClassNotFoundException
Return the plain text object.
Parameters:
cipher - The cipher used to decrypt the secret key and allow the decryption of the object.
Returns:
The plain text object.
Throws:
java.lang.ClassNotFoundException - The object class could not be loaded.

getEncryptor

public Cipher getEncryptor()
return a Cipher capable of encrypting another object with the secret key used to encrypt this one. Note: in the event you are dealing with an object constructed by someone else, this call is only meaningful if you have decrypted the object.
Returns:
the secret key cipher that was originally used, set up for encryption.

getDecryptor

public Cipher getDecryptor()
return a Cipher capable of decrypting another object encrypted with the same secret key as this one.
Returns:
the secret key cipher that was originally used, set up for decryption.

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.