java.lang.Objectjavax.crypto.SealedObject
public class SealedObject
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:
getObject
method that takes a Cipher object.
This method requires a fully initialized Cipher object,
initialized with the
exact same algorithm, key, padding scheme, etc., that were used to seal the
object.
This approach has the advantage that the party who unseals the sealed object does not require knowledge of the decryption key. For example, after one party has initialized the cipher object with the required decryption key, it could hand over the cipher object to another party who then unseals the sealed object.
getObject methods
that take a Key object.
In this approach, the getObject method creates a cipher
object for the appropriate decryption algorithm and initializes it with the
given decryption key and the algorithm parameters (if any) that were stored
in the sealed object.
This approach has the advantage that the party who unseals the object does not need to keep track of the parameters (e.g., an IV) that were used to seal the object.
Cipher,
Serialized Form| 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; can be null.c - the cipher used to seal the object.
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 sizeprotected SealedObject(SealedObject so)
so - a SealedObject object
NullPointerException - if the given sealed object is null.| Method 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
NullPointerException - if the given cipher is null.
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.
IllegalArgumentException - if the given provider is null
or empty.
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).Ces informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
6 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)