java - Apache Shiro login error: IncorrectCredentialsException -
i keep getting error when attempt login. appreciated.
login code
realm realm = new testrealm(); securitymanager sm = new defaultsecuritymanager(realm); securityutils.setsecuritymanager(sm); usernamepasswordtoken token = new usernamepasswordtoken(); token.setusername("dave"); token.setpassword("le1990".tochararray()); token.setrememberme(true); subject sub = securityutils.getsubject(); sub.login(token);
dogetauthenticationinfo method
protected authenticationinfo dogetauthenticationinfo(authenticationtoken token) throws authenticationexception{ usernamepasswordtoken uptoken = (usernamepasswordtoken)token; string username = uptoken.getusername(); if(username == null) this.logger.info("we don't except null usernames. sorry. "); authenticationinfo info = null; try{ user user = new user(); string pass = user.getpassforuser(); if(pass == null) throw new accountexception("the account looking doesn't exist"); info = new simpleauthenticationinfo(username, pass, getname());
user.getpassforuser method returns hard wired value testing. value copied db $shiro1$sha-256$500000$temcnap0k+zboiw7y49mww==$veym6yl3qicjvmwo0r2yu0kdc3ueaxzoyun0vt+0v5m=
shiro.ini file
# realms used customsecurityrealm=com.raven.rave.common.testrealm customsecurityrealm.jndidatasourcename=java:jdbc/dbeka customsecurityrealm.permissionslookupenabled=true
finally exception thrown
error [stderr] org.apache.shiro.authc.incorrectcredentialsexception: submitted credentials token [org.apache.shiro.authc.usernamepasswordtoken - dave, rememberme=true] did not match expected credent error [stderr] @ org.apache.shiro.realm.authenticatingrealm.assertcredentialsmatch(authenticatingrealm.java:600) error [stderr] @ org.apache.shiro.realm.authenticatingrealm.getauthenticationinfo(authenticatingrealm.java:578) error [stderr] @ org.apache.shiro.authc.pam.modularrealmauthenticator.dosinglerealmauthentication(modularrealmauthenticator.java:180) error [stderr] @ org.apache.shiro.authc.pam.modularrealmauthenticator.doauthenticate(modularrealmauthenticator.java:267) error [stderr] @ org.apache.shiro.authc.abstractauthenticator.authenticate(abstractauthenticator.java:198) error [stderr] @ org.apache.shiro.mgt.authenticatingsecuritymanager.authenticate(authenticatingsecuritymanager.java:106) error [stderr] @ org.apache.shiro.mgt.defaultsecuritymanager.login(defaultsecuritymanager.java:270) error [stderr] @ org.apache.shiro.subject.support.delegatingsubject.login(delegatingsubject.java:256)
when registered user, passed in same password "le1990". also, password retrieved db have in plaintext. if so, how decrypt password stored ?
the problem obvious one, missed.i hadn't set credentialmatcher jdbc realm, on ini file. adding in statement fixed up.
updated shiro.ini file
passwordservice = org.apache.shiro.authc.credential.defaultpasswordservice passwordmatcher = org.apache.shiro.authc.credential.passwordmatcher passwordmatcher.passwordservice = $passwordservice # realms used jdbcrealm=com.raven.rave.common.testrealm jdbcrealm.permissionslookupenabled=true securitymanager.realm = $jdbcrealm #statement fixed jdbcrealm.credentialsmatcher = $passwordmatcher
Comments
Post a Comment