private String signAndEncrypt(final Serializable value, final Key encryptionKey, final Key signingKey) {
        val encoded = FunctionUtils.doIf(this.signingEnabled,
            () -> {
                LOGGER.trace("Attempting to sign value based on signing key defined by [{}]", getSigningKeySetting());
                val signed = sign(value.toString().getBytes(StandardCharsets.UTF_8), signingKey);
                return new String(signed, StandardCharsets.UTF_8);
            },
            value::toString
        ).get();

        return FunctionUtils.doIf(isEncryptionPossible(encryptionKey),
            () -> {
                LOGGER.trace("Attempting to encrypt value based on encryption key defined by [{}]", getEncryptionKeySetting());
                return encryptValueAsJwt(encryptionKey, encoded);
            },
            () -> encoded).get();
    }
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