Shiro登录认证流程

登录认证流程

1.获取当前用户

Subject currentUser = SecurityUtils.getSubject();

2.判断用户是否登录

currentUser.isAuthenticate();

3.将用户名密码封装成tonken

UsernamePasswordToken tonken = new UsernamePasswordToken(“username”,“password”);

4.通过捕获执行currentUser.login(tonken)的异常来验证登录

ConcurrentAccessException:并发访问异常(多个用户同时登录时抛出)
UnknownAccountException uae:用户名不存在
IncorrectCredentialsException ice:密码错误
LockedAccountException lae:用户被锁住
ExpiredCredentialsException:凭证过期
ExcessiveAttemptsException:认证次数超过限制
UnsupportedTokenException:使用了不支持的Token

5.currentUser.login(tonken)是调用Realm中的getAuthenticationInfo方法拿到一个AuthenticationInfo对象info,再调用CredentialsMatcher的doCredentialsMatch方法将token(代表了用户输入的那一块)和info(代表了数据库中取出的那一块)进行比对

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_39463716/article/details/86306819