javax.crypto
Class SealedObject

java.lang.Object
  |
  +--javax.crypto.SealedObject
All Implemented Interfaces:
Serializable

public class SealedObject
extends Object
implements Serializable

Class for cryptographic "sealing" a serialized object.


Attention:  This is not a SUN implementation!

This class has been developed by IAIK according to the documentation publically available.
For SUNīs documentation of this class see http://java.sun.com/security/JCE1.2/spec/apidoc/index.html


This class can be used for protecting the confidentiality of a Serializable object. For protecting the Serializable object, create a SealedObject by calling the constructor with the given Serializable object and the Cipher to be used for encrypting. For decrypting - and deserializing - the encrypted object again, use the getobject(Cipher cipher) method, where now the Cipher is initialized for decryptiion.

Version:
File Revision 16
See Also:
getObject(javax.crypto.Cipher), Serialized Form

Field Summary
protected  byte[] encodedParams
           
 
Constructor Summary
protected SealedObject(SealedObject so)
          Create a new SealedObject cloning another.
  SealedObject(Serializable object, Cipher c)
          Creates a SealedObject from the given Serializable object using the given Cipher for encryption.
 
Method Summary
 String getAlgorithm()
          Returns the algorithm that was used to seal this object.
 Object getObject(Cipher c)
          Returns he original Serializable object from which this SealedObject has been created.
 Object getObject(Key key)
          Retrieves the original (encapsulated) object.
 Object getObject(Key key, String provider)
          Retrieves the original (encapsulated) object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encodedParams

protected byte[] encodedParams
Constructor Detail

SealedObject

public SealedObject(Serializable object,
                    Cipher c)
             throws IOException,
                    IllegalBlockSizeException
Creates a SealedObject from the given Serializable object using the given Cipher for encryption.
Parameters:
object - the Serializeable object to be sealed
c - the cipher used for sealing, initialized for encryption
Throws:
IOException - if an error occurs during serialization
IllegalBlockSizeException - if the total length of the processed data is not a multiple of the block size for a (no padding performing) block cipher

SealedObject

protected SealedObject(SealedObject so)
Create a new SealedObject cloning another.
Method Detail

getAlgorithm

public final String getAlgorithm()
Returns the algorithm that was used to seal this object.
Returns:
the algorithm that was used to seal this object

getObject

public final Object getObject(Cipher c)
                       throws IOException,
                              ClassNotFoundException,
                              IllegalBlockSizeException,
                              BadPaddingException
Returns he original Serializable object from which this SealedObject has been created.
Parameters:
c - the cipher used for unsealing, initialized for decryption
Returns:
the original object.
Throws:
IOException - if an error occurs during de-serialiazation
ClassNotFoundException - if an error occurs during de-serialiazation
IllegalBlockSizeException - if the total length of the processed data is not a multiple of the block size for a (no padding performing) block cipher
BadPaddingException - if the input data does not have proper padding bytes for data decryption including (un)padding

getObject

public final Object getObject(Key key)
                       throws IOException,
                              ClassNotFoundException,
                              NoSuchAlgorithmException,
                              InvalidKeyException
Retrieves the original (encapsulated) object. This method creates a cipher for the algorithm that had been used in the sealing operation. If the default provider package provides an implementation of that algorithm, an instance of Cipher containing that implementation is used. If the algorithm is not available in the default package, other packages are searched. The Cipher object is initialized for decryption, using the given key and the parameters (if any) that had been used in the sealing operation. The encapsulated object is unsealed and de-serialized, before it is returned.
Parameters:
key - the key used to unseal the object
Returns:
the original object
Throws:
IOException - if an error occurs during de-serialiazation
ClassNotFoundException - if an error occurs during de-serialiazation
NoSuchAlgorithmException - if the algorithm to unseal the object is not available
InvalidKeyException - if the given key cannot be used to unseal the object (e.g., it has the wrong algorithm)

getObject

public final Object getObject(Key key,
                              String provider)
                       throws IOException,
                              ClassNotFoundException,
                              NoSuchAlgorithmException,
                              NoSuchProviderException,
                              InvalidKeyException
Retrieves the original (encapsulated) object. This method creates a cipher for the algorithm that had been used in the sealing operation, using an implementation of that algorithm from the given provider. The Cipher object is initialized for decryption, using the given key and the parameters (if any) that had been used in the sealing operation. The encapsulated object is unsealed and de-serialized, before it is returned.
Parameters:
key - the key used to unseal the object
provider - the name of the provider of the algorithm to unseal the object
Returns:
the original object
Throws:
IOException - if an error occurs during de-serialiazation
ClassNotFoundException - if an error occurs during de-serialiazation
NoSuchAlgorithmException - if the algorithm to unseal the object is not available
NoSuchProviderException - if the given provider is not configured
InvalidKeyException - if the given key cannot be used to unseal the object (e.g., it has the wrong algorithm)

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK