📄 logoutcontroller.java
字号:
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.ja-sig.org/products/cas/overview/license/ */package org.jasig.cas.web;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.jasig.cas.CentralAuthenticationService;import org.jasig.cas.util.annotation.NotNull;import org.jasig.cas.web.support.CookieRetrievingCookieGenerator;import org.springframework.web.servlet.ModelAndView;import org.springframework.web.servlet.mvc.AbstractController;import org.springframework.web.servlet.view.RedirectView;/** * Controller to delete ticket granting ticket cookie in order to log out of * single sign on. This controller implements the idea of the ESUP Portail's * Logout patch to allow for redirecting to a url on logout. It also exposes a * log out link to the view via the WebConstants.LOGOUT constant. * * @author Scott Battaglia * @version $Revision: 42503 $ $Date: 2007-09-28 10:43:24 -0400 (Fri, 28 Sep 2007) $ * @since 3.0 */public final class LogoutController extends AbstractController { /** The CORE to which we delegate for all CAS functionality. */ @NotNull private CentralAuthenticationService centralAuthenticationService; /** CookieGenerator for TGT Cookie */ @NotNull private CookieRetrievingCookieGenerator ticketGrantingTicketCookieGenerator; /** CookieGenerator for Warn Cookie */ @NotNull private CookieRetrievingCookieGenerator warnCookieGenerator; /** Logout view name. */ @NotNull private String logoutView; /** * Boolean to determine if we will redirect to any url provided in the * service request parameter. */ private boolean followServiceRedirects; public LogoutController() { setCacheSeconds(0); } protected ModelAndView handleRequestInternal( final HttpServletRequest request, final HttpServletResponse response) throws Exception { final String ticketGrantingTicketId = this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request); final String service = request.getParameter("service"); if (ticketGrantingTicketId != null) { this.centralAuthenticationService .destroyTicketGrantingTicket(ticketGrantingTicketId); this.ticketGrantingTicketCookieGenerator.removeCookie(response); this.warnCookieGenerator.removeCookie(response); } if (this.followServiceRedirects && service != null) { return new ModelAndView(new RedirectView(service)); } return new ModelAndView(this.logoutView); } public void setTicketGrantingTicketCookieGenerator( final CookieRetrievingCookieGenerator ticketGrantingTicketCookieGenerator) { this.ticketGrantingTicketCookieGenerator = ticketGrantingTicketCookieGenerator; } public void setWarnCookieGenerator(final CookieRetrievingCookieGenerator warnCookieGenerator) { this.warnCookieGenerator = warnCookieGenerator; } /** * @param centralAuthenticationService The centralAuthenticationService to * set. */ public void setCentralAuthenticationService( final CentralAuthenticationService centralAuthenticationService) { this.centralAuthenticationService = centralAuthenticationService; } public void setFollowServiceRedirects(final boolean followServiceRedirects) { this.followServiceRedirects = followServiceRedirects; } public void setLogoutView(final String logoutView) { this.logoutView = logoutView; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -