大神帮忙看看shiro认证校验密码输入正确密码也会报密码不正确的错误

developer_feng 2018-07-19 12:05:56
新手学习shiro,程序在输入正确的密码时报的错误如下:



org.apache.shiro.authc.IncorrectCredentialsException ,密码不正确,但是我输入的是正确的密码

哦,数据库密码是做了MD5加密的,如下


密码1234567 MD5加密后为 fcea920f7412b5da7be0cf42b8c93759



这个是盐值

 protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
// token是用户输入的用户名和密码
// 第一步从token中取出用户名
String userCode = (String) token.getPrincipal();
SmbmsUser findUser=null;

try {
findUser= smbmsUser.findUser(userCode);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (findUser==null) {
return null;
}
String userpassword = findUser.getUserpassword();

String salt = findUser.getSalt();

SmbmsUserPO smbmsUserPO = new SmbmsUserPO();
smbmsUserPO.setId(findUser.getId());
smbmsUserPO.setUsercode(findUser.getUsercode());
smbmsUserPO.setUsername(findUser.getUsername());
List<SysPermission> findMenuListByUserId =null;
try {
findMenuListByUserId = sysPermissionService.findMenuListByUserId(String.valueOf(findUser.getId()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//将用户菜单 设置到activeUser
smbmsUserPO.setMenus(findMenuListByUserId);

SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo(smbmsUserPO, userpassword, ByteSource.Util.bytes(salt), this.getName());
return simpleAuthenticationInfo;
}


这个是认证的代码,自定义的realm



这个是shiro.xml中的自定义realm及凭证匹配器的配置

看了前后,不知道为啥密码会校验错误,MD5匹配的问题吗?求大神帮忙看下
...全文
997 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
奔跑的小鱼儿 2018-07-20
  • 打赏
  • 举报
回复
String salt = findUser.getSalt();
你用了盐值加密吧
看一下他写的几篇博客,前后几篇都看完应该就知道问题在哪了
https://blog.csdn.net/acmman/article/details/78585662
developer_feng 2018-07-19
  • 打赏
  • 举报
回复
也没办法看到MD5匹配的过程,都是shiro框架做对比
developer_feng 2018-07-19
  • 打赏
  • 举报
回复
引用 1 楼 welan123123 的回复:
把两个不一样的MD5发出来看看


啥意思
奔跑的小鱼儿 2018-07-19
  • 打赏
  • 举报
回复
把两个不一样的MD5发出来看看

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧