|
@@ -86,7 +86,7 @@ public class ShiroRealm extends AuthorizingRealm {
|
|
* @throws AuthenticationException
|
|
* @throws AuthenticationException
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
|
|
|
|
|
|
+ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) {
|
|
log.debug("===============Shiro身份认证开始============doGetAuthenticationInfo==========");
|
|
log.debug("===============Shiro身份认证开始============doGetAuthenticationInfo==========");
|
|
String token = (String) auth.getCredentials();
|
|
String token = (String) auth.getCredentials();
|
|
if (token == null) {
|
|
if (token == null) {
|
|
@@ -103,7 +103,7 @@ public class ShiroRealm extends AuthorizingRealm {
|
|
*
|
|
*
|
|
* @param token
|
|
* @param token
|
|
*/
|
|
*/
|
|
- public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException {
|
|
|
|
|
|
+ public LoginUser checkUserTokenIsEffect(String token){
|
|
// 解密获得username,用于和数据库进行对比
|
|
// 解密获得username,用于和数据库进行对比
|
|
String username = JwtUtil.getUsername(token);
|
|
String username = JwtUtil.getUsername(token);
|
|
if (username == null) {
|
|
if (username == null) {
|
|
@@ -114,15 +114,15 @@ public class ShiroRealm extends AuthorizingRealm {
|
|
log.debug("———校验token是否有效————checkUserTokenIsEffect——————— "+ token);
|
|
log.debug("———校验token是否有效————checkUserTokenIsEffect——————— "+ token);
|
|
LoginUser loginUser = commonAPI.getUserByName(username);
|
|
LoginUser loginUser = commonAPI.getUserByName(username);
|
|
if (loginUser == null) {
|
|
if (loginUser == null) {
|
|
- throw new AuthenticationException("用户不存在!");
|
|
|
|
|
|
+ log.info("用户不存在!");
|
|
}
|
|
}
|
|
// 判断用户状态
|
|
// 判断用户状态
|
|
if (loginUser.getStatus() != 1) {
|
|
if (loginUser.getStatus() != 1) {
|
|
- throw new AuthenticationException("账号已被锁定,请联系管理员!");
|
|
|
|
|
|
+ log.info("账号已被锁定,请联系管理员!");
|
|
}
|
|
}
|
|
// 校验token是否超时失效 & 或者账号密码是否错误
|
|
// 校验token是否超时失效 & 或者账号密码是否错误
|
|
if (!jwtTokenRefresh(token, username, loginUser.getPassword())) {
|
|
if (!jwtTokenRefresh(token, username, loginUser.getPassword())) {
|
|
- throw new AuthenticationException("Token失效,请重新登录!");
|
|
|
|
|
|
+ log.info("Token失效,请重新登录!");
|
|
}
|
|
}
|
|
|
|
|
|
return loginUser;
|
|
return loginUser;
|