前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Odd number of characters异常

Odd number of characters异常

作者头像
sunonzj
发布2022-06-21 09:20:56
1.8K0
发布2022-06-21 09:20:56
举报
文章被收录于专栏:zjblogzjblog

Java.lang.IllegalArgumentException: Odd number of characters. at org.apache.shiro.codec.Hex.decode(Hex.java:128) ~[shiro-core-1.3.2.jar:1.3.2] at org.apache.shiro.codec.Hex.decode(Hex.java:107) ~[shiro-core-1.3.2.jar:1.3.2] at org.apache.shiro.codec.Hex.decode(Hex.java:95) ~[shiro-core-1.3.2.jar:1.3.2] at org.apache.shiro.authc.credential.HashedCredentialsMatcher.getCredentials(HashedCredentialsMatcher.java:353) ~[shiro-core-1.3.2.jar:1.3.2] at org.apache.shiro.authc.credential.HashedCredentialsMatcher.doCredentialsMatch(HashedCredentialsMatcher.java:380) ~[shiro-core-1.3.2.jar:1.3.2] at org.apache.shiro.realm.AuthenticatingRealm.assertCredentialsMatch(AuthenticatingRealm.java:597) ~[shiro-core-1.3.2.jar:1.3.2]

原因一: 使用shiro登入认证的 return new SimpleAuthenticationInfo(token.getPrincipal(), password, salt, getName()); 传参数的时候password 要使用加密过的。

原因二:后面整合jwt 改成了

代码语言:javascript
复制
return new SimpleAuthenticationInfo(token, token, getName());

需要把这段去掉 不然也会报这个错

代码语言:javascript
复制
/**
     * HashedCredentialsMatcher,这个类是为了对密码进行编码的,
     * 防止密码在数据库里明码保存,当然在登陆认证的时候,
     * 这个类也负责对form里输入的密码进行编码。
     *//*

    @Bean(name = "hashedCredentialsMatcher")
    public HashedCredentialsMatcher hashedCredentialsMatcher() {
        HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher();
        credentialsMatcher.setHashAlgorithmName("MD5");
        credentialsMatcher.setHashIterations(2);
        credentialsMatcher.setStoredCredentialsHexEncoded(true);
        return credentialsMatcher;
    }
*/
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-05-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档