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

CMSCompressedDataGenerator

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

A simple example of usage.

CMSCompressedDataGenerator fact = new CMSCompressedDataGenerator();

CMSCompressedData data = fact.generate(content, algorithm);

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


           
     
    
    
Methods Summary
public CMSCompressedDatagenerate(CMSProcessable content, java.lang.String compressionOID)
generate an object that contains an CMS Compressed Data

        AlgorithmIdentifier     comAlgId;
        ASN1OctetString         comOcts;

        try
        {
            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
            DeflaterOutputStream  zOut = new DeflaterOutputStream(bOut);

            content.write(zOut);

            zOut.close();

            comAlgId = makeAlgId(compressionOID, null);
            comOcts = new BERConstructedOctetString(bOut.toByteArray());
        }
        catch (IOException e)
        {
            throw new CMSException("exception encoding data.", e);
        }

        ContentInfo     comContent = new ContentInfo(
                                    CMSObjectIdentifiers.data, comOcts);

        ContentInfo     contentInfo = new ContentInfo(
                                    CMSObjectIdentifiers.compressedData,
                                    new CompressedData(comAlgId, comContent));

        return new CMSCompressedData(contentInfo);
    
private org.bouncycastle.asn1.x509.AlgorithmIdentifiermakeAlgId(java.lang.String oid, byte[] params)

        if (params != null)
        {
            return new AlgorithmIdentifier(
                            new DERObjectIdentifier(oid), makeObj(params));
        }
        else
        {
            return new AlgorithmIdentifier(new DERObjectIdentifier(oid));
        }
    
private org.bouncycastle.asn1.DERObjectmakeObj(byte[] encoding)

        if (encoding == null)
        {
            return null;
        }

        ByteArrayInputStream    bIn = new ByteArrayInputStream(encoding);
        ASN1InputStream         aIn = new ASN1InputStream(bIn);

        return aIn.readObject();