All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testifyproject.bouncycastle.cms.CMSCompressedData Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package org.testifyproject.bouncycastle.cms;

import java.org.testifyproject.testifyproject.IOException;
import java.org.testifyproject.testifyproject.InputStream;

import org.testifyproject.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.testifyproject.bouncycastle.asn1.ASN1OctetString;
import org.testifyproject.bouncycastle.asn1.cms.CompressedData;
import org.testifyproject.bouncycastle.asn1.cms.ContentInfo;
import org.testifyproject.bouncycastle.operator.InputExpander;
import org.testifyproject.bouncycastle.operator.InputExpanderProvider;

/**
 * containing class for an CMS Compressed Data object
 * 
 *     CMSCompressedData cd = new CMSCompressedData(inputStream);
 *
 *     process(cd.getContent(new ZlibExpanderProvider()));
 * 
*/ public class CMSCompressedData { ContentInfo contentInfo; CompressedData org.testifyproject.testifyprojectData; public CMSCompressedData( byte[] org.testifyproject.testifyprojectpressedData) throws CMSException { this(CMSUtils.readContentInfo(org.testifyproject.testifyprojectpressedData)); } public CMSCompressedData( InputStream org.testifyproject.testifyprojectpressedData) throws CMSException { this(CMSUtils.readContentInfo(org.testifyproject.testifyprojectpressedData)); } public CMSCompressedData( ContentInfo contentInfo) throws CMSException { this.contentInfo = contentInfo; try { this.org.testifyproject.testifyprojectData = CompressedData.getInstance(contentInfo.getContent()); } catch (ClassCastException e) { throw new CMSException("Malformed content.", e); } catch (IllegalArgumentException e) { throw new CMSException("Malformed content.", e); } } public ASN1ObjectIdentifier getContentType() { return contentInfo.getContentType(); } /** * Return the uncompressed content. * * @param expanderProvider a provider of expander algorithm implementations. * @return the uncompressed content * @throws CMSException if there is an exception un-org.testifyproject.testifyprojectpressing the data. */ public byte[] getContent(InputExpanderProvider expanderProvider) throws CMSException { ContentInfo content = org.testifyproject.testifyprojectData.getEncapContentInfo(); ASN1OctetString bytes = (ASN1OctetString)content.getContent(); InputExpander expander = expanderProvider.get(org.testifyproject.testifyprojectData.getCompressionAlgorithmIdentifier()); InputStream zIn = expander.getInputStream(bytes.getOctetStream()); try { return CMSUtils.streamToByteArray(zIn); } catch (IOException e) { throw new CMSException("exception reading org.testifyproject.testifyprojectpressed stream.", e); } } /** * return the ContentInfo */ public ContentInfo toASN1Structure() { return contentInfo; } /** * return the ASN.1 encoded representation of this object. */ public byte[] getEncoded() throws IOException { return contentInfo.getEncoded(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy