/** * return a CompressedData object from the given object. * * @param _obj the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static CompressedData getInstance( Object _obj) { if (_obj == null || _obj instanceof CompressedData) { return (CompressedData)_obj; } if (_obj instanceof ASN1Sequence) { return new CompressedData((ASN1Sequence)_obj); } throw new IllegalArgumentException("Invalid CompressedData: " + _obj.getClass().getName()); }
/** * Return a CompressedData object from the given object. * <p> * Accepted inputs: * <ul> * <li> null → null * <li> {@link CompressedData} object * <li> {@link org.spongycastle.asn1.ASN1Sequence#getInstance(java.lang.Object) ASN1Sequence} input formats with CompressedData structure inside * </ul> * * @param obj the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static CompressedData getInstance( Object obj) { if (obj instanceof CompressedData) { return (CompressedData)obj; } if (obj != null) { return new CompressedData(ASN1Sequence.getInstance(obj)); } return null; }
/** Obtiene un tipo CompressedData. * @param data * 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); }
new CompressedData(comAlgId, comContent));
new CompressedData(comAlgId, comContent));