shiro认证流程记录

Subject.login()->委托给securityManager.login(this, token)-> authenticate(token)-> authenticate()->this.authenticator.authenticate(token)-> AbstractAuthenticator.authenticate(token)-> doAuthenticate(token)-> doSingleRealmAuthentication(realms.iterator().next(),-> authenticationToken)-> realm.getAuthenticationInfo(token)-> doGetAuthenticationInfo(token),前面都只是获取AuthenticationToken对象在执行完doGetAuthenticationInfo(token)后,还是在realm.getAuthenticationInfo(token)方法内,执行assertCredentialsMatch(token, info)方法进行token和info(AuthenticationToken的实例)中凭证的对比,对比正确则认证成功,失败则为密码错误。一旦执行assertCredentialsMatch方法则代表账号存在,因为在执行assertCredentialsMatch之前进行了info非空判断,而info实例是通过用户名获取的对象,在通过用户名获取info的时候,如果用户名不存在,则从数据库获取的密码为空,在自定义的realm中直接返回了null,即info对象为空,即不会进行对比认证,同时会打印debug信息,在doSingleRealmAuthentication方法接收到的值为null,此时会抛出UnknownAccountException异常。那么可以认为在realm.getAuthenticationInfo中就执行完了主要的认证匹配的流程。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值