Search in sources :

Example 1 with HardTimeoutExpirationPolicy

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

the class CasCoreTicketsConfiguration method ticketGrantingTicketExpirationPolicy.

@ConditionalOnMissingBean(name = "ticketGrantingTicketExpirationPolicy")
@Bean
public ExpirationPolicy ticketGrantingTicketExpirationPolicy() {
    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) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with HardTimeoutExpirationPolicy

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

the class CasCoreTicketsConfiguration method rememberMeExpirationPolicy.

@Bean
public ExpirationPolicy rememberMeExpirationPolicy() {
    final TicketGrantingTicketProperties tgt = casProperties.getTicket().getTgt();
    final HardTimeoutExpirationPolicy rememberMePolicy = new HardTimeoutExpirationPolicy(tgt.getRememberMe().getTimeToKillInSeconds());
    final RememberMeDelegatingExpirationPolicy p = new RememberMeDelegatingExpirationPolicy(ticketGrantingTicketExpirationPolicy());
    p.addPolicy(RememberMeDelegatingExpirationPolicy.PolicyTypes.REMEMBER_ME, rememberMePolicy);
    p.addPolicy(RememberMeDelegatingExpirationPolicy.PolicyTypes.DEFAULT, ticketGrantingTicketExpirationPolicy());
    return p;
}
Also used : HardTimeoutExpirationPolicy(org.apereo.cas.ticket.support.HardTimeoutExpirationPolicy) TicketGrantingTicketProperties(org.apereo.cas.configuration.model.core.ticket.TicketGrantingTicketProperties) RememberMeDelegatingExpirationPolicy(org.apereo.cas.ticket.support.RememberMeDelegatingExpirationPolicy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with HardTimeoutExpirationPolicy

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

the class SurrogateAuthenticationConfiguration method grantingTicketExpirationPolicy.

@Bean
public ExpirationPolicy grantingTicketExpirationPolicy(@Qualifier("ticketGrantingTicketExpirationPolicy") final ExpirationPolicy ticketGrantingTicketExpirationPolicy) {
    final SurrogateAuthenticationProperties su = casProperties.getAuthn().getSurrogate();
    final HardTimeoutExpirationPolicy surrogatePolicy = new HardTimeoutExpirationPolicy(su.getTgt().getTimeToKillInSeconds());
    final SurrogateSessionExpirationPolicy policy = new SurrogateSessionExpirationPolicy(surrogatePolicy);
    policy.addPolicy(SurrogateSessionExpirationPolicy.PolicyTypes.SURROGATE, surrogatePolicy);
    policy.addPolicy(SurrogateSessionExpirationPolicy.PolicyTypes.DEFAULT, ticketGrantingTicketExpirationPolicy);
    return policy;
}
Also used : SurrogateAuthenticationProperties(org.apereo.cas.configuration.model.support.surrogate.SurrogateAuthenticationProperties) HardTimeoutExpirationPolicy(org.apereo.cas.ticket.support.HardTimeoutExpirationPolicy) SurrogateSessionExpirationPolicy(org.apereo.cas.ticket.support.SurrogateSessionExpirationPolicy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with HardTimeoutExpirationPolicy

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

the class CasCoreTicketsConfiguration method grantingTicketExpirationPolicy.

@ConditionalOnMissingBean(name = "grantingTicketExpirationPolicy")
@Bean
public ExpirationPolicy grantingTicketExpirationPolicy() {
    final TicketGrantingTicketProperties tgt = casProperties.getTicket().getTgt();
    if (tgt.getRememberMe().isEnabled()) {
        final RememberMeDelegatingExpirationPolicy p = new RememberMeDelegatingExpirationPolicy();
        p.setRememberMeExpirationPolicy(new HardTimeoutExpirationPolicy(tgt.getRememberMe().getTimeToKillInSeconds()));
        p.setSessionExpirationPolicy(buildTicketGrantingTicketExpirationPolicy());
        return p;
    }
    return buildTicketGrantingTicketExpirationPolicy();
}
Also used : HardTimeoutExpirationPolicy(org.apereo.cas.ticket.support.HardTimeoutExpirationPolicy) TicketGrantingTicketProperties(org.apereo.cas.configuration.model.core.ticket.TicketGrantingTicketProperties) RememberMeDelegatingExpirationPolicy(org.apereo.cas.ticket.support.RememberMeDelegatingExpirationPolicy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with HardTimeoutExpirationPolicy

use of org.apereo.cas.ticket.support.HardTimeoutExpirationPolicy 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

HardTimeoutExpirationPolicy (org.apereo.cas.ticket.support.HardTimeoutExpirationPolicy)6 TicketGrantingTicketProperties (org.apereo.cas.configuration.model.core.ticket.TicketGrantingTicketProperties)4 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)4 Bean (org.springframework.context.annotation.Bean)4 AlwaysExpiresExpirationPolicy (org.apereo.cas.ticket.support.AlwaysExpiresExpirationPolicy)2 MultiTimeUseOrTimeoutExpirationPolicy (org.apereo.cas.ticket.support.MultiTimeUseOrTimeoutExpirationPolicy)2 NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)2 RememberMeDelegatingExpirationPolicy (org.apereo.cas.ticket.support.RememberMeDelegatingExpirationPolicy)2 ThrottledUseAndTimeoutExpirationPolicy (org.apereo.cas.ticket.support.ThrottledUseAndTimeoutExpirationPolicy)2 TicketGrantingTicketExpirationPolicy (org.apereo.cas.ticket.support.TicketGrantingTicketExpirationPolicy)2 TimeoutExpirationPolicy (org.apereo.cas.ticket.support.TimeoutExpirationPolicy)2 Set (java.util.Set)1 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)1 AuditableExecution (org.apereo.cas.audit.AuditableExecution)1 AuditableExecutionResult (org.apereo.cas.audit.AuditableExecutionResult)1 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)1 DefaultAuthenticationServiceSelectionStrategy (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy)1 Service (org.apereo.cas.authentication.principal.Service)1 WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)1 SurrogateAuthenticationProperties (org.apereo.cas.configuration.model.support.surrogate.SurrogateAuthenticationProperties)1