org.testifyproject.bouncycastle.cms.CMSCompressedDataParser Maven / Gradle / Ivy
The newest version!
package org.testifyproject.bouncycastle.cms;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.testifyproject.bouncycastle.asn1.ASN1OctetStringParser;
import org.testifyproject.bouncycastle.asn1.ASN1SequenceParser;
import org.testifyproject.bouncycastle.asn1.BERTags;
import org.testifyproject.bouncycastle.asn1.cms.CompressedDataParser;
import org.testifyproject.bouncycastle.asn1.cms.ContentInfoParser;
import org.testifyproject.bouncycastle.operator.InputExpander;
import org.testifyproject.bouncycastle.operator.InputExpanderProvider;
/**
* Class for reading a CMS Compressed Data stream.
*
* CMSCompressedDataParser cp = new CMSCompressedDataParser(inputStream);
*
* process(cp.getContent(new ZlibExpanderProvider()).getContentStream());
*
* Note: this class does not introduce buffering - if you are processing large files you should create
* the parser with:
*
* CMSCompressedDataParser ep = new CMSCompressedDataParser(new BufferedInputStream(inputStream, bufSize));
*
* where bufSize is a suitably large buffer size.
*/
public class CMSCompressedDataParser
extends CMSContentInfoParser
{
public CMSCompressedDataParser(
byte[] org.testifyproject.testifyprojectpressedData)
throws CMSException
{
this(new ByteArrayInputStream(org.testifyproject.testifyprojectpressedData));
}
public CMSCompressedDataParser(
InputStream org.testifyproject.testifyprojectpressedData)
throws CMSException
{
super(org.testifyproject.testifyprojectpressedData);
}
/**
* Return a typed stream which will allow the reading of the org.testifyproject.testifyprojectpressed content in
* expanded form.
*
* @param expanderProvider a provider of expander algorithm implementations.
* @return a type stream which will yield the un-org.testifyproject.testifyprojectpressed content.
* @throws CMSException if there is an exception parsing the CompressedData object.
*/
public CMSTypedStream getContent(InputExpanderProvider expanderProvider)
throws CMSException
{
try
{
CompressedDataParser org.testifyproject.testifyprojectData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
ContentInfoParser content = org.testifyproject.testifyprojectData.getEncapContentInfo();
InputExpander expander = expanderProvider.get(org.testifyproject.testifyprojectData.getCompressionAlgorithmIdentifier());
ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);
return new CMSTypedStream(content.getContentType().getId(), expander.getInputStream(bytes.getOctetStream()));
}
catch (IOException e)
{
throw new CMSException("IOException reading org.testifyproject.testifyprojectpressed content.", e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy