After seraching for a while, seems to me that maxAgeDays wasn't implemented at all in CAS 5 / 6.....
Anyway, I figure to just copy the ticket cleaner and implement that myself, I copied my implementation here to other can reference :D
package net.mycompany.cas.audit.cleaner;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.inspektr.audit.support.JdbcAuditTrailManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration("mycompanyJdbcAuditTrailSchedulingConfiguration")
@EnableConfigurationProperties(CasConfigurationProperties.class)
@EnableScheduling
@EnableAsync
@EnableTransactionManagement(proxyTargetClass = true)
//@AutoConfigureAfter(CasSupportJdbcAuditConfiguration.class)
public class MyCompanyJdbcAuditTrailSchedulingConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(MyCompanyJdbcAuditTrailSchedulingConfiguration.class);
@ConditionalOnMissingBean(name = "jdbcAuditTrailCleanerScheduler")
@Bean
@Autowired
@RefreshScope
public JdbcAuditCleanerScheduler jdbcAuditTrailCleanerScheduler(@Qualifier("jdbcAuditTrailManager") final JdbcAuditTrailManager jdbcAuditTrailManager) {
return new JdbcAuditCleanerScheduler(jdbcAuditTrailManager);
}
/**
* The Ticket registry cleaner scheduler. Because the cleaner itself is marked
* with {@link org.springframework.transaction.annotation.Transactional},
* we need to create a separate scheduler component that simply invokes it
* so that {@link Scheduled} annotations can be processed and not interfere
* with transaction semantics of the cleaner.
*/
public static class JdbcAuditCleanerScheduler {
private final JdbcAuditTrailManager jdbcAuditTrailManager;
public JdbcAuditCleanerScheduler(final JdbcAuditTrailManager jdbcAuditTrailManager) {
this.jdbcAuditTrailManager = jdbcAuditTrailManager;
}
// Every day, 1:01 a.m.
@Scheduled(cron = "0 1 1 * * ?")
public void run() {
try {
LOGGER.debug("Jdbc Audit Trail clean performed");
this.jdbcAuditTrailManager.clean();
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=net.mycompany.cas.audit.cleaner.MyCompanyJdbcAuditTrailSchedulingConfiguration