Shiro异常java.lang.IllegalArgumentException: Odd number of characters的解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Pruett/article/details/83900643
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]

原因很简单,就是你从数据库中查出来的数据不是密文的,
在realm文件中,身份验证最后一句话一般这么写,这里传入的第二个参数password必须是密文的,是你使用的加密方式的密文 , 比如 mD5 ,sha256等

return new SimpleAuthenticationInfo(token.getPrincipal(), password, salt, getName());

猜你喜欢

转载自blog.csdn.net/Pruett/article/details/83900643