|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList
codec.asn1.ASN1AbstractCollection
codec.asn1.ASN1Sequence
codec.pkcs7.EnvelopedData
public class EnvelopedData
This class represents the PKCS#7 EnvelopedData type, which is defined as follows:
EnvelopedData ::= SEQUENCE {
version Version,
recipientInfos RecipientInfos,
encryptedContentInfo EncryptedContentInfo
}
RecipientInfos ::= SET OF RecipientInfo
See class RecipientInfo for a
description of the RecipientInfo structure.
| Field Summary | |
|---|---|
static int |
BUFFER_SIZE
The size of the buffer allocated for reading and verifying data in case this is a detached signature file. |
protected ContentInfo |
content_
The ContentInfo. |
protected EncryptedContentInfo |
info_
The EncryptedContentInfo. |
protected ASN1SetOf |
recipients_
The RecipientInfos. |
private static int[] |
THIS_OID
The OID of this structure. |
protected ASN1Integer |
version_
The version of this structure. |
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
EnvelopedData()
This method calls builds the tree of ASN.1 objects used for decoding this structure. |
|
EnvelopedData(SecretKey bek,
String bea,
AlgorithmParameters params)
Creates an instance that is initialised with the given secret key and algorithm parameters. |
|
| Method Summary | |
|---|---|
void |
addRecipient(X509Certificate cert)
This method adds a recipient to the list of recipients. |
void |
decryptBulkData(InputStream in,
OutputStream out)
This method reads encrypted bulk data from the input stream, decrypts and writes the decrypted data to the given output stream. |
void |
encryptBulkData(InputStream in,
OutputStream out)
This method reads plaintext bulk data from the input stream, encrypts it and writes the encrypted data to the given output stream. |
ASN1ObjectIdentifier |
getContentType()
Retrieves and returns the content type of the content stored in the encryptedContentInfo of this
structure. |
byte[] |
getData()
This method decrypts and returns the decrypted data contained in this instance or null if
there is no contained data. |
ASN1ObjectIdentifier |
getOID()
Returns the OID of this structure. |
RecipientInfo |
getRecipientInfo(X509Certificate cert)
This method retrieves the RecipientInfo
macthing the given certificate or null if there
is no such recipient. |
List |
getRecipientInfos()
This method returns an unmodifiable list view on the RecipientInfos of this
structure. |
SecretKey |
getSecretKey()
This method returns the secret bulk encryption key if the underlying EncryptedContentInfo structure is already initialised properly (by calling one of this object's init methods). |
boolean |
hasRecipient(X509Certificate cert)
This method checks if the given certificate is listed as a recipient by comparing the issuer and serial number of the given certificate with those listed in the recipient infos of this instance. |
void |
init(X509Certificate cert,
PrivateKey kdk)
Initialises this instance for encryption/decryption. |
boolean |
isReady()
This method returns true if this
instance is ready for encryption/decryption
without further initialisation. |
void |
setData(InputStream in)
Encrypts the given data and inserts it as Data content. |
| Methods inherited from class codec.asn1.ASN1Sequence |
|---|
getTag |
| Methods inherited from class codec.asn1.ASN1AbstractCollection |
|---|
checkConstraints, decode, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional, toString |
| Methods inherited from class java.util.ArrayList |
|---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, removeAll, retainAll |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface codec.asn1.ASN1Type |
|---|
checkConstraints, decode, encode, getConstraint, getTag, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional |
| Methods inherited from interface java.util.Collection |
|---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Methods inherited from interface java.util.List |
|---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
| Field Detail |
|---|
public static final int BUFFER_SIZE
private static final int[] THIS_OID
protected ASN1Integer version_
protected ASN1SetOf recipients_
protected EncryptedContentInfo info_
EncryptedContentInfo.
protected ContentInfo content_
ContentInfo.
| Constructor Detail |
|---|
public EnvelopedData()
public EnvelopedData(SecretKey bek,
String bea,
AlgorithmParameters params)
throws InvalidAlgorithmParameterException
init method for adding recipients.
bek - The secret key to use for bulk encryption.bea - The name of the bulk encryption algorithm.params - The AlgorithmParameters of the bulk
encryption algorithm.
InvalidAlgorithmParameterException - just what
is says...| Method Detail |
|---|
public ASN1ObjectIdentifier getOID()
getOID in interface ASN1RegisteredTypepublic ASN1ObjectIdentifier getContentType()
encryptedContentInfo of this
structure. This value is meaningful only if this instance
was decoded or initialised properly.
public List getRecipientInfos()
RecipientInfos of this
structure.
public boolean hasRecipient(X509Certificate cert)
recipient infos of this instance.
cert - The certificate that identifies the recipient.
true if a recipient who matches the
given certificate is included in this structure.public RecipientInfo getRecipientInfo(X509Certificate cert)
RecipientInfo
macthing the given certificate or null if there
is no such recipient.
cert - The certificate that identifies the recipient.
null
if no matching recipient was found.
public void addRecipient(X509Certificate cert)
throws GeneralSecurityException,
BadNameException
EncryptedContentInfo is
initialised properly. This is done by either of two
means:
init with a certificate
that is listed as recipient and appropriate private
key.
RecipientInfo instance is
created and added to the list of recipient infos
in this instance.
cert - The certificate of the recipient.
GeneralSecurityException - if some cipher
operation fails. The reason can bedetermined
from the actual subclass that is thrown.
BadNameException - if the issuer name in
the certificate cannot be parsed.
public void init(X509Certificate cert,
PrivateKey kdk)
throws GeneralSecurityException,
NoSuchElementException
RecipientInfo matching the given certificate and
calls init of the
EncryptedContentInfo
contained in this structure.This method need to be called only if this instance was not initialised with a secret key for bulk encryption, but was initialised through parsing it from a DER stream. In other words, this method is probably used only when reading EnvelopedData sent by someone else but hardly ever if it is generated.
Please note that, once this instance is properly
initialised, additional recipients might be added
to it unless this structure is protected by
integrity measures (such as wrapping it in a
SignedData structure.
kdk - The private Key Decryption Key
required to decrypt the DEK.cert - The certificate matching the private key.
GeneralSecurityException - if some cipher
operation fails.
NoSuchElementException - if no matching
RecipientInfo is found in
this instance.public boolean isReady()
true if this
instance is ready for encryption/decryption
without further initialisation.
true if it is ready.
public void setData(InputStream in)
throws GeneralSecurityException,
IOException
Data content.
IllegalStateException - if the DEK is not
initialised.
GeneralSecurityException - if something nasty
happens while encrypting such as algorithms not found,
bad paddings et cetera.
IOException
public byte[] getData()
throws GeneralSecurityException,
NoSuchElementException
null if
there is no contained data.
InconsistentStateException - in case of an
unexpected internal exception. This should never
happen.
IllegalStateException - if the DEK is not
initialised.
NoSuchElementException - if the content
type is not Data.
GeneralSecurityException - if a cipher
operation fails.public SecretKey getSecretKey()
init methods). If the
key is not available (yet) then null
is returned.
null.
IllegalStateException - if this instance is
not yet initialised.
public void decryptBulkData(InputStream in,
OutputStream out)
throws IOException,
GeneralSecurityException
in - The input stream from which the data is read.out - The output stream to which the data is
written.
IOException
GeneralSecurityException
public void encryptBulkData(InputStream in,
OutputStream out)
throws IOException,
GeneralSecurityException
in - The input stream from which the data is read.out - The output stream to which the data is
written.
IOException
GeneralSecurityException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||