use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy 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();
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class DistributedTicketRegistryTests method verifyUpdateOfRegistry.
@Test
public void verifyUpdateOfRegistry() throws AbstractTicketException {
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(t);
final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket(TGT_ID);
final ServiceTicket s = returned.grantServiceTicket("test2", RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
this.ticketRegistry.addTicket(s);
final ServiceTicket s2 = (ServiceTicket) this.ticketRegistry.getTicket("test2");
assertNotNull(s2.grantProxyGrantingTicket("ff", CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
assertTrue(s2.isValidFor(RegisteredServiceTestUtils.getService()));
assertTrue(this.wasTicketUpdated);
returned.markTicketExpired();
assertTrue(t.isExpired());
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class DistributedTicketRegistryTests method verifyDeleteTicketWithPGT.
@Test
public void verifyDeleteTicketWithPGT() {
final Authentication a = CoreAuthenticationTestUtils.getAuthentication();
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TGT_NAME, a, new NeverExpiresExpirationPolicy()));
final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class);
final Service service = CoreAuthenticationTestUtils.getService("TGT_DELETE_TEST");
final ServiceTicket st1 = tgt.grantServiceTicket("ST1", service, new NeverExpiresExpirationPolicy(), true, true);
this.ticketRegistry.addTicket(st1);
assertNotNull(this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
final ProxyGrantingTicket pgt = st1.grantProxyGrantingTicket("PGT-1", a, new NeverExpiresExpirationPolicy());
assertEquals(a, pgt.getAuthentication());
this.ticketRegistry.addTicket(pgt);
assertSame(3, this.ticketRegistry.deleteTicket(tgt.getId()));
assertNull(this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class));
assertNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
assertNull(this.ticketRegistry.getTicket("PGT-1", ProxyGrantingTicket.class));
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class TicketGrantingTicketImplTests method verifyDoubleGrantSameServiceTicketKeepAll.
@Test
public void verifyDoubleGrantSameServiceTicketKeepAll() {
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, false);
assertEquals(2, t.getServices().size());
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class TicketGrantingTicketImplTests method verifyDoubleGrantDifferentServiceTicket.
@Test
public void verifyDoubleGrantDifferentServiceTicket() {
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService2(), new NeverExpiresExpirationPolicy(), false, true);
assertEquals(2, t.getServices().size());
}
Aggregations