Example usage for org.bouncycastle.asn1.cms CompressedData CompressedData

List of usage examples for org.bouncycastle.asn1.cms CompressedData CompressedData

Introduction

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

Prototype

public CompressedData(AlgorithmIdentifier compressionAlgorithm, ContentInfo encapContentInfo) 

Source Link

Usage

From source file:es.gob.afirma.envelopers.cms.CMSCompressedData.java

License:Open Source License

/** Obtiene un tipo CompressedData.
 * @param data/*from  ww w  .j  av  a  2  s. co  m*/
 *        Datos a comprimir
 * @return Tipo CompressedData.
 * @throws IOException En caso de error en la lectura o tratamiento de datos */
static byte[] genCompressedData(final byte[] data) throws IOException {

    // Algoritmo de compresion
    final AlgorithmIdentifier comAlgId = new AlgorithmIdentifier(new ASN1ObjectIdentifier(ZLIB));

    // Se comprimen los datos
    final byte[] compressed = BinaryUtils.compress(data);

    final ASN1OctetString comOcts = new BEROctetString(compressed);

    // Contenido comprimido
    final ContentInfo comContent = new ContentInfo(CMSObjectIdentifiers.data, comOcts);

    return new ContentInfo(CMSObjectIdentifiers.compressedData, new CompressedData(comAlgId, comContent))
            .getEncoded(ASN1Encoding.DER);

}