/**
 * <p>Copyright:Copyright(c) 2017</p>
 * <p>Company:上海中信信息发展股份有限公司</p>
 * <p>包名:com.cesgroup.cesmonitor.web</p>
 * <p>文件名:RedirectFormAuthenticationFilter.java</p>
 * <p>创建时间:2017年8月22日 下午5:53:06</p>
 * <p>作者:zhang.erwei</p>
 */

package com.cesgroup.cesmonitor.web;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.util.WebUtils;

import com.cesgroup.framework.jcaptcha.shiro.JCaptchaFormAuthenticationFilter;

/**
 *
 * @author zhang.erwei
 * @version 1.0.0 2017年8月22日
 */
public class RedirectFormAuthenticationFilter extends JCaptchaFormAuthenticationFilter {

    @Override
    protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request,
        ServletResponse response) throws Exception {
        HttpServletRequest req = (HttpServletRequest) request;
        String forwardUrl = request.getParameter("forwardUrl");

        if (forwardUrl != null) {
            req.getSession().setAttribute("forwardUrl", forwardUrl);

        }
        WebUtils.issueRedirect(request, response, "/index.jsp");
        return false;
        //return super.onLoginSuccess(token, subject, request, response);
    }

}
