use of org.apereo.cas.ticket.expiration.TicketGrantingTicketExpirationPolicy in project cas by apereo.
the class NonInflatingSaml20ObjectBuilderTests method verifyAttrValueTypeXSObject.
@Test
public void verifyAttrValueTypeXSObject() {
val builder = new NonInflatingSaml20ObjectBuilder(openSamlConfigBean);
assertNotNull(builder.newAttribute("email", "mail", List.of(new TicketGrantingTicketExpirationPolicy(100, 100)), Map.of("mail", "basic"), "basic", Map.of("mail", XSObject.class.getSimpleName())));
}
use of org.apereo.cas.ticket.expiration.TicketGrantingTicketExpirationPolicy in project cas by apereo.
the class BaseTicketRegistryTests method verifyDeleteExpiredTicketById.
@RepeatedTest(2)
public void verifyDeleteExpiredTicketById() throws Exception {
val expirationPolicy = new TicketGrantingTicketExpirationPolicy(42, 23);
val ticketGrantingTicket = new TicketGrantingTicketImpl(ticketGrantingTicketId, CoreAuthenticationTestUtils.getAuthentication(), expirationPolicy);
expirationPolicy.setClock(Clock.fixed(ticketGrantingTicket.getCreationTime().toInstant(), ZoneOffset.UTC));
assertFalse(ticketGrantingTicket.isExpired());
getNewTicketRegistry().addTicket(ticketGrantingTicket);
ticketGrantingTicket.markTicketExpired();
assertTrue(ticketGrantingTicket.isExpired());
val deletedTicketCount = getNewTicketRegistry().deleteTicket(ticketGrantingTicket.getId());
assertTrue(deletedTicketCount <= 1);
}
use of org.apereo.cas.ticket.expiration.TicketGrantingTicketExpirationPolicy in project cas by apereo.
the class TicketGrantingTicketExpirationPolicyBuilder method toTicketGrantingTicketExpirationPolicy.
/**
* To ticket-granting ticket expiration policy.
*
* @return the expiration policy
*/
protected ExpirationPolicy toTicketGrantingTicketExpirationPolicy() {
val tgt = casProperties.getTicket().getTgt();
if (tgt.getPrimary().getMaxTimeToLiveInSeconds() <= 0 && tgt.getPrimary().getTimeToKillInSeconds() <= 0) {
LOGGER.warn("Ticket-granting ticket expiration policy is set to NEVER expire tickets.");
return NeverExpiresExpirationPolicy.INSTANCE;
}
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.getThrottledTimeout().getTimeInBetweenUsesInSeconds() > 0 && tgt.getThrottledTimeout().getTimeToKillInSeconds() > 0) {
val 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());
}
if (tgt.getPrimary().getMaxTimeToLiveInSeconds() > 0 && tgt.getPrimary().getTimeToKillInSeconds() > 0) {
LOGGER.debug("Ticket-granting ticket expiration policy is based on hard/idle timeouts of [{}]/[{}] seconds", tgt.getPrimary().getMaxTimeToLiveInSeconds(), tgt.getPrimary().getTimeToKillInSeconds());
return new TicketGrantingTicketExpirationPolicy(tgt.getPrimary().getMaxTimeToLiveInSeconds(), tgt.getPrimary().getTimeToKillInSeconds());
}
LOGGER.warn("Ticket-granting ticket expiration policy is set to ALWAYS expire tickets.");
return new AlwaysExpiresExpirationPolicy();
}
use of org.apereo.cas.ticket.expiration.TicketGrantingTicketExpirationPolicy in project cas by apereo.
the class TicketGrantingTicketExpirationPolicyBuilderTests method verifyDefault.
@Test
public void verifyDefault() {
val props = new CasConfigurationProperties();
props.getTicket().getTgt().getPrimary().setMaxTimeToLiveInSeconds(10);
props.getTicket().getTgt().getPrimary().setTimeToKillInSeconds(10);
val builder = new TicketGrantingTicketExpirationPolicyBuilder(props);
assertTrue(builder.buildTicketExpirationPolicy() instanceof TicketGrantingTicketExpirationPolicy);
}
Aggregations