FileDocCategorySizeDatePackage
CMSCompressedDataStreamGenerator.javaAPI DocBouncy Castle Crypto API 1.41 (Java 1.5)3777Wed Oct 01 10:55:30 BST 2008org.bouncycastle.cms

CMSCompressedDataStreamGenerator

public class CMSCompressedDataStreamGenerator extends Object
General class for generating a compressed CMS message stream.

A simple example of usage.

CMSCompressedDataStreamGenerator gen = new CMSCompressedDataStreamGenerator();

OutputStream cOut = gen.open(outputStream, CMSCompressedDataStreamGenerator.ZLIB);

cOut.write(data);

cOut.close();

Fields Summary
public static final String
ZLIB
Constructors Summary
public CMSCompressedDataStreamGenerator()
base constructor


           
     
    
    
Methods Summary
public java.io.OutputStreamopen(java.io.OutputStream out, java.lang.String compressionOID)

        return open(out, CMSObjectIdentifiers.data.getId(), compressionOID);
    
public java.io.OutputStreamopen(java.io.OutputStream out, java.lang.String contentOID, java.lang.String compressionOID)

        BERSequenceGenerator sGen = new BERSequenceGenerator(out);
        
        sGen.addObject(CMSObjectIdentifiers.compressedData);
        
        //
        // Compressed Data
        //
        BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true);
        
        cGen.addObject(new DERInteger(0));
        
        //
        // AlgorithmIdentifier
        //
        DERSequenceGenerator algGen = new DERSequenceGenerator(cGen.getRawOutputStream());
        
        algGen.addObject(new DERObjectIdentifier(ZLIB));

        algGen.close();
        
        //
        // Encapsulated ContentInfo
        //
        BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream());
        
        eiGen.addObject(new DERObjectIdentifier(contentOID));
        
        BEROctetStringGenerator octGen = new BEROctetStringGenerator(eiGen.getRawOutputStream(), 0, true);
        
        return new CmsCompressedOutputStream(new DeflaterOutputStream(octGen.getOctetOutputStream()), sGen, cGen, eiGen);