use of org.apereo.cas.logout.LogoutRequest in project cas by apereo.
the class LogoutActionTests method verifyLogoutRequestBack.
@Test
public void verifyLogoutRequestBack() throws Exception {
final Cookie cookie = new Cookie(COOKIE_TGC_ID, "test");
this.request.setCookies(cookie);
final LogoutRequest logoutRequest = new DefaultLogoutRequest(StringUtils.EMPTY, null, null);
logoutRequest.setStatus(LogoutRequestStatus.SUCCESS);
WebUtils.putLogoutRequests(this.requestContext, Arrays.asList(logoutRequest));
final LogoutProperties properties = new LogoutProperties();
this.logoutAction = new LogoutAction(getWebApplicationServiceFactory(), this.serviceManager, properties);
final Event event = this.logoutAction.doExecute(this.requestContext);
assertEquals(CasWebflowConstants.TRANSITION_ID_FINISH, event.getId());
}
use of org.apereo.cas.logout.LogoutRequest in project cas by apereo.
the class LogoutActionTests method verifyLogoutRequestFront.
@SuppressWarnings("unchecked")
@Test
public void verifyLogoutRequestFront() throws Exception {
final Cookie cookie = new Cookie(COOKIE_TGC_ID, "test");
this.request.setCookies(cookie);
final LogoutRequest logoutRequest = new DefaultLogoutRequest(StringUtils.EMPTY, null, null);
WebUtils.putLogoutRequests(this.requestContext, Arrays.asList(logoutRequest));
final LogoutProperties properties = new LogoutProperties();
this.logoutAction = new LogoutAction(getWebApplicationServiceFactory(), this.serviceManager, properties);
final Event event = this.logoutAction.doExecute(this.requestContext);
assertEquals(CasWebflowConstants.TRANSITION_ID_FRONT, event.getId());
final List<LogoutRequest> logoutRequests = WebUtils.getLogoutRequests(this.requestContext);
assertEquals(1, logoutRequests.size());
assertEquals(logoutRequest, logoutRequests.get(0));
}
use of org.apereo.cas.logout.LogoutRequest in project cas by apereo.
the class TerminateSessionAction method terminate.
/**
* Terminates the CAS SSO session by destroying the TGT (if any) and removing cookies related to the SSO session.
*
* @param context Request context.
* @return "success"
*/
public Event terminate(final RequestContext context) {
// in login's webflow : we can get the value from context as it has already been stored
try {
final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
final HttpServletResponse response = WebUtils.getHttpServletResponse(context);
String tgtId = WebUtils.getTicketGrantingTicketId(context);
// for logout, we need to get the cookie's value
if (tgtId == null) {
tgtId = this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request);
}
if (tgtId != null) {
LOGGER.debug("Destroying SSO session linked to ticket-granting ticket [{}]", tgtId);
final List<LogoutRequest> logoutRequests = this.centralAuthenticationService.destroyTicketGrantingTicket(tgtId);
WebUtils.putLogoutRequests(context, logoutRequests);
}
LOGGER.debug("Removing CAS cookies");
this.ticketGrantingTicketCookieGenerator.removeCookie(response);
this.warnCookieGenerator.removeCookie(response);
destroyApplicationSession(request, response);
LOGGER.debug("Terminated all CAS sessions successfully.");
return this.eventFactorySupport.success(this);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
use of org.apereo.cas.logout.LogoutRequest in project cas by apereo.
the class TerminateSessionAction method terminate.
/**
* Terminates the CAS SSO session by destroying the TGT (if any) and removing cookies related to the SSO session.
*
* @param context Request context.
* @return "success"
*/
@SneakyThrows
public Event terminate(final RequestContext context) {
final HttpServletRequest request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
final HttpServletResponse response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context);
String tgtId = WebUtils.getTicketGrantingTicketId(context);
// for logout, we need to get the cookie's value
if (tgtId == null) {
tgtId = this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request);
}
if (tgtId != null) {
LOGGER.debug("Destroying SSO session linked to ticket-granting ticket [{}]", tgtId);
final List<LogoutRequest> logoutRequests = this.centralAuthenticationService.destroyTicketGrantingTicket(tgtId);
WebUtils.putLogoutRequests(context, logoutRequests);
}
LOGGER.debug("Removing CAS cookies");
this.ticketGrantingTicketCookieGenerator.removeCookie(response);
this.warnCookieGenerator.removeCookie(response);
destroyApplicationSession(request, response);
LOGGER.debug("Terminated all CAS sessions successfully.");
return this.eventFactorySupport.success(this);
}
Aggregations