public class CompressionProvider extends AlgorithmID
1. Extend the CompressionProvider class, and override method getInputStreamCompressEngine,
which is specified as follows:
if(algorithmid.equals(CompressionProvider.zlib_compress))
return new ZLIBCompressionInputStream(inputstream, CompressMode, blocksize);
else
throw new NoSuchAlgorithmException("Algorithm " + algorithmid.getAlgorithm().getName() + " not available!");
2. Specify the AlgorithmID for the compression algorithm being used. This AlgorithmID
should be added into the extension of the CompressionProvider as CompressionProvider is
an extension of AlgorithmID.
3. Write a Compression InputStream class which implements interface
InputStreamCompressEngine and make sure the getInputStream() method is
implemented.
4. The CompressedContent.setCompressionProvider() method can be used to set the CompressionProvider
which will be used.
| Modifier and Type | Field and Description |
|---|---|
static AlgorithmID |
zlib_compress
Creates an AlgorithmID for the
ZLIB compression algorithm. |
aes_128_CBC, aes_128_ECB, aes_128_wrap, aes_192_CBC, aes_192_ECB, aes_192_wrap, aes_256_CBC, aes_256_ECB, aes_256_wrap, cast3_CBC, cast5_CBC, cms_3DES_wrap, cms_cast_wrap, cms_cast5_wrap, cms_idea_wrap, cms_pwri_kek, cms_rc2_wrap, des_CBC, des_EDE3_CBC, dhKeyAgreement, dhSinglePass_cofactorDH_sha1kdf_scheme, dhSinglePass_cofactorDH_sha224kdf_scheme, dhSinglePass_cofactorDH_sha256kdf_scheme, dhSinglePass_cofactorDH_sha384kdf_scheme, dhSinglePass_cofactorDH_sha512kdf_scheme, dhSinglePass_stdDH_sha1kdf_scheme, dhSinglePass_stdDH_sha224kdf_scheme, dhSinglePass_stdDH_sha256kdf_scheme, dhSinglePass_stdDH_sha384kdf_scheme, dhSinglePass_stdDH_sha512kdf_scheme, dsa, dsa_With_SHA1, dsaWithSHA, dsaWithSHA1, dsaX957, ecdsa_with_Recommended, ecdsa_with_Sha224, ecdsa_with_Sha256, ecdsa_with_Sha384, ecdsa_with_Sha512, ecdsa_with_Specified, ecdsaWithSHA1, esdh, esdhKeyAgreement, id_ecPublicKey, id_RSASAA_PSS, idea_CBC, implementations, md2, md2WithRSAEncryption, md4, md4WithRSAEncryption, md5, md5WithRSAEncryption, mgf1, pbeWithMD5AndDES_CBC, pbeWithSHAAnd128BitRC2_CBC, pbeWithSHAAnd128BitRC4, pbeWithSHAAnd2_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd40BitRC2_CBC, pbeWithSHAAnd40BitRC4, pbkdf2, rc2_CBC, rc4, rc5_CBC, rsa, rsaEncryption, rsaESOAEP, sha, sha1, sha1WithRSAEncryption, sha224, sha224WithRSAEncryption, sha256, sha256WithRSAEncryption, sha384, sha384WithRSAEncryption, sha512, sha512WithRSAEncryption| Constructor and Description |
|---|
CompressionProvider() |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
compress(AlgorithmID algorithmid,
byte[] data,
int compressionMode)
Uses the given compression algorithm to compress/decompress the supplied input data.
|
InputStreamCompressEngine |
getInputStreamCompressEngine(AlgorithmID algorithmid,
java.io.InputStream inputstream,
int CompressMode,
int blocksize)
This method returns an InputStreamCompressEngine for compressing or decompressing
data read from some input stream.
|
changeObjectID, changeOIDString, clone, decode, encodeAbsentParametersAsNull, equals, getAlgorithm, getAlgorithmParameters, getAlgorithmParameters, getAlgorithmParameters, getCipherInstance, getCipherInstance, getDecodedAbsentParameters, getImplementationName, getInstance, getInstance, getKeyAgreementInstance, getKeyAgreementInstance, getKeyFactoryInstance, getKeyFactoryInstance, getKeyGeneratorInstance, getKeyGeneratorInstance, getKeyPairGeneratorInstance, getKeyPairGeneratorInstance, getMessageDigestInstance, getMessageDigestInstance, getName, getParameter, getRawImplementationName, getSecretKeyFactoryInstance, getSecretKeyFactoryInstance, getSignatureInstance, getSignatureInstance, initSignatureSign, initSignatureVerify, setAlgorithmParameters, setParameter, toASN1Object, toASN1Object, toEntrustAlgorithmID, toStringpublic static AlgorithmID zlib_compress
ZLIB compression algorithm.public InputStreamCompressEngine getInputStreamCompressEngine(AlgorithmID algorithmid, java.io.InputStream inputstream, int CompressMode, int blocksize) throws java.security.NoSuchAlgorithmException
algorithmid - the compression/decompression algorithm to be usedinputstream - the input stream supplying the data to be compressed/decompressedCompressMode - the compression mode to be used (COMPRESS or DECOMPRESS)blocksize - the size of the internal buffer, if used by the compress engine.java.security.NoSuchAlgorithmExceptionpublic byte[] compress(AlgorithmID algorithmid, byte[] data, int compressionMode) throws java.io.IOException, java.security.NoSuchAlgorithmException
algorithmid - the compression/decompression algorithm to be useddata - the input data to be compressed/decompressedcompressionMode - the compression mode to be used (COMPRESS or DECOMPRESS)IOExecption - if an I/O error occurs during data compression/decompressionjava.security.NoSuchAlgorithmException - - if the requested compression algorithm is not supportedjava.io.IOException