@Override
    public byte[] encode(final Object o) throws IOException {
        if (o == null) {
            return ArrayUtils.EMPTY_BYTE_ARRAY;
        }
        try (val outBuffer = new ByteArrayOutputStream()) {
            try (val out = this.compression
                ? new ObjectOutputStream(new GZIPOutputStream(outBuffer))
                : new ObjectOutputStream(outBuffer)) {

                writeObjectToOutputStream(o, out);
            } catch (final NotSerializableException e) {
                LoggingUtils.warn(LOGGER, e);
            }
            return encrypt(outBuffer);
        }
    }
Flag to indicate whether to Gzip compression before encryption.
core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/executor/EncryptedTranscoder.java