Hi all, 

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

*Config file*

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);
            }
        }
    }

}

*spring.factories*
org.springframework.boot.autoconfigure.EnableAutoConfiguration=net.mycompany.cas.audit.cleaner.MyCompanyJdbcAuditTrailSchedulingConfiguration
 


Cheers!
- Andy

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/7ce2572b-41cc-4477-8536-3f26fad93da7%40apereo.org.

Reply via email to