• Shiro框架--将Shrio的session改成HTTPSession数据


    重写 FormAuthenticationFilter类 的 onLoginSuccess()方法即可

    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpSession;
    
    import org.apache.shiro.authc.AuthenticationToken;
    import org.apache.shiro.subject.Subject;
    import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
    
    public class ShiroFormAuthenticationFilter extends FormAuthenticationFilter {
    
        @Override
        protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request,
                ServletResponse response) throws Exception {
            //获取身份里面的用户信息
            Object user = subject.getPrincipal();
            HttpServletRequest httpServletRequest = (HttpServletRequest) request;
            HttpSession session = httpServletRequest.getSession();    
            session.setAttribute("user", user);
            
            return super.onLoginSuccess(token, subject, httpServletRequest, response);
        }
    
    }
  • 相关阅读:
    MySQL严格模式总结
    python筛选关键字---error
    将pem证书转换成p12格式证书
    ## 游戏网关源码赏析
    pid获取
    顺序io_磁盘队列
    nsq源码阅读3_编译nsqd
    nsq源码阅读2_核心数据结构
    nsq源码阅读1_目录结构
    如何设计Mqtt的Retain?
  • 原文地址:https://www.cnblogs.com/vieta/p/11155420.html
Copyright © 2020-2023  润新知