Example usage for org.bouncycastle.cms CMSCompressedDataParser CMSCompressedDataParser

List of usage examples for org.bouncycastle.cms CMSCompressedDataParser CMSCompressedDataParser

Introduction

In this page you can find the example usage for org.bouncycastle.cms CMSCompressedDataParser CMSCompressedDataParser.

Prototype

public CMSCompressedDataParser(InputStream compressedData) throws CMSException 

Source Link

Usage

From source file:com.zotoh.crypto.CryptoUte.java

License:Open Source License

/**
 * @param inp//from w  w w.ja  v a  2s. c  o m
 * @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.util.security.BCCryptoHelper.java

/**
 * Uncompresses a data stream/*  ww  w .  ja v  a  2 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();
}

From source file:org.neociclo.odetteftp.util.EnvelopingUtil.java

License:Apache License

/**
 * /*ww w  . j  a  v  a  2 s  .  co m*/
 * @param compressedData
 *            InputStream of encapsulated compressed data
 * @return InputStream the original (uncompressed) readable data stream
 * @throws CMSException
 */
public static InputStream openCompressedDataParser(InputStream compressedData) throws CMSException {

    // set up the parser and retrieve the original data stream
    CMSCompressedDataParser cp = new CMSCompressedDataParser(compressedData);
    InputStream contentStream = cp.getContent().getContentStream();

    return contentStream;
}

From source file:org.neociclo.odetteftp.util.EnvelopingUtil.java

License:Apache License

public static void parseCompressedDataContentStream(InputStream compressedData, OutputStream outStream)
        throws CMSException, IOException {

    // use the CMS parser to uncompress the CompressedData
    CMSCompressedDataParser cp = new CMSCompressedDataParser(compressedData);
    InputStream uncompressed = cp.getContent().getContentStream();

    IoUtil.copyStream(uncompressed, outStream);

}