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.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private AlgorithmIdentifier | |
| pack-priv EnvelopedDataParser | |
| private OriginatorInformation | |
| pack-priv RecipientInformationStore | |
| private AttributeTable |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private byte[] | |
| public AlgorithmIdentifier | Returns: AlgorithmIdentifier representing the content encryption algorithm.Return the content encryption algorithm details for the data in this object. |
| public String | |
| 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.Return the originator information associated with this message if present. |
| public RecipientInformationStore | |
| public AttributeTable | getUnprotectedAttributes()
return a table of the unprotected attributes indexed by the OID of the attribute. |
| attrNotRead | back to summary |
|---|---|
| private boolean attrNotRead | |
| encAlg | back to summary |
|---|---|
| private AlgorithmIdentifier encAlg | |
| envelopedData | back to summary |
|---|---|
| pack-priv EnvelopedDataParser envelopedData | |
| originatorInfo | back to summary |
|---|---|
| private OriginatorInformation originatorInfo | |
| recipientInfoStore | back to summary |
|---|---|
| pack-priv RecipientInformationStore recipientInfoStore | |
| unprotectedAttributes | back to summary |
|---|---|
| private AttributeTable unprotectedAttributes | |
| CMSEnvelopedDataParser | back to summary |
|---|---|
| public CMSEnvelopedDataParser(byte[] envelopedData) throws CMSException, IOException | |
| CMSEnvelopedDataParser | back to summary |
|---|---|
| public CMSEnvelopedDataParser(InputStream envelopedData) throws CMSException, IOException | |
| encodeObj | back to summary |
|---|---|
| private byte[] encodeObj(ASN1Encodable obj) throws IOException | |
| getContentEncryptionAlgorithm | back to summary |
|---|---|
| public AlgorithmIdentifier getContentEncryptionAlgorithm() Return the content encryption algorithm details for the data in this object.
| |
| getEncryptionAlgOID | back to summary |
|---|---|
| public String getEncryptionAlgOID() return the object identifier for the content encryption algorithm. | |
| getEncryptionAlgParams | back to summary |
|---|---|
| public byte[] getEncryptionAlgParams() return the ASN.1 encoded encryption algorithm parameters, or null if there aren't any. | |
| getOriginatorInfo | back to summary |
|---|---|
| public OriginatorInformation getOriginatorInfo() Return the originator information associated with this message if present.
| |
| getRecipientInfos | back to summary |
|---|---|
| public RecipientInformationStore getRecipientInfos() return a store of the intended recipients for this message | |
| getUnprotectedAttributes | back to summary |
|---|---|
| public AttributeTable getUnprotectedAttributes() throws IOException return a table of the unprotected attributes indexed by the OID of the attribute. | |