拦截器强制session过期
来源:互联网 发布:细说php第二版答案 编辑:程序博客网 时间:2024/05/16 18:31
package com.paxsz.tms.admin.web.interceptor;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Qualifier;import org.springframework.security.core.context.SecurityContextHolder;import org.springframework.web.method.HandlerMethod;import org.springframework.web.servlet.HandlerInterceptor;import org.springframework.web.servlet.ModelAndView;import com.paxsz.common.exception.BusinessException;import com.paxsz.server.AppException;import com.paxsz.tms.admin.model.PubUser;import com.paxsz.tms.admin.service.UserService;import com.paxsz.tms.admin.web.util.AdminUtil;public class CheckCurrentUserInterceptor implements HandlerInterceptor {@Autowired@Qualifier("tmsUserService")private UserService userService;static Log log = LogFactory.getLog(CheckCurrentUserInterceptor.class);@Overridepublic boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {if (handler instanceof HandlerMethod) {PubUser currentUser = AdminUtil.getLoginUser();if(currentUser != null){PubUser user = userService.get(currentUser.getId());if(user == null){SecurityContextHolder.getContext().setAuthentication(null);throw new AppException("currentuser.notFound");}if(!String.valueOf(currentUser.getOrganization().getId()).equals(String.valueOf(user.getOrganization().getId()))){SecurityContextHolder.getContext().setAuthentication(null);throw new AppException("currentgroup.changed");}currentUser.setEmail(user.getEmail());currentUser.setFullname(user.getFullname());currentUser.setPhone(user.getPhone());}}return true;}@Overridepublic void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {}@Overridepublic void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {}}
0 0
- 拦截器强制session过期
- ajaxsetup,结合拦截器处理session过期,跳转登录页面
- Java-session过期后,拦截器拦截后页面跳不出iframe框架问题
- shiro 拦截器实现session过期拦截ajax请求的处理
- ajax请求session过期失效被拦截的解决
- Session过期
- session 过期
- Session过期
- session 过期?
- struts2 Session拦截器
- struts2 session拦截器
- OkHttp拦截器解决登录过期问题
- springMVC 拦截器session控制
- springMVC 拦截器session控制
- Spring mvc Session拦截器
- Struts2拦截器获取session
- struts2 ,session失效,拦截器
- Session过期问题
- 第十三周项目1--数组大折腾2
- 客户自谈移民香港的感想和经历
- python中如何判断字符类型
- 数组排序--选择排序
- Centos6.4系统安装
- 拦截器强制session过期
- 如何在github上fork一个项目来贡献代码以及同步原作者的修改
- 智能手环五大主流MEMS传感器盘点
- SQL基础总结2
- CocosStudio UI组件使用大全Cocos2d-x3.2使用
- ANT十五大最佳实践
- 一些常用软件的网络端口协议分类介绍
- kmp算法总结
- 第十三周项目一 数组大折腾(3.输出长度16的整型数组中与3有关的数)