|
Préférences
Moteurs de recherche
|
||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.4.2
javax.crypto
|
Field Summary | |
protected byte[] |
encodedParams
The encoded parameters. |
Constructor Summary | |
protected |
SealedObject(SealedObject so)
Constructs a SealedObject object from the passed-in SealedObject. |
|
SealedObject(Serializable object,
Cipher c)
Constructs a SealedObject from any Serializable object. |
Method Summary | |
String |
getAlgorithm()
Returns the algorithm that was used to seal this object. |
Object |
getObject(Cipher c)
Retrieves the original (encapsulated) object. |
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 |
protected byte[] encodedParams
Constructor Detail |
public SealedObject(Serializable object, Cipher c) throws IOException, IllegalBlockSizeException
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
.
object
- the object to be sealed.c
- the cipher used to seal the object.
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 sizeprotected SealedObject(SealedObject so)
so
- a SealedObject objectMethod Detail |
public final String getAlgorithm()
public final Object getObject(Key key) throws IOException, ClassNotFoundException, NoSuchAlgorithmException, InvalidKeyException
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.
key
- the key used to unseal the object.
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).public final Object getObject(Cipher c) throws IOException, ClassNotFoundException, IllegalBlockSizeException, BadPaddingException
The encapsulated object is unsealed (using the given Cipher, assuming that the Cipher is already properly initialized) and de-serialized, before it is returned.
c
- the cipher used to unseal the object
IOException
- if an error occurs during de-serialiazation
ClassNotFoundException
- if an error occurs during
de-serialiazation
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
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 bytespublic final Object getObject(Key key, String provider) throws IOException, ClassNotFoundException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException
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.
key
- the key used to unseal the object.provider
- the name of the provider of the algorithm to unseal
the object.
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).