/** @deprecated use open(OutputStream, ASN1ObjectIdentifier, ContentCompressor) */
  public OutputStream open(OutputStream out, String contentOID, String compressionOID)
      throws IOException {
    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));

    OutputStream octetStream =
        CMSUtils.createBEROctetOutputStream(eiGen.getRawOutputStream(), 0, true, _bufferSize);

    return new CmsCompressedOutputStream(new DeflaterOutputStream(octetStream), sGen, cGen, eiGen);
  }
  /**
   * Open a compressing output stream.
   *
   * @param contentOID
   * @param out
   * @param compressor
   * @return
   * @throws IOException
   */
  public OutputStream open(
      ASN1ObjectIdentifier contentOID, OutputStream out, OutputCompressor compressor)
      throws IOException {
    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
    //
    cGen.addObject(compressor.getAlgorithmIdentifier());

    //
    // Encapsulated ContentInfo
    //
    BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream());

    eiGen.addObject(contentOID);

    OutputStream octetStream =
        CMSUtils.createBEROctetOutputStream(eiGen.getRawOutputStream(), 0, true, _bufferSize);

    return new CmsCompressedOutputStream(
        compressor.getOutputStream(octetStream), sGen, cGen, eiGen);
  }
 public void close() throws IOException {
   _out.close();
   _eiGen.close();
   _cGen.close();
   _sGen.close();
 }