现在部署了CAS,有一个应用,下载输入应用的URL可以正确跳转到CAS服务的登陆界面,登陆验证通过后页面却跳转到了应用的登陆界面,不能直接进入登陆成功的主页面!
应用的web.xml如下
应用的web.xml如下
<!-- 用于单点登录 --> <filter> <filter-name>CASFilter</filter-name> <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class> <init-param> <param-name>casServerLoginUrl</param-name> <param-value>https://TP_1010000110011000:8443/cas/login</param-value> </init-param> <init-param> <param-name>serverName</param-name> <param-value>http://localhost:8080</param-value> </init-param> </filter> <filter-mapping> <filter-name>CASFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 该过滤器负责Ticket的校验工作 --> <filter> <filter-name>CAS Validation Filter</filter-name> <filter-class> org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class> <init-param> <param-name>casServerUrlPrefix</param-name> <param-value>https://TP_1010000110011000:8443/cas</param-value> </init-param> <init-param> <param-name>serverName</param-name> <param-value>http://localhost:8080</param-value> </init-param> </filter> <filter-mapping> <filter-name>CAS Validation Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 该过滤器负责实现HttpServletRequest请求的包裹 --> <filter> <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name> <filter-class> org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class> </filter> <filter-mapping> <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!--自定义cas设置user过滤器--> <filter> <display-name>AutoSetUserAdapterFilter</display-name> <filter-name>AutoSetUserAdapterFilter</filter-name> <filter-class>com.cdt.cas.client.casClientFilter</filter-class> </filter> <filter-mapping> <filter-name>AutoSetUserAdapterFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
casClientFilter的代码如下:
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { Date startTime = new Date(); System.out.println("CasClient开始时间"+startTime.getTime()); final HttpServletRequest request = (HttpServletRequest) servletRequest; final HttpServletResponse response = (HttpServletResponse) servletResponse; final HttpSession session = request.getSession(false); final Assertion assertion = (Assertion) (session == null ? request .getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION) : session .getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION)); String username = assertion == null ? null : assertion.getPrincipal().getName(); //_const_cas_assertion_是CAS中存放登录用户名的session标志 Object object = request.getSession().getAttribute("_const_cas_assertion_"); String url = request.getRequestURL().toString(); if(object != null && username != null) { //存放用户类型 session.setAttribute("userType", "2"); //设置cookie Cookie cookie = new Cookie("username",username); int maxAge = 60*60*24*365; //cookie存活时间1年 cookie.setMaxAge(maxAge); response.addCookie(cookie); } if (chain != null) { chain.doFilter(request, response); } Date endTime = new Date(); System.out.println("CasClient结束时间"+endTime.getTime()); }
讨教各位高手!这个到底怎么弄啊!现在一直跳转到登陆页面!没有进入到登陆成功的页面啊!
解决方案:30分
是不是跳转的url不正确 或新页面所在的项目没启动