CAS Client获取ticket

       

        因为ticket只有第一次从cas server跳转过来后地址栏携带ticket参数,后被 cas client 去掉了,所以加一个优先级高于CAS filter的 filter 来获取ticket.

 


        FetchCasTicketFilter
        com.xindun.cims.filter.FetchCasTicketFilter
    
  
        FetchCasTicketFilter
        /*
  

 

package com.xindun.cims.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;



public class FetchCasTicketFilter implements Filter {


 
 
 @Override
 public void destroy() {
  // TODO Auto-generated method stub

 }

 @Override
 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
   throws IOException, ServletException {
  HttpServletRequest request = (HttpServletRequest) req;
  String queryString = request.getQueryString();
  if(queryString != null && queryString.contains("ticket")){
   request.getSession().setAttribute("ticket_", queryString.substring(queryString.indexOf("=") + 1));
  }
  chain.doFilter(req, res);
 }

 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
  
 }
 

 
}

 

你可能感兴趣的:(cas)