protected MultifactorAuthenticationTrustRecord storeTrustedAuthenticationRecord(
        final RequestContext requestContext,
        final Authentication authentication,
        final MultifactorAuthenticationTrustBean deviceRecord) {
        if (storageService.isAvailable()) {
            val principal = authentication.getPrincipal().getId();
            LOGGER.debug("Attempting to store trusted authentication record for [{}] as device [{}]", principal, deviceRecord.getDeviceName());
            val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
            val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(requestContext);
            val fingerprint = deviceFingerprintStrategy.determineFingerprint(authentication, request, response);
            val record = MultifactorAuthenticationTrustRecord.newInstance(principal,
                MultifactorAuthenticationTrustUtils.generateGeography(), fingerprint);
            record.setName(deviceRecord.getDeviceName());
            record.setMultifactorAuthenticationProvider(requestContext.getFlowScope().get(CasWebflowConstants.VAR_ID_MFA_PROVIDER_ID, String.class));
            if (deviceRecord.getTimeUnit() != ChronoUnit.FOREVER && deviceRecord.getExpiration() > 0) {
                record.expireIn(deviceRecord.getExpiration(), deviceRecord.getTimeUnit());
            } else {
                record.neverExpire();
            }

            LOGGER.debug("Trusted authentication record will expire at [{}]", record.getExpirationDate());
            val stored = storageService.save(record);
            LOGGER.debug("Saved trusted authentication record for [{}] under [{}]", principal, stored.getName());
            return stored;
        }
        return null;
    }
This is {@link MultifactorAuthenticationSetTrustAction}.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-trusted-mfa-core/src/main/java/org/apereo/cas/trusted/web/flow/MultifactorAuthenticationSetTrustAction.java