菜鸟日志20170502

任务:老系统servlet到Spring MVC框架的改造
遇到的问题:
1.Spring的security机制控制提示403
问题解析:
错误现象描述:
登录系统后访问子菜单(以子菜单为例改造)提示403,但是从断点debug来看,请求URL正确拿到。

排查思路:
排除法:
1、.do请求经由dispatch分发,spring Security拦截检查.do请求。
2、采用dispatch分发以其他后缀结尾的请求,可以完成分发,故可以定位问题在于spring security模块;
3、
排查applicationContext-security.xml

过程:
1.在applicationContext-security.xml查找URL权限过滤器
org.springframework.security.web.access.intercept.FilterSecurityInterceptor
2. FilterSecurityInterceptor extends AbstractSecurityInterceptor
Debug
Authentication authenticated = authenticateIfRequired();
发现authenticated 之中提示Not granted any authorities
3.进入authenticateIfRequired()查看发现该方法中调用
Authentication authentication =SecurityContextHolder.getContext().getAuthentication();
发现authenticated 之中提示Not granted any authorities
4.分析在哪赋予authentication 的值?
5.发现登录的时候有涉及到这个值得处理
UserDetails user = (UserDetails) SecurityContextHolder.getContext()
.getAuthentication()
.getPrincipal();
ShUser operateUser = (ShUser) this.getPrincipal();
6.进入ShUser.java(implements Serializable ,UserDetails)查看
7.发现对authentication 的处理为null
public Collection

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值