anan7741 2021-09-27 10:57 采纳率: 16.7%
浏览 30

springboot shiro 很奇怪,在密码和计算和库值相等情况下,验证死活不通过

很奇怪,在密码和计算和库值相等情况下,验证死活不通过

  /**
     * description: 主要是用来进行身份认证的,也就是说验证用户输入的账号和密码是否正确。
     *
     * @return 身份验证信息
     */
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException {
        //获取用户的输入的账号.
        ShiroToken token = (ShiroToken) authcToken;


        Admin admin = adminService.selectByMobile(token.getUsername());
        Admin a2=new Admin();
        a2.setPassword(token.getPwd());
        a2.setCreateTime(admin.getCreateTime());
        System.out.println("输入值:"+a2.getPassword());
        System.out.println("计算值:"+passwordUtil.getEncryptPwd(a2.getPassword(),a2.getCreateTime()));
        if (null == admin) {
            throw new UnknownAccountException("账号不存在");
        }
        token.setId(admin.getId());
        AftUser aftUser = admin;
        System.out.println("库 值:"+aftUser.getPassword());
        System.out.println("盐:"+ aftUser.getCreateTime());

        return new SimpleAuthenticationInfo(aftUser, aftUser.getPassword(), passwordUtil.getAftSalt(aftUser),
                getName());
    
    }
输入值:123456
计算值:41b9bf03ac0bb6988f6fc81433658a07
库 值:41b9bf03ac0bb6988f6fc81433658a07
盐:Thu Nov 01 11:13:18 CST 2018

2021/09/27-10:49:14 ERROR [dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token [com.kede.core.shiro.token.ShiroToken - admin, rememberMe=false] did not match the expected credentials.] with root cause
org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token [com.kede.core.shiro.token.ShiroToken - admin, rememberMe=false] did not match the expected credentials.

  • 写回答

2条回答 默认 最新

  • Tomshidi 2021-09-27 11:06
    关注

    不会是用了 == 判断了两个字符串吧

    评论

报告相同问题?

问题事件

  • 请采纳用户回复 1月6日
  • 创建了问题 9月27日