/** * Clean up expired records. */ @Scheduled(initialDelayString = "${cas.authn.mfa.trusted.cleaner.schedule.startDelay:PT10S}", fixedDelayString = "${cas.authn.mfa.trusted.cleaner.schedule.repeatInterval:PT60S}") public void clean() { if (!trustedProperties.getCleaner().getSchedule().isEnabled()) { LOGGER.debug("[{}] is disabled. Expired trusted authentication records will not automatically be cleaned up by CAS", getClass().getName()); return; } try { LOGGER.debug("Proceeding to clean up expired trusted authentication records..."); SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this); val validDate = LocalDateTime.now().minus(trustedProperties.getExpiration(), DateTimeUtils.toChronoUnit(trustedProperties.getTimeUnit())); LOGGER.info("Expiring records that are on/before [{}]", validDate); this.storage.expire(validDate); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } } }
/** * Devices registered and trusted. * * @return the set */ @ReadOperation public Set<? extends MultifactorAuthenticationTrustRecord> devices() { val unit = DateTimeUtils.toChronoUnit(properties.getTimeUnit()); val onOrAfter = LocalDateTime.now().minus(properties.getExpiration(), unit); this.mfaTrustEngine.expire(onOrAfter); return this.mfaTrustEngine.get(onOrAfter); }
/** * Devices for user. * * @param username the username * @return the set */ @ReadOperation public Set<? extends MultifactorAuthenticationTrustRecord> devicesForUser(@Selector final String username) { val unit = DateTimeUtils.toChronoUnit(properties.getTimeUnit()); val onOrAfter = LocalDateTime.now().minus(properties.getExpiration(), unit); this.mfaTrustEngine.expire(onOrAfter); return this.mfaTrustEngine.get(username, onOrAfter); }
val unit = DateTimeUtils.toChronoUnit(trustedProperties.getTimeUnit()); val onOrAfter = LocalDateTime.now().minus(trustedProperties.getExpiration(), unit); LOGGER.debug("Retrieving trusted authentication records for [{}] that are on/after [{}]", principal, onOrAfter);