List of usage examples for org.bouncycastle.cms.jcajce ZlibExpanderProvider ZlibExpanderProvider
public ZlibExpanderProvider()
From source file:com.zotoh.crypto.CryptoUte.java
License:Open Source License
/** * @param inp/*from w w w . j av a 2 s.c om*/ * @return * @throws GeneralSecurityException * @throws IOException */ public static StreamData decompressAsStream(InputStream inp) throws GeneralSecurityException, IOException { CMSTypedStream cms = null; StreamData r = null; if (inp != null) try { cms = new CMSCompressedDataParser(inp).getContent(new ZlibExpanderProvider()); if (cms == null) { throw new GeneralSecurityException("Failed to decompress stream: corrupted content"); } r = readStream(cms.getContentStream()); } catch (CMSException e) { throw new GeneralSecurityException(e); } return r != null ? r : new StreamData(); }
From source file:de.mendelson.comm.as2.message.AS2MessageParser.java
/** * Uncompresses message data/* w w w. java 2 s . co m*/ */ public byte[] decompressData(AS2MessageInfo info, SMIMECompressed compressed, long compressedSize) throws Exception { byte[] decompressedData = compressed.getContent(new ZlibExpanderProvider()); info.setCompressionType(AS2Message.COMPRESSION_ZLIB); if (this.logger != null) { this.logger.log(Level.INFO, this.rb.getResourceString("data.compressed.expanded", new Object[] { info.getMessageId(), AS2Tools.getDataSizeDisplay(compressedSize), AS2Tools.getDataSizeDisplay(decompressedData.length) }), info); } return (decompressedData); }
From source file:de.mendelson.comm.as2.message.AS2MessageParser.java
/** * Looks if the data is compressed and decompresses it if necessary */// w w w .j ava 2 s. co m public Part decompressData(Part part, AS2Message message) throws Exception { Part compressedPart = this.getCompressedEmbeddedPart(part); if (compressedPart == null) { return (part); } SMIMECompressed compressed = null; if (compressedPart instanceof MimeBodyPart) { compressed = new SMIMECompressed((MimeBodyPart) compressedPart); } else { compressed = new SMIMECompressed((MimeMessage) compressedPart); } byte[] decompressedData = compressed.getContent(new ZlibExpanderProvider()); ((AS2MessageInfo) message.getAS2Info()).setCompressionType(AS2Message.COMPRESSION_ZLIB); if (this.logger != null) { this.logger.log(Level.INFO, this.rb.getResourceString("data.compressed.expanded", new Object[] { message.getAS2Info().getMessageId(), AS2Tools.getDataSizeDisplay(part.getSize()), AS2Tools.getDataSizeDisplay(decompressedData.length) }), message.getAS2Info()); } ByteArrayInputStream memIn = new ByteArrayInputStream(decompressedData); MimeBodyPart uncompressedPayload = new MimeBodyPart(memIn); memIn.close(); return (uncompressedPayload); }
From source file:de.mendelson.util.security.BCCryptoHelper.java
/** * Uncompresses a data stream/*w w w .j a v a2 s . c o m*/ */ public void uncompressCMS(InputStream compressed, OutputStream uncompressed) throws Exception { CMSCompressedDataParser compressedParser = new CMSCompressedDataParser(new BufferedInputStream(compressed)); this.copyStreams(compressedParser.getContent(new ZlibExpanderProvider()).getContentStream(), uncompressed); uncompressed.flush(); }