`
01jiangwei01
  • 浏览: 533622 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

cas 系统实例 服务端配置(三) 退出到指定页面

    博客分类:
  • cas
阅读更多

CAS退出默认是转向CAS内置的退出页面,在实际应用中需要跳转到自己指定的页面。退出转向决定于org.jasig.cas.web.LogoutController,我们看一下原代码。

 

    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);  
    }  
 

 

 可以看出,当this.followServiceRedirects && service != null时才会跳转到自己指定的view,service应该都比较熟悉了,它是客户传的参数,

指定cas中心转向哪里,但我们仅仅传 service 还是不行的,还需要把 followServiceRedirects属性设为true,下面看看如何修改这个属性

 

修改cas-servlet.xml配置文件中的logoutController,新增属性p:followServiceRedirects="true", 修改后如下:

 

Xml代码  收藏代码
<bean id="logoutController" class="org.jasig.cas.web.LogoutController"  
    p:centralAuthenticationService-ref="centralAuthenticationService"  
    p:logoutView="casLogoutView"  
    p:followServiceRedirects="true"  
    p:warnCookieGenerator-ref="warnCookieGenerator"  
    p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator" />
  客户端应用为:

 

<a href="./sso/logout.jsp?service=http://localhost:8081/casclient4/sso/index.jsp">退出</a><br><br>

 

logout.jsp 的内容是:

<%
String query = request.getQueryString();
request.getSession().invalidate();
response.sendRedirect("http://localhost:8081/casserver/logout?"+query);

%>
分享到:
评论
1 楼 yang190637133 2013-02-28  
  顶顶顶  看看结果是什么

相关推荐

Global site tag (gtag.js) - Google Analytics