java - Custom DaoAuthenticationProvider doesn't send correct exception to custom AuthenticationFailureHandler -


in application, use spring security, , try customize it...

i have custum daoauthenticationprovider :

@component("authenticationprovider") public class limitloginauthenticationprovider extends daoauthenticationprovider {     ...     @override     public authentication authenticate(authentication pauthentication)             throws authenticationexception {         if (stringutils.isblank(pauthentication.getname())) {             throw new usernamenotfoundexception("login required");         }         if (stringutils.isblank(pauthentication.getcredentials().tostring())) {             throw new authenticationcredentialsnotfoundexception(                     "password required");         }         ...     } } 

and custum authenticationfailurehandler :

@component("authenticationfailurehandler") public class myauthenticationfailurehandler implements         authenticationfailurehandler {     @override     public void onauthenticationfailure(httpservletrequest prequest,             httpservletresponse presponse,             authenticationexception pauthenticationexception)             throws ioexception, servletexception {         pauthenticationexception.getmessage(); // -> bad credentials     } } 

my problem when submit form without login or with login no password, message "bad credentials" (from badcredentialsexception) , not custom message. why ?

ps : exceptions corerctly throw in custom daoauthenticationprovider.

it's @tobad357 said before, must set sethideusernotfoundexceptions false in authenticate() method of limitloginauthenticationprovider.class.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -