use of org.apereo.cas.logout.slo.SingleLogoutRequestContext in project cas by apereo.
the class DefaultLogoutManager method performLogoutForTicket.
private List<SingleLogoutRequestContext> performLogoutForTicket(final SingleLogoutExecutionRequest context) {
val ticketToBeLoggedOut = context.getTicketGrantingTicket();
val streamServices = Stream.concat(Stream.of(ticketToBeLoggedOut.getServices()), Stream.of(ticketToBeLoggedOut.getProxyGrantingTickets()));
val logoutServices = streamServices.map(Map::entrySet).flatMap(Set::stream).filter(entry -> entry.getValue() instanceof WebApplicationService).filter(Objects::nonNull).map(entry -> Pair.of(entry.getKey(), (WebApplicationService) entry.getValue())).collect(Collectors.toList());
val sloHandlers = logoutExecutionPlan.getSingleLogoutServiceMessageHandlers();
return logoutServices.stream().map(entry -> sloHandlers.stream().sorted(Comparator.comparing(SingleLogoutServiceMessageHandler::getOrder)).filter(handler -> handler.supports(context, entry.getValue())).map(handler -> {
val service = entry.getValue();
LOGGER.trace("Handling single logout callback for [{}]", service.getId());
return handler.handle(service, entry.getKey(), context);
}).flatMap(Collection::stream).filter(Objects::nonNull).collect(Collectors.toList())).flatMap(Collection::stream).filter(distinctByKey(SingleLogoutRequestContext::getService)).collect(Collectors.toList());
}
use of org.apereo.cas.logout.slo.SingleLogoutRequestContext in project cas by apereo.
the class FrontChannelLogoutAction method doInternalExecute.
@Override
protected Event doInternalExecute(final HttpServletRequest request, final HttpServletResponse response, final RequestContext context) {
val logoutRequests = WebUtils.getLogoutRequests(context);
if (logoutRequests == null || logoutRequests.isEmpty()) {
return getFinishLogoutEvent();
}
if (casProperties.getSlo().isDisabled()) {
LOGGER.debug("Single logout callbacks are disabled");
return getFinishLogoutEvent();
}
val logoutUrls = new HashMap<SingleLogoutRequestContext, LogoutHttpMessage>();
logoutRequests.stream().filter(r -> r.getStatus() == LogoutRequestStatus.NOT_ATTEMPTED).forEach(r -> {
LOGGER.debug("Using logout url [{}] for front-channel logout requests", r.getLogoutUrl().toExternalForm());
logoutExecutionPlan.getSingleLogoutServiceMessageHandlers().stream().sorted(Comparator.comparing(SingleLogoutServiceMessageHandler::getOrder)).filter(handler -> handler.supports(r.getExecutionRequest(), r.getService())).forEach(handler -> {
val logoutMessage = handler.createSingleLogoutMessage(r);
LOGGER.debug("Front-channel logout message to send to [{}] is [{}]", r.getLogoutUrl(), logoutMessage);
val msg = new LogoutHttpMessage(r.getLogoutUrl(), logoutMessage.getPayload(), true);
logoutUrls.put(r, msg);
r.setStatus(LogoutRequestStatus.SUCCESS);
r.getService().setLoggedOutAlready(true);
});
});
if (!logoutUrls.isEmpty()) {
WebUtils.putLogoutUrls(context, logoutUrls);
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_PROPAGATE);
}
return getFinishLogoutEvent();
}
Aggregations