/** 认证回调函数,登录时调用. */ @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AccountException { Subject currentUser = SecurityUtils.getSubject(); currentUser.getSession(); System.out.println("============" + this.getAuthenticationCacheName()); System.out.println("============" + this.getAuthorizationCacheName()); UsernamePasswordToken token = (UsernamePasswordToken) authcToken; ShiroUser user = null; try { user = shiroUserService.findUserByLoginName(token.getUsername()); } catch (Exception e) { e.printStackTrace(); } if (user != null) { if (!user.isEnabled()) { throw new DisabledAccountException(); } byte[] salt = EncodeUtils.hexDecode(user.getSalt()); return new SimpleAuthenticationInfo( user, user.getPassword(), ByteSource.Util.bytes(salt), getName()); } else { return null; } }