use of org.apereo.cas.ticket.ProxyGrantingTicketIssuerTicket in project cas by apereo.
the class BaseTicketRegistryTests method verifyDeleteTicketWithPGT.
@RepeatedTest(2)
public void verifyDeleteTicketWithPGT() throws Exception {
val a = CoreAuthenticationTestUtils.getAuthentication();
ticketRegistry.addTicket(new TicketGrantingTicketImpl(ticketGrantingTicketId, a, NeverExpiresExpirationPolicy.INSTANCE));
val tgt = ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
val service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
val st1 = (ProxyGrantingTicketIssuerTicket) tgt.grantServiceTicket(serviceTicketId, service, NeverExpiresExpirationPolicy.INSTANCE, false, true);
ticketRegistry.addTicket(st1);
ticketRegistry.updateTicket(tgt);
assertNotNull(ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class));
assertNotNull(ticketRegistry.getTicket(serviceTicketId, ServiceTicket.class));
val pgt = st1.grantProxyGrantingTicket(proxyGrantingTicketId, a, NeverExpiresExpirationPolicy.INSTANCE);
ticketRegistry.addTicket(pgt);
ticketRegistry.updateTicket(tgt);
ticketRegistry.updateTicket(st1);
assertEquals(pgt.getTicketGrantingTicket(), tgt);
assertNotNull(ticketRegistry.getTicket(proxyGrantingTicketId, ProxyGrantingTicket.class));
assertEquals(a, pgt.getAuthentication());
assertNotNull(ticketRegistry.getTicket(serviceTicketId, ServiceTicket.class));
await().untilAsserted(() -> assertTrue(ticketRegistry.deleteTicket(tgt.getId()) > 0));
assertNull(ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class));
assertNull(ticketRegistry.getTicket(serviceTicketId, ServiceTicket.class));
assertNull(ticketRegistry.getTicket(proxyGrantingTicketId, ProxyGrantingTicket.class));
}
use of org.apereo.cas.ticket.ProxyGrantingTicketIssuerTicket in project cas by apereo.
the class BaseTicketRegistryTests method verifyDeleteTicketsWithMultiplePGTs.
@RepeatedTest(2)
public void verifyDeleteTicketsWithMultiplePGTs() throws Exception {
FunctionUtils.doAndRetry(callback -> {
val a = CoreAuthenticationTestUtils.getAuthentication();
ticketRegistry.addTicket(new TicketGrantingTicketImpl(ticketGrantingTicketId, a, NeverExpiresExpirationPolicy.INSTANCE));
val tgt = ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
assertNotNull(tgt, "Ticket-granting ticket must not be null");
val service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
IntStream.range(1, 5).forEach(Unchecked.intConsumer(i -> {
val st = (ProxyGrantingTicketIssuerTicket) tgt.grantServiceTicket(serviceTicketId + '-' + i, service, NeverExpiresExpirationPolicy.INSTANCE, false, true);
ticketRegistry.addTicket(st);
ticketRegistry.updateTicket(tgt);
val pgt = st.grantProxyGrantingTicket(proxyGrantingTicketId + '-' + i, a, NeverExpiresExpirationPolicy.INSTANCE);
ticketRegistry.addTicket(pgt);
ticketRegistry.updateTicket(tgt);
ticketRegistry.updateTicket(st);
}));
val c = ticketRegistry.deleteTicket(ticketGrantingTicketId);
assertEquals(6, c);
return null;
});
}
use of org.apereo.cas.ticket.ProxyGrantingTicketIssuerTicket in project cas by apereo.
the class DefaultProxyGrantingTicketFactory method produceTicket.
/**
* Produce ticket.
*
* @param <T> the type parameter
* @param serviceTicket the service ticket
* @param authentication the authentication
* @param pgtId the pgt id
* @param clazz the clazz
* @return the ticket
*/
protected <T extends ProxyGrantingTicket> T produceTicket(final ServiceTicket serviceTicket, final Authentication authentication, final String pgtId, final Class<T> clazz) {
val proxyGrantingTicketExpirationPolicy = getProxyGrantingTicketExpirationPolicy(serviceTicket);
val pgtIssuer = (ProxyGrantingTicketIssuerTicket) serviceTicket;
val result = produceTicketWithAdequateExpirationPolicy(proxyGrantingTicketExpirationPolicy, pgtIssuer, authentication, pgtId);
if (!clazz.isAssignableFrom(result.getClass())) {
throw new ClassCastException("Result [" + result + " is of type " + result.getClass() + " when we were expecting " + clazz);
}
return (T) result;
}
use of org.apereo.cas.ticket.ProxyGrantingTicketIssuerTicket in project cas by apereo.
the class DistributedTicketRegistryTests method verifyUpdateOfRegistry.
@Test
public void verifyUpdateOfRegistry() throws Exception {
val t = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getAuthentication(), NeverExpiresExpirationPolicy.INSTANCE);
this.ticketRegistry.addTicket(t);
val returned = (TicketGrantingTicket) this.ticketRegistry.getTicket(TGT_ID);
val s = (ProxyGrantingTicketIssuerTicket) returned.grantServiceTicket("test2", RegisteredServiceTestUtils.getService(), NeverExpiresExpirationPolicy.INSTANCE, false, true);
this.ticketRegistry.addTicket(s);
val s2 = (ProxyGrantingTicketIssuerTicket) this.ticketRegistry.getTicket("test2");
assertNotNull(s2.grantProxyGrantingTicket("ff", CoreAuthenticationTestUtils.getAuthentication(), NeverExpiresExpirationPolicy.INSTANCE));
assertTrue(this.wasTicketUpdated);
returned.markTicketExpired();
assertTrue(t.isExpired());
}
use of org.apereo.cas.ticket.ProxyGrantingTicketIssuerTicket in project cas by apereo.
the class DistributedTicketRegistryTests method verifyDeleteTicketWithPGT.
@Test
public void verifyDeleteTicketWithPGT() throws Exception {
val a = CoreAuthenticationTestUtils.getAuthentication();
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TGT_NAME, a, NeverExpiresExpirationPolicy.INSTANCE));
val tgt = this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class);
val service = CoreAuthenticationTestUtils.getService("TGT_DELETE_TEST");
val st1 = (ProxyGrantingTicketIssuerTicket) tgt.grantServiceTicket("ST1", service, NeverExpiresExpirationPolicy.INSTANCE, true, true);
this.ticketRegistry.addTicket(st1);
assertNotNull(this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
val pgt = st1.grantProxyGrantingTicket("PGT-1", a, NeverExpiresExpirationPolicy.INSTANCE);
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));
}
Aggregations