Search in sources :

Example 1 with TicketGrantingTicketExpirationPolicy

use of org.apereo.cas.ticket.support.TicketGrantingTicketExpirationPolicy in project cas by apereo.

the class CasCoreTicketsConfiguration method buildTicketGrantingTicketExpirationPolicy.

private ExpirationPolicy buildTicketGrantingTicketExpirationPolicy() {
    final TicketGrantingTicketProperties tgt = casProperties.getTicket().getTgt();
    if (tgt.getMaxTimeToLiveInSeconds() < 0 && tgt.getTimeToKillInSeconds() < 0) {
        LOGGER.warn("Ticket-granting ticket expiration policy is set to NEVER expire tickets.");
        return new NeverExpiresExpirationPolicy();
    }
    if (tgt.getTimeout().getMaxTimeToLiveInSeconds() > 0) {
        LOGGER.debug("Ticket-granting ticket expiration policy is based on a timeout of [{}] seconds", tgt.getTimeout().getMaxTimeToLiveInSeconds());
        return new TimeoutExpirationPolicy(tgt.getTimeout().getMaxTimeToLiveInSeconds());
    }
    if (tgt.getMaxTimeToLiveInSeconds() > 0 && tgt.getTimeToKillInSeconds() > 0) {
        LOGGER.debug("Ticket-granting ticket expiration policy is based on hard/idle timeouts of [{}]/[{}] seconds", tgt.getMaxTimeToLiveInSeconds(), tgt.getTimeToKillInSeconds());
        return new TicketGrantingTicketExpirationPolicy(tgt.getMaxTimeToLiveInSeconds(), tgt.getTimeToKillInSeconds());
    }
    if (tgt.getThrottledTimeout().getTimeInBetweenUsesInSeconds() > 0 && tgt.getThrottledTimeout().getTimeToKillInSeconds() > 0) {
        final ThrottledUseAndTimeoutExpirationPolicy p = new ThrottledUseAndTimeoutExpirationPolicy();
        p.setTimeToKillInSeconds(tgt.getThrottledTimeout().getTimeToKillInSeconds());
        p.setTimeInBetweenUsesInSeconds(tgt.getThrottledTimeout().getTimeInBetweenUsesInSeconds());
        LOGGER.debug("Ticket-granting ticket expiration policy is based on throttled timeouts");
        return p;
    }
    if (tgt.getHardTimeout().getTimeToKillInSeconds() > 0) {
        LOGGER.debug("Ticket-granting ticket expiration policy is based on a hard timeout of [{}] seconds", tgt.getHardTimeout().getTimeToKillInSeconds());
        return new HardTimeoutExpirationPolicy(tgt.getHardTimeout().getTimeToKillInSeconds());
    }
    LOGGER.warn("Ticket-granting ticket expiration policy is set to ALWAYS expire tickets.");
    return new AlwaysExpiresExpirationPolicy();
}
Also used : ThrottledUseAndTimeoutExpirationPolicy(org.apereo.cas.ticket.support.ThrottledUseAndTimeoutExpirationPolicy) NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) HardTimeoutExpirationPolicy(org.apereo.cas.ticket.support.HardTimeoutExpirationPolicy) TicketGrantingTicketProperties(org.apereo.cas.configuration.model.core.ticket.TicketGrantingTicketProperties) TicketGrantingTicketExpirationPolicy(org.apereo.cas.ticket.support.TicketGrantingTicketExpirationPolicy) AlwaysExpiresExpirationPolicy(org.apereo.cas.ticket.support.AlwaysExpiresExpirationPolicy) ThrottledUseAndTimeoutExpirationPolicy(org.apereo.cas.ticket.support.ThrottledUseAndTimeoutExpirationPolicy) HardTimeoutExpirationPolicy(org.apereo.cas.ticket.support.HardTimeoutExpirationPolicy) MultiTimeUseOrTimeoutExpirationPolicy(org.apereo.cas.ticket.support.MultiTimeUseOrTimeoutExpirationPolicy) TimeoutExpirationPolicy(org.apereo.cas.ticket.support.TimeoutExpirationPolicy)

Aggregations

TicketGrantingTicketProperties (org.apereo.cas.configuration.model.core.ticket.TicketGrantingTicketProperties)1 AlwaysExpiresExpirationPolicy (org.apereo.cas.ticket.support.AlwaysExpiresExpirationPolicy)1 HardTimeoutExpirationPolicy (org.apereo.cas.ticket.support.HardTimeoutExpirationPolicy)1 MultiTimeUseOrTimeoutExpirationPolicy (org.apereo.cas.ticket.support.MultiTimeUseOrTimeoutExpirationPolicy)1 NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)1 ThrottledUseAndTimeoutExpirationPolicy (org.apereo.cas.ticket.support.ThrottledUseAndTimeoutExpirationPolicy)1 TicketGrantingTicketExpirationPolicy (org.apereo.cas.ticket.support.TicketGrantingTicketExpirationPolicy)1 TimeoutExpirationPolicy (org.apereo.cas.ticket.support.TimeoutExpirationPolicy)1