Search in sources :

Example 1 with InputExpander

use of com.github.zhenwei.pkix.operator.InputExpander in project LinLong-Java by zhenwei1108.

the class CMSCompressedDataParser method getContent.

/**
 * Return a typed stream which will allow the reading of the compressed content in expanded form.
 *
 * @param expanderProvider a provider of expander algorithm implementations.
 * @return a type stream which will yield the un-compressed content.
 * @throws CMSException if there is an exception parsing the CompressedData object.
 */
public CMSTypedStream getContent(InputExpanderProvider expanderProvider) throws CMSException {
    try {
        CompressedDataParser comData = new CompressedDataParser((ASN1SequenceParser) _contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser content = comData.getEncapContentInfo();
        InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());
        ASN1OctetStringParser bytes = (ASN1OctetStringParser) content.getContent(BERTags.OCTET_STRING);
        return new CMSTypedStream(content.getContentType(), expander.getInputStream(bytes.getOctetStream()));
    } catch (IOException e) {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
Also used : ContentInfoParser(com.github.zhenwei.pkix.util.asn1.cms.ContentInfoParser) CompressedDataParser(com.github.zhenwei.pkix.util.asn1.cms.CompressedDataParser) InputExpander(com.github.zhenwei.pkix.operator.InputExpander) IOException(java.io.IOException) ASN1OctetStringParser(com.github.zhenwei.core.asn1.ASN1OctetStringParser)

Example 2 with InputExpander

use of com.github.zhenwei.pkix.operator.InputExpander in project LinLong-Java by zhenwei1108.

the class CMSCompressedData method getContentStream.

public CMSTypedStream getContentStream(InputExpanderProvider expanderProvider) {
    ContentInfo content = comData.getEncapContentInfo();
    ASN1OctetString bytes = (ASN1OctetString) content.getContent();
    InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());
    InputStream zIn = expander.getInputStream(bytes.getOctetStream());
    return new CMSTypedStream(content.getContentType(), zIn);
}
Also used : ASN1OctetString(com.github.zhenwei.core.asn1.ASN1OctetString) ContentInfo(com.github.zhenwei.pkix.util.asn1.cms.ContentInfo) InputStream(java.io.InputStream) InputExpander(com.github.zhenwei.pkix.operator.InputExpander)

Example 3 with InputExpander

use of com.github.zhenwei.pkix.operator.InputExpander in project LinLong-Java by zhenwei1108.

the class CMSCompressedData method getContent.

/**
 * Return the uncompressed content.
 *
 * @param expanderProvider a provider of expander algorithm implementations.
 * @return the uncompressed content
 * @throws CMSException if there is an exception un-compressing the data.
 */
public byte[] getContent(InputExpanderProvider expanderProvider) throws CMSException {
    ContentInfo content = comData.getEncapContentInfo();
    ASN1OctetString bytes = (ASN1OctetString) content.getContent();
    InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());
    InputStream zIn = expander.getInputStream(bytes.getOctetStream());
    try {
        return CMSUtils.streamToByteArray(zIn);
    } catch (IOException e) {
        throw new CMSException("exception reading compressed stream.", e);
    }
}
Also used : ASN1OctetString(com.github.zhenwei.core.asn1.ASN1OctetString) ContentInfo(com.github.zhenwei.pkix.util.asn1.cms.ContentInfo) InputStream(java.io.InputStream) InputExpander(com.github.zhenwei.pkix.operator.InputExpander) IOException(java.io.IOException)

Aggregations

InputExpander (com.github.zhenwei.pkix.operator.InputExpander)3 ASN1OctetString (com.github.zhenwei.core.asn1.ASN1OctetString)2 ContentInfo (com.github.zhenwei.pkix.util.asn1.cms.ContentInfo)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ASN1OctetStringParser (com.github.zhenwei.core.asn1.ASN1OctetStringParser)1 CompressedDataParser (com.github.zhenwei.pkix.util.asn1.cms.CompressedDataParser)1 ContentInfoParser (com.github.zhenwei.pkix.util.asn1.cms.ContentInfoParser)1