Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.crypto
Class SealedObject  view SealedObject download SealedObject.java

java.lang.Object
  extended byjavax.crypto.SealedObject
All Implemented Interfaces:
java.io.Serializable

public class SealedObject
extends java.lang.Object
implements java.io.Serializable

This class allows any java.io.Serializable object to be stored in an encrypted form.

When the sealed object is ready to be unsealed (and deserialized) the caller may use either

  1. getObject(javax.crypto.Cipher) 55 , which uses an already-initialized Cipher.

    or,
  2. getObject(java.security.Key) 55 or getObject(java.security.Key,java.lang.String) 55 , which will initialize a new cipher instance with the encodedParams 55 that were stored with this sealed object (this is so parameters, such as the IV, don't need to be known by the one unsealing the object).

Since:
1.4

Field Summary
protected  byte[] encodedParams
          The encoded algorithm parameters.
private  byte[] encryptedContent
          The serialized, encrypted object.
private  java.lang.String paramsAlg
          The parameter type.
private  java.lang.String sealAlg
          The algorithm used to seal the object.
private  Cipher sealCipher
          The cipher that decrypts when this object is unsealed.
private static long serialVersionUID
          Compatible with JDK1.4.
 
Constructor Summary
protected SealedObject(SealedObject so)
          Create a new sealed object from another sealed object.
  SealedObject(java.io.Serializable object, Cipher cipher)
          Create a new sealed object from a java.io.Serializable object and a cipher.
 
Method Summary
 java.lang.String getAlgorithm()
          Get the name of the algorithm used to seal this object.
 java.lang.Object getObject(Cipher cipher)
          Unseal and deserialize this sealed object with a specified (already initialized) cipher.
 java.lang.Object getObject(java.security.Key key)
          Unseal and deserialize this sealed object with the specified key.
 java.lang.Object getObject(java.security.Key key, java.lang.String provider)
          Unseal and deserialize this sealed object with the specified key, using a cipher from the named provider.
private  void readObject(java.io.ObjectInputStream ois)
          Deserialize this object.
private  java.lang.Object unseal()
          Unseal this object, returning it.
private  void writeObject(java.io.ObjectOutputStream oos)
          Serialize this 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
The encoded algorithm parameters.


encryptedContent

private byte[] encryptedContent
The serialized, encrypted object.


sealAlg

private java.lang.String sealAlg
The algorithm used to seal the object.


paramsAlg

private java.lang.String paramsAlg
The parameter type.


sealCipher

private transient Cipher sealCipher
The cipher that decrypts when this object is unsealed.


serialVersionUID

private static final long serialVersionUID
Compatible with JDK1.4.

See Also:
Constant Field Values
Constructor Detail

SealedObject

public SealedObject(java.io.Serializable object,
                    Cipher cipher)
             throws java.io.IOException,
                    IllegalBlockSizeException
Create a new sealed object from a java.io.Serializable object and a cipher.


SealedObject

protected SealedObject(SealedObject so)
Create a new sealed object from another sealed object.

Method Detail

getAlgorithm

public final java.lang.String getAlgorithm()
Get the name of the algorithm used to seal this object.


getObject

public final java.lang.Object getObject(Cipher cipher)
                                 throws java.io.IOException,
                                        java.lang.ClassNotFoundException,
                                        IllegalBlockSizeException,
                                        BadPaddingException
Unseal and deserialize this sealed object with a specified (already initialized) cipher.


getObject

public final java.lang.Object getObject(java.security.Key key)
                                 throws java.io.IOException,
                                        java.lang.ClassNotFoundException,
                                        java.security.InvalidKeyException,
                                        java.security.NoSuchAlgorithmException
Unseal and deserialize this sealed object with the specified key.


getObject

public final java.lang.Object getObject(java.security.Key key,
                                        java.lang.String provider)
                                 throws java.io.IOException,
                                        java.lang.ClassNotFoundException,
                                        java.security.InvalidKeyException,
                                        java.security.NoSuchAlgorithmException,
                                        java.security.NoSuchProviderException
Unseal and deserialize this sealed object with the specified key, using a cipher from the named provider.


readObject

private void readObject(java.io.ObjectInputStream ois)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Deserialize this object.


writeObject

private void writeObject(java.io.ObjectOutputStream oos)
                  throws java.io.IOException
Serialize this object.


unseal

private java.lang.Object unseal()
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException,
                                IllegalBlockSizeException,
                                BadPaddingException
Unseal this object, returning it.