Search in sources :

Example 1 with TransientSessionTicketImpl

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

the class DelegatedClientJacksonModuleTests method verifyOperation.

@Test
@SuppressWarnings("JavaUtilDate")
public void verifyOperation() throws Exception {
    val mapper = SERIALIZER.getObjectMapper();
    assertTrue(mapper.getRegisteredModuleIds().contains(DelegatedClientJacksonModule.class.getName()));
    val jwt = new PlainJWT(new JWTClaimsSet.Builder().audience("audience").subject("subject").expirationTime(new Date()).issueTime(new Date()).claim("first_name", "name").build());
    val oidcProfile = new OidcProfile();
    oidcProfile.setId("id");
    oidcProfile.setIdTokenString(jwt.serialize());
    val ticket = new TransientSessionTicketImpl(UUID.randomUUID().toString(), NeverExpiresExpirationPolicy.INSTANCE, RegisteredServiceTestUtils.getService(), Map.of("profiles", oidcProfile));
    val content = mapper.writeValueAsString(ticket);
    assertNotNull(mapper.readValue(content, TransientSessionTicket.class));
}
Also used : lombok.val(lombok.val) TransientSessionTicket(org.apereo.cas.ticket.TransientSessionTicket) PlainJWT(com.nimbusds.jwt.PlainJWT) JWTClaimsSet(com.nimbusds.jwt.JWTClaimsSet) OidcProfile(org.pac4j.oidc.profile.OidcProfile) TransientSessionTicketImpl(org.apereo.cas.ticket.TransientSessionTicketImpl) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 2 with TransientSessionTicketImpl

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

the class DefaultTransientSessionTicketFactory method create.

/**
 * Create delegated authentication request ticket.
 *
 * @param service    the service
 * @param properties the properties
 * @return the delegated authentication request ticket
 */
@Override
public TransientSessionTicket create(final Service service, final Map<String, Serializable> properties) {
    val id = ticketIdGenerator.getNewTicketId(TransientSessionTicket.PREFIX);
    val expirationPolicy = TransientSessionTicketFactory.buildExpirationPolicy(this.expirationPolicyBuilder, properties);
    return new TransientSessionTicketImpl(id, expirationPolicy, service, properties);
}
Also used : lombok.val(lombok.val) TransientSessionTicketImpl(org.apereo.cas.ticket.TransientSessionTicketImpl)

Example 3 with TransientSessionTicketImpl

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

the class BaseTicketRegistryTests method verifyTransientSessionTickets.

@RepeatedTest(2)
public void verifyTransientSessionTickets() throws Exception {
    ticketRegistry.addTicket(new TransientSessionTicketImpl(transientSessionTicketId, NeverExpiresExpirationPolicy.INSTANCE, RegisteredServiceTestUtils.getService(), CollectionUtils.wrap("key", "value")));
    assertSame(1, ticketRegistry.deleteTicket(transientSessionTicketId), () -> "Wrong ticket count. useEncryption[" + useEncryption + ']');
    assertNull(ticketRegistry.getTicket(transientSessionTicketId), () -> TICKET_SHOULD_BE_NULL_USE_ENCRYPTION + useEncryption + ']');
}
Also used : TransientSessionTicketImpl(org.apereo.cas.ticket.TransientSessionTicketImpl) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Aggregations

TransientSessionTicketImpl (org.apereo.cas.ticket.TransientSessionTicketImpl)3 lombok.val (lombok.val)2 JWTClaimsSet (com.nimbusds.jwt.JWTClaimsSet)1 PlainJWT (com.nimbusds.jwt.PlainJWT)1 Date (java.util.Date)1 TransientSessionTicket (org.apereo.cas.ticket.TransientSessionTicket)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1 Test (org.junit.jupiter.api.Test)1 OidcProfile (org.pac4j.oidc.profile.OidcProfile)1