cas入门之二十五:ticket清理器

时间:2022-01-21 22:43:46
当ticket存储器,没有能力管理ticket的状态时,则需要ticket清理器。默认的内存ticket存储器,jpa存储器等都需要ticket清理器;memecached ,ehcache等存储器则不需要ticket清理器。默认情况下,ticket 清理器配置在cas/WEB-INF/spring-configuration/ticketRegistry.xml文件中,如下所示:
<!--Quartz -->
    <!-- TICKET REGISTRY CLEANER -->
    <bean id="ticketRegistryCleaner" class="org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner"
        p:ticketRegistry-ref="ticketRegistry" />
    
    <bean id="jobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
        p:targetObject-ref="ticketRegistryCleaner"
        p:targetMethod="clean" />
    
    <bean id="triggerJobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.SimpleTriggerBean"
        p:jobDetail-ref="jobDetailTicketRegistryCleaner"
        p:startDelay="20000"
        p:repeatInterval="5000000" />
DefaultTicketRegistryCleaner集成一个接口org.jasig.cas.ticket.registry.support.LockingStrategy,它有三个实现类:
org.jasig.cas.ticket.registry.support.NoOpLockingStrategy
org.jasig.cas.ticket.registry.support.JdbcLockingStrategy,这个已过期,不推荐使用
org.jasig.cas.ticket.registry.support.JpaLockingStrategy,这个在

cas 入门之十五:ticket 存储方案-jpa ticket存储

已经应用过;默认情况应用的是NoOpLockingStrategy;

如果我们应用其他的后台机制去处理过期ticket,则可能需要实现LockingStrategy接口。