h09219 s 00039/00088/00093 d D 1.4 97/12/09 15:24:52 luehe 5 4 c rm ,* e s 00000/00019/00181 d D 1.3 97/10/22 15:25:08 luehe 4 3 c removed examples e s 00003/00003/00197 d D 1.2 97/10/18 13:59:54 luehe 3 1 c removed examples e s 00000/00000/00000 d R 1.2 97/10/09 09:58:17 Codemgr 2 1 c SunPro Code Manager data about conflicts, renames, etc... c Name history : 1 0 security/JCE1.2/earlyaccess/javax.crypto.SealedObject.html e s 00200/00000/00000 d D 1.1 97/10/09 09:58:16 luehe 1 0 c date and time created 97/10/09 09:58:16 by luehe e u U f e 0 t T I 1 D 3 E 3 I 3 D 5 E 5 I 5 E 5 E 3 Class javax.crypto.SealedObject
D 3
All Packages  Class Hierarchy  This Package  Previous  Next  Index
E 3 I 3 D 5 All Packages Class Hierarchy This Package Previous Next Index E 5 I 5 All Packages Class Hierarchy This Package Previous Next Index E 5 E 3

Class javax.crypto.SealedObject

java.lang.Object
   |
   +----javax.crypto.SealedObject

public class SealedObject
extends Object
implements 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 D 5 that embeds in its content the original object, in serialized format (i.e., a "deep copy"). Then, a cryptographic algorithm, such as DES, can be applied to the content to protect its confidentiality. The encrypted content can later be decrypted with the corresponding algorithm using the correct decryption key.

After decryption, the original content can be obtained in object form through deserialization. The content, while encrypted, is not available to anyone who does not possess the correct decryption key, assuming that the cryptosystem is secure. E 5 I 5 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. E 5 D 4

A typical usage is illustrated with the following code segment.

 (generate a key and initialize cipher)
 KeyGenerator keyGen = KeyGenerator.getInstance("DES");
 SecretKey desKey = keyGen.generateKey();
 Cipher cipher = Cipher.getInstance("DES");
 cipher.init(Cipher.ENCRYPT_MODE, desKey);
 ...
 (create SealedObject and encrypt)
 SealedObject so = new SealedObject("we are here");
 so.seal(cipher);
 ...
 (decrypt and retrieve the original object)
 cipher.init(Cipher.DECRYPT_MODE, desKey);
 so.unseal(cipher);
 try {
     String s = (String) so.getContent();
 } catch (java.lang.ClassNotFoundException e) {};
 
E 4

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

See Also:
Cipher

Constructor Index

 o D 5 SealedObject(Serializable)
Constructs an SealedObject from any Serializable object. E 5 I 5 SealedObject(Serializable, Cipher)
Constructs a SealedObject from any Serializable object. E 5

Method Index

 o D 5 getContent()
Retrieves the stored object, if it is not sealed.
 o resetContent(Serializable)
Changes the stored object to be the newly specified object, and causes the SealedObject to become unsealed, no matter what the previous status was.
 o seal(Cipher)
Seals the "content" using the given Cipher, assuming that the Cipher is already properly initialized.
 o unseal(Cipher)
Unseals the "content" using the given Cipher, assuming that the Cipher is already properly initialized. E 5 I 5 getObject(Cipher)
Retrieves the original (encapsulated) object. E 5

Constructors

D 5  o E 5 I 5  o E 5 SealedObject
D 5
 public SealedObject(Serializable object) throws IOException
E 5
I 5
 public SealedObject(Serializable object,
                     Cipher c) throws IOException, IllegalBlockSizeException
E 5
D 5
Constructs an SealedObject from any Serializable object. E 5 I 5
Constructs a SealedObject from any Serializable object.

The given object is sealed using the given Cipher, assuming that the Cipher is already properly initialized. E 5

Parameters:
object - the object to be sealed. I 5
c - the cipher used to seal the object.
Throws: IOException
if an error occurs during serialization
Throws: IllegalBlockSizeException
if the given cipher is a block cipher, no padding has been requested, and the total input length is not a multiple of the cipher's block size E 5

Methods

D 5  o resetContent E 5 I 5  o getObject E 5
D 5
 public final void resetContent(Serializable object) throws IOException
E 5
I 5
 public final Object getObject(Cipher c) throws IOException, ClassNotFoundException, IllegalBlockSizeException, BadPaddingException
E 5
D 5
Changes the stored object to be the newly specified object, and causes the SealedObject to become unsealed, no matter what the previous status was. E 5 I 5
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. E 5

Parameters: D 5
object - the new object to be sealed.
Throws: IOException
if an error occurs during serialiazation
 o getContent
 public final Object getContent() throws IOException, ClassNotFoundException
Retrieves the stored object, if it is not sealed. The stored copy is de-serialized before it is returned.

E 5 I 5
c - the cipher used to unseal the object E 5
Returns: D 5
the stored object. E 5 I 5
the original object. E 5
Throws: IOException D 5
if an error occurs during serialiazation E 5 I 5
if an error occurs during de-serialiazation E 5
Throws: ClassNotFoundException
if an error occurs during D 5 serialiazation
 o seal
 public final void seal(Cipher c) throws IllegalBlockSizeException
Seals the "content" using the given Cipher, assuming that the Cipher is already properly initialized.

E 5 I 5 de-serialiazation E 5
Throws: IllegalBlockSizeException
if the given cipher is a block D 5 cipher, no padding has been requested, and the total input length is not a multiple of the cipher's block size
 o unseal
 public final void unseal(Cipher c) throws IllegalBlockSizeException, BadPaddingException
Unseals the "content" using the given Cipher, assuming that the Cipher is already properly initialized.

Throws: IllegalBlockSizeException
if the given cipher is a block cipher, and the total input length is not a multiple of the cipher's block size E 5 I 5 cipher, no padding has been requested, and the total input length is not a multiple of the cipher's block size E 5
Throws: BadPaddingException
if the given cipher has been initialized for decryption, and padding has been specified, but the input data does not have proper expected padding bytes

D 3
All Packages  Class Hierarchy  This Package  Previous  Next  Index
E 3 I 3 D 5 All Packages Class Hierarchy This Package Previous Next Index E 5 I 5 All Packages Class Hierarchy This Package Previous Next Index E 5 E 3 E 1