Home » openjdk-7 » javax » crypto » [javadoc | source]
javax.crypto
public class: SealedObject [javadoc | source]
java.lang.Object
   javax.crypto.SealedObject

All Implemented Interfaces:
    java$io$Serializable

This class enables a programmer to create an object and protect its confidentiality with a cryptographic algorithm.

Given any Serializable object, one can create a SealedObject that encapsulates the original object, in serialized format (i.e., a "deep copy"), and seals (encrypts) its serialized contents, using a cryptographic algorithm such as DES, to protect its confidentiality. The encrypted content can later be decrypted (with the corresponding algorithm using the correct decryption key) and de-serialized, yielding the original object.

Note that the Cipher object must be fully initialized with the correct algorithm, key, padding scheme, etc., before being applied to a SealedObject.

The original object that was sealed can be recovered in two different ways:

Field Summary
static final  long serialVersionUID     
protected  byte[] encodedParams    The cryptographic parameters used by the sealing Cipher, encoded in the default format.

That is, cipher.getParameters().getEncoded().

    serial:
 
Constructor:
 protected SealedObject(SealedObject so) 
    Constructs a SealedObject object from the passed-in SealedObject.
    Parameters:
    so - a SealedObject object
    Throws:
    NullPointerException - if the given sealed object is null.
    exception: NullPointerException - if the given sealed object is null.
 public SealedObject(Serializable object,
    Cipher c) throws IOException, IllegalBlockSizeException 
    Constructs a SealedObject from any Serializable object.

    The given object is serialized, and its serialized contents are encrypted using the given Cipher, which must be fully initialized.

    Any algorithm parameters that may be used in the encryption operation are stored inside of the new SealedObject.

    Parameters:
    object - the object to be sealed; can be null.
    c - the cipher used to seal the object.
    Throws:
    NullPointerException - if the given cipher is null.
    IOException - if an error occurs during serialization
    IllegalBlockSizeException - if the given cipher is a block cipher, no padding has been requested, and the total input length (i.e., the length of the serialized object contents) is not a multiple of the cipher's block size
    exception: NullPointerException - if the given cipher is null.
    exception: IOException - if an error occurs during serialization
    exception: IllegalBlockSizeException - if the given cipher is a block cipher, no padding has been requested, and the total input length (i.e., the length of the serialized object contents) is not a multiple of the cipher's block size
Method from javax.crypto.SealedObject Summary:
getAlgorithm,   getObject,   getObject,   getObject
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.crypto.SealedObject Detail:
 public final String getAlgorithm() 
    Returns the algorithm that was used to seal this object.
 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.

 public final Object getObject(Cipher c) throws IOException, ClassNotFoundException, IllegalBlockSizeException, BadPaddingException 
    Retrieves the original (encapsulated) object.

    The encapsulated object is unsealed (using the given Cipher, assuming that the Cipher is already properly initialized) and de-serialized, before it is returned.

 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.