private String encryptAndSign(final Serializable value, final Key encryptionKey, final Key signingKey) {
        val encoded = FunctionUtils.doIf(isEncryptionPossible(encryptionKey),
            () -> {
                LOGGER.trace("Attempting to encrypt value based on encryption key defined by [{}]", getEncryptionKeySetting());
                return encryptValueAsJwt(encryptionKey, value);
            },
            value::toString).get();

        if (this.signingEnabled) {
            LOGGER.trace("Attempting to sign value based on signing key defined by [{}]", getSigningKeySetting());
            val signed = sign(encoded.getBytes(StandardCharsets.UTF_8), signingKey);
            return new String(signed, StandardCharsets.UTF_8);
        }
        return encoded;
    }
The {@link BaseStringCipherExecutor} is the default
implementation of {@link CipherExecutor}. It provides
a facade API to encrypt, sign, and verify values.

@author Misagh Moayyed
@since 4.1
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/cipher/BaseStringCipherExecutor.java