use of org.apereo.cas.support.events.ticket.CasTicketGrantingTicketDestroyedEvent 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...");
AuthenticationCredentialsThreadLocalBinder.bindCurrent(ticket.getAuthentication());
final List<LogoutRequest> logoutRequests = this.logoutManager.performLogout(ticket);
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 new ArrayList<>(0);
}
use of org.apereo.cas.support.events.ticket.CasTicketGrantingTicketDestroyedEvent in project cas by apereo.
the class DefaultSingleLogoutRequestExecutor method execute.
@Override
public List<SingleLogoutRequestContext> execute(final String ticketId, final HttpServletRequest request, final HttpServletResponse response) {
val ca = AuthenticationCredentialsThreadLocalBinder.getCurrentAuthentication();
try {
val ticket = centralAuthenticationService.getTicket(ticketId, Ticket.class);
LOGGER.debug("Ticket [{}] found. Processing logout requests and then deleting the ticket...", ticket.getId());
val logoutRequests = new ArrayList<SingleLogoutRequestContext>();
if (ticket instanceof TicketGrantingTicket) {
val tgt = (TicketGrantingTicket) ticket;
AuthenticationCredentialsThreadLocalBinder.bindCurrent(tgt.getAuthentication());
logoutRequests.addAll(logoutManager.performLogout(SingleLogoutExecutionRequest.builder().ticketGrantingTicket(tgt).httpServletRequest(Optional.of(request)).httpServletResponse(Optional.of(response)).build()));
applicationContext.publishEvent(new CasTicketGrantingTicketDestroyedEvent(this, tgt));
}
LOGGER.trace("Removing ticket [{}] from registry...", ticketId);
centralAuthenticationService.deleteTicket(ticketId);
return logoutRequests;
} catch (final Exception e) {
val msg = String.format("Ticket-granting ticket [%s] cannot be found in the ticket registry.", ticketId);
LOGGER.debug(msg, e);
} finally {
AuthenticationCredentialsThreadLocalBinder.bindCurrent(ca);
}
return new ArrayList<>(0);
}
use of org.apereo.cas.support.events.ticket.CasTicketGrantingTicketDestroyedEvent in project cas by apereo.
the class CasAuthenticationEventListenerTests method verifyCasTicketGrantingTicketDestroyed.
@Test
public void verifyCasTicketGrantingTicketDestroyed() {
val event = new CasTicketGrantingTicketDestroyedEvent(this, new MockTicketGrantingTicket("casuser"));
applicationContext.publishEvent(event);
assertFalse(casEventRepository.load().findAny().isEmpty());
}
Aggregations