JSON在线解析

提问人:SOJSON用户 提问日期:2018-04-03 09:03 热度:12699
问题标签 shiro exception

错误如下:

 threw exception [Request processing failed; nested exception is org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token [org.apache.shiro.authc.UsernamePasswordToken - admin, rememberMe=true] did not match the expected credentials.] with root cause
org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token [org.apache.shiro.authc.UsernamePasswordToken - admin, rememberMe=true] did not match the expected credentials.
at org.apache.shiro.realm.AuthenticatingRealm.assertCredentialsMatch(AuthenticatingRealm.java:600)
at org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:578)
at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:180)
at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:267)
at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198)
at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106)
at org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:270)
at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:256)
at com.sk.main.controller.LoginController.login(LoginController.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)


1条回答 我来回答
soゝso| 2018-04-03 09:08

这是shiro返回的密码校验结果不一样,要么你把shiro校验的令牌规则重写,就是按什么方式去校验。

要么你自己把密码加密好传给shiro。


白话文讲:

当你登陆的时候,你会创建一个UsernamePasswordToken对象,或者UsernamePasswordToken的子类对象,并且赋予账号、密码、rememberMe,这里的密码你需要和数据库一直,比如你做了md5加密,那么你先做md5加密然后再创建UsernamePasswordToken对象.

然后你在校验完毕后:

return new SimpleAuthenticationInfo(token,memberSecurity.getLoginPswd(), getName());

这里的第二个参数为密码,shiro会把第二个参数和你开始传进来的参数按规则对比,如果错误(或者是同一个引用对象)就返回上面的错误。