Search in sources :

Example 1 with DefaultSecurityTokenTicketFactory

use of org.apereo.cas.ticket.DefaultSecurityTokenTicketFactory in project cas by apereo.

the class JpaTicketRegistryTests method verifySecurityTokenTicket.

@RepeatedTest(2)
public void verifySecurityTokenTicket() throws Exception {
    val securityTokenTicketFactory = new DefaultSecurityTokenTicketFactory(new DefaultUniqueTicketIdGenerator(), neverExpiresExpirationPolicyBuilder());
    val originalAuthn = CoreAuthenticationTestUtils.getAuthentication();
    val tgt = new TicketGrantingTicketImpl(ticketGrantingTicketId, originalAuthn, NeverExpiresExpirationPolicy.INSTANCE);
    this.newTicketRegistry.addTicket(tgt);
    val token = securityTokenTicketFactory.create(tgt, "dummy-token".getBytes(StandardCharsets.UTF_8));
    this.newTicketRegistry.addTicket(token);
    assertNotNull(this.newTicketRegistry.getTicket(token.getId()));
    this.newTicketRegistry.deleteTicket(token);
    assertNull(this.newTicketRegistry.getTicket(token.getId()));
}
Also used : lombok.val(lombok.val) DefaultSecurityTokenTicketFactory(org.apereo.cas.ticket.DefaultSecurityTokenTicketFactory) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) DefaultUniqueTicketIdGenerator(org.apereo.cas.util.DefaultUniqueTicketIdGenerator) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Aggregations

lombok.val (lombok.val)1 DefaultSecurityTokenTicketFactory (org.apereo.cas.ticket.DefaultSecurityTokenTicketFactory)1 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)1 DefaultUniqueTicketIdGenerator (org.apereo.cas.util.DefaultUniqueTicketIdGenerator)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1