/** Método que extrae el contenido de un tipo CompressedData. * @param data El tipo CompressedData. * @return El contenido del envoltorio. * @throws IOException Cuando hay un error de lectura de datos. * @throws DataFormatException Si los datos no estaban comprimidos. */ static byte[] getContentCompressedData(final byte[] data) throws IOException, DataFormatException { final ASN1Sequence contentEnvelopedData = Utils.fetchWrappedData(data); final CompressedData compressed = CompressedData.getInstance(contentEnvelopedData); final DEROctetString dos = (DEROctetString) compressed.getEncapContentInfo().getContent(); return BinaryUtils.uncompress(dos.getOctets()); } }
/** * 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); } }
/** * 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); } }