Package org.apereo.cas.util
Class CompressionUtils
- java.lang.Object
-
- org.apereo.cas.util.CompressionUtils
-
public class CompressionUtils extends java.lang.ObjectThis isCompressionUtilsthat encapsulates common compression calls and operations in one spot.- Since:
- 4.1
-
-
Constructor Summary
Constructors Constructor Description CompressionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringcompress(java.lang.String srcTxt)Use ZipOutputStream to zip text to byte array, then convert byte array to base64 string, so it can be transferred via http request.static java.lang.StringdecodeByteArrayToString(byte[] bytes)Decode the byte[] in base64 to a string.static java.lang.Stringdecompress(java.lang.String zippedBase64Str)First decode base64 String to byte array, then use ZipInputStream to revert the byte array to a string.static java.lang.Stringdeflate(byte[] bytes)Deflate the given bytes using zlib.static java.lang.Stringdeflate(java.lang.String data)Deflate the given string via aDeflater.static java.lang.Stringinflate(byte[] bytes)Inflate the byte[] to a string.static org.springframework.core.io.WritableResourcetoZipFile(java.util.stream.Stream<?> dataStream, java.util.function.Function<java.lang.Object,java.io.File> converter, java.lang.String prefix)To zip file.
-
-
-
Method Detail
-
deflate
public static java.lang.String deflate(byte[] bytes)
Deflate the given bytes using zlib.- Parameters:
bytes- the bytes- Returns:
- the converted string
-
deflate
public static java.lang.String deflate(java.lang.String data)
Deflate the given string via aDeflater.- Parameters:
data- the data- Returns:
- base64 encoded string
-
inflate
public static java.lang.String inflate(byte[] bytes)
Inflate the byte[] to a string.- Parameters:
bytes- the data to decode- Returns:
- the new string
-
decompress
public static java.lang.String decompress(java.lang.String zippedBase64Str)
First decode base64 String to byte array, then use ZipInputStream to revert the byte array to a string.- Parameters:
zippedBase64Str- the zipped base 64 str- Returns:
- the string, or null
-
decodeByteArrayToString
public static java.lang.String decodeByteArrayToString(byte[] bytes)
Decode the byte[] in base64 to a string.- Parameters:
bytes- the data to encode- Returns:
- the new string
-
compress
public static java.lang.String compress(java.lang.String srcTxt)
Use ZipOutputStream to zip text to byte array, then convert byte array to base64 string, so it can be transferred via http request.- Parameters:
srcTxt- the src txt- Returns:
- the string in UTF-8 format and base64'ed, or null.
-
toZipFile
public static org.springframework.core.io.WritableResource toZipFile(java.util.stream.Stream<?> dataStream, java.util.function.Function<java.lang.Object,java.io.File> converter, java.lang.String prefix)To zip file.- Parameters:
dataStream- the data streamconverter- the converterprefix- the prefix- Returns:
- the writable resource
-
-