use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class TicketOrCredentialPrincipalResolverTests method verifyResolverTicketGrantingTicket.
@Test
public void verifyResolverTicketGrantingTicket() throws Exception {
final Credential c = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), c);
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket st = getCentralAuthenticationService().grantServiceTicket(ticketId.getId(), CoreAuthenticationTestUtils.getService(), ctx);
final TicketOrCredentialPrincipalResolver res = new TicketOrCredentialPrincipalResolver(getCentralAuthenticationService());
final JoinPoint jp = mock(JoinPoint.class);
when(jp.getArgs()).thenReturn(new Object[] { ticketId.getId() });
final String result = res.resolveFrom(jp, null);
assertNotNull(result);
assertEquals(result, c.getId());
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class LogoutManagerImpl method performLogoutForTicket.
private void performLogoutForTicket(final TicketGrantingTicket ticket, final List<LogoutRequest> logoutRequests) {
ticket.getServices().entrySet().stream().filter(entry -> entry.getValue() instanceof WebApplicationService).forEach(entry -> {
final Service service = entry.getValue();
LOGGER.debug("Handling single logout callback for [{}]", service);
final LogoutRequest logoutRequest = this.singleLogoutServiceMessageHandler.handle((WebApplicationService) service, entry.getKey());
if (logoutRequest != null) {
LOGGER.debug("Captured logout request [{}]", logoutRequest);
logoutRequests.add(logoutRequest);
}
});
final Collection<ProxyGrantingTicket> proxyGrantingTickets = ticket.getProxyGrantingTickets();
if (proxyGrantingTickets.isEmpty()) {
LOGGER.debug("There are no proxy-granting tickets associated with [{}] to process for single logout", ticket.getId());
} else {
proxyGrantingTickets.forEach(proxyGrantingTicket -> performLogoutForTicket(proxyGrantingTicket, logoutRequests));
}
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class Cas10ProxyHandlerTests method verifyCredentialsAndProxy.
@Test
public void verifyCredentialsAndProxy() {
final TicketGrantingTicket proxyGrantingTicket = mock(TicketGrantingTicket.class);
when(proxyGrantingTicket.getId()).thenReturn("proxyGrantingTicket");
assertNull(this.proxyHandler.handle(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(), proxyGrantingTicket));
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class AbstractTicketRegistryTests method verifyDeleteTicketWithChildren.
@Test
public void verifyDeleteTicketWithChildren() {
try {
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX + "1", CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class);
final Service service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
final ServiceTicket st1 = tgt.grantServiceTicket("ST11", service, new NeverExpiresExpirationPolicy(), false, false);
final ServiceTicket st2 = tgt.grantServiceTicket("ST21", service, new NeverExpiresExpirationPolicy(), false, false);
final ServiceTicket st3 = tgt.grantServiceTicket("ST31", service, new NeverExpiresExpirationPolicy(), false, false);
this.ticketRegistry.addTicket(st1);
this.ticketRegistry.addTicket(st2);
this.ticketRegistry.addTicket(st3);
assertNotNull(this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST11", ServiceTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST21", ServiceTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST31", ServiceTicket.class));
this.ticketRegistry.updateTicket(tgt);
assertSame(4, this.ticketRegistry.deleteTicket(tgt.getId()));
assertNull(this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class));
assertNull(this.ticketRegistry.getTicket("ST11", ServiceTicket.class));
assertNull(this.ticketRegistry.getTicket("ST21", ServiceTicket.class));
assertNull(this.ticketRegistry.getTicket("ST31", ServiceTicket.class));
} catch (final Exception e) {
fail(CAUGHT_AN_EXCEPTION_BUT_WAS_NOT_EXPECTED + e.getMessage());
}
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class DefaultCentralAuthenticationService method destroyTicketGrantingTicket.
@Audit(action = "TICKET_GRANTING_TICKET_DESTROYED", actionResolverName = "DESTROY_TICKET_GRANTING_TICKET_RESOLVER", resourceResolverName = "DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER")
@Metered(name = "DESTROY_TICKET_GRANTING_TICKET_METER")
@Counted(name = "DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic = true)
@Override
public List<LogoutRequest> destroyTicketGrantingTicket(final String ticketGrantingTicketId) {
try {
LOGGER.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId);
final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
LOGGER.debug("Ticket found. Processing logout requests and then deleting the ticket...");
AuthenticationCredentialsLocalBinder.bindCurrent(ticket.getAuthentication());
final List<LogoutRequest> logoutRequests = this.logoutManager.performLogout(ticket);
this.ticketRegistry.deleteTicket(ticketGrantingTicketId);
doPublishEvent(new CasTicketGrantingTicketDestroyedEvent(this, ticket));
return logoutRequests;
} catch (final InvalidTicketException e) {
LOGGER.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId);
}
return Collections.emptyList();
}
Aggregations