Top Description Fields Constructors Methods
org.bouncycastle.cms

public Class CMSEnvelopedDataParser

extends CMSContentInfoParser
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, org.bouncycastle.asn1.ASN1Encodable, .ASN1EncodableVector, .ASN1OctetStringParser, .ASN1SequenceParser, .ASN1Set, .ASN1SetParser, .BERTags, .DERSet, org.bouncycastle.asn1.cms.AttributeTable, .EncryptedContentInfoParser, .EnvelopedDataParser, .OriginatorInfo, org.bouncycastle.asn1.x509.AlgorithmIdentifier

Parsing class for an CMS Enveloped Data object from an input stream.

Note

that because we are in a streaming mode only one recipient can be tried and it is important that the methods on the parser are called in the appropriate order.

Example of use - assuming the first recipient matches the private key we have.

     CMSEnvelopedDataParser     ep = new CMSEnvelopedDataParser(inputStream);

     RecipientInformationStore  recipients = ep.getRecipientInfos();

     Collection  c = recipients.getRecipients();
     Iterator    it = c.iterator();

     if (it.hasNext())
     {
         RecipientInformation   recipient = (RecipientInformation)it.next();

         CMSTypedStream recData = recipient.getContentStream(new JceKeyTransEnvelopedRecipient(privateKey).setProvider("BC"));

         processDataStream(recData.getContentStream());
     }
 
Note: this class does not introduce buffering - if you are processing large files you should create the parser with:
         CMSEnvelopedDataParser     ep = new CMSEnvelopedDataParser(new BufferedInputStream(inputStream, bufSize));
 
where bufSize is a suitably large buffer size.

Field Summary

Modifier and TypeField and Description
private boolean
private AlgorithmIdentifier
pack-priv EnvelopedDataParser
private OriginatorInformation
pack-priv RecipientInformationStore
private AttributeTable
Inherited from org.bouncycastle.cms.CMSContentInfoParser:
_contentInfo_data

Constructor Summary

AccessConstructor and Description
public
CMSEnvelopedDataParser(byte[] envelopedData)

public

Method Summary

Modifier and TypeMethod and Description
private byte[]
public AlgorithmIdentifier

Returns:

AlgorithmIdentifier representing the content encryption algorithm.
getContentEncryptionAlgorithm
()

Return the content encryption algorithm details for the data in this object.

public String
getEncryptionAlgOID()

return the object identifier for the content encryption algorithm.

public byte[]
getEncryptionAlgParams()

return the ASN.1 encoded encryption algorithm parameters, or null if there aren't any.

public OriginatorInformation

Returns:

OriginatorInformation, null if not present.
getOriginatorInfo
()

Return the originator information associated with this message if present.

public RecipientInformationStore
getRecipientInfos()

return a store of the intended recipients for this message

public AttributeTable
getUnprotectedAttributes()

return a table of the unprotected attributes indexed by the OID of the attribute.

Inherited from org.bouncycastle.cms.CMSContentInfoParser:
close

Field Detail

attrNotReadback to summary
private boolean attrNotRead
encAlgback to summary
private AlgorithmIdentifier encAlg
envelopedDataback to summary
pack-priv EnvelopedDataParser envelopedData
originatorInfoback to summary
private OriginatorInformation originatorInfo
recipientInfoStoreback to summary
pack-priv RecipientInformationStore recipientInfoStore
unprotectedAttributesback to summary
private AttributeTable unprotectedAttributes

Constructor Detail

CMSEnvelopedDataParserback to summary
public CMSEnvelopedDataParser(byte[] envelopedData) throws CMSException, IOException
CMSEnvelopedDataParserback to summary
public CMSEnvelopedDataParser(InputStream envelopedData) throws CMSException, IOException

Method Detail

encodeObjback to summary
private byte[] encodeObj(ASN1Encodable obj) throws IOException
getContentEncryptionAlgorithmback to summary
public AlgorithmIdentifier getContentEncryptionAlgorithm()

Return the content encryption algorithm details for the data in this object.

Returns:AlgorithmIdentifier

AlgorithmIdentifier representing the content encryption algorithm.

getEncryptionAlgOIDback to summary
public String getEncryptionAlgOID()

return the object identifier for the content encryption algorithm.

getEncryptionAlgParamsback to summary
public byte[] getEncryptionAlgParams()

return the ASN.1 encoded encryption algorithm parameters, or null if there aren't any.

getOriginatorInfoback to summary
public OriginatorInformation getOriginatorInfo()

Return the originator information associated with this message if present.

Returns:OriginatorInformation

OriginatorInformation, null if not present.

getRecipientInfosback to summary
public RecipientInformationStore getRecipientInfos()

return a store of the intended recipients for this message

getUnprotectedAttributesback to summary
public AttributeTable getUnprotectedAttributes() throws IOException

return a table of the unprotected attributes indexed by the OID of the attribute.