String deflateAndBase64Encode(final XMLObject message) throws MessageEncodingException {
        LOGGER.debug("Deflating and Base64 encoding SAML message");
        try {
            val messageStr = SerializeSupport.nodeToString(marshallMessage(message));
            LOGGER.trace("Output XML message: {}", messageStr);

            val bytesOut = new ByteArrayOutputStream();
            val deflater = new Deflater(Deflater.DEFLATED, true);
            val deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
            deflaterStream.write(messageStr.getBytes(StandardCharsets.UTF_8));
            deflaterStream.finish();

            return Base64Support.encode(bytesOut.toByteArray(), Base64Support.UNCHUNKED);
        } catch (final Exception e) {
            throw new MessageEncodingException("Unable to DEFLATE and Base64 encode SAML message", e);
        }
    }
DEFLATE (RFC1951) compresses the given SAML message.

@param message SAML message
@return DEFLATE compressed message
@throws MessageEncodingException thrown if there is a problem compressing the message
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java