java - Custom Authentication Provider on Spring Security 2 userDetailsService issue -


i had spring security 2.0.5 on webapp, using default provider. requirements have changed , need customauthenticationprovider in order change authentication way.

this authenticationprovider

public class customauthenticationprovider implements authenticationprovider {  @autowired private paramsproperties paramsproperties;    @suppresswarnings("unchecked") public authentication authenticate(authentication authentication) throws authenticationexception {      //check username , passwd     string user = (string) authentication.getprincipal();     string pass = (string) authentication.getcredentials();     if(stringutils.isblank(user) || stringutils.isblank(pass) ){         throw new badcredentialsexception("incorrect username/password");     }      //create sso     singlesignonservice service = new singlesignonservice(paramsproperties.getservicesserver());     try {         //check logged         service.setusername(authentication.getname());         service.setpassword(authentication.getcredentials().tostring());         clientresponse response = service.call();         string result = response.getentity(string.class);          objectmapper mapper = new objectmapper();         map<string,object> map = mapper.readvalue(result, new typereference<map<string,object>>() {} );         //read code         string code = (string)map.get("code");         log.debug(" ** [authenticate] result: " + code );         (string s : (list<string>)map.get( "messages" ) ) {             log.debug(" [authenticate] message: " + s );         }          if ( code.equals( "session_created" ) || code.equals( "session_updated" ) || code.equals( "session_verified" ) ) {                           usernamepasswordauthenticationtoken tokensso = loginhelper.getusersringtokenfromauthservice(map);                         return tokensso;                         } else {             return null;         }     } catch (exception e) {         e.printstacktrace();         throw new authenticationserviceexception( e.getmessage() );     } }   public boolean supports(class authentication) {     return authentication.equals(usernamepasswordauthenticationtoken.class); } 

and security.xml

<http>   <form-login default-target-url ="/login.html" always-use-default-target="true" login-page="/login.html" login-processing-url="/j_spring_security_check"         authentication-failure-url="/login.html" />     <http-basic />   <logout logout-success-url="/login.html" /> </http>  <beans:bean id="mypasswordencryptor"     class="com.mycomp.comunes.server.spring.core.mypasswordencoder" lazy-init="true">     <beans:constructor-arg>         <beans:bean class="org.jasypt.util.password.configurablepasswordencryptor" />     </beans:constructor-arg>     <beans:constructor-arg ref="paramsproperties" /> </beans:bean>  <beans:bean id="passwordencoder"     class="org.jasypt.spring.security2.passwordencoder" lazy-init="true">     <beans:property name="passwordencryptor">         <beans:ref bean="mypasswordencryptor" />     </beans:property> </beans:bean>  <beans:bean id="authenticationprovider"     class="com.mycomp.comunes.server.spring.manager.autenticacion.customauthenticationprovider"> </beans:bean>   <authentication-provider user-service-ref='authenticationprovider'>     <password-encoder ref="passwordencoder" /> </authentication-provider> 

but when deploying, following:

caused by: java.lang.illegalargumentexception: cannot convert value of type [$proxy112 implementing org.springframework.security.providers.authenticationprovider,org.springframework.aop.springproxy,org.springframework.aop.framework.advised] required type [org.springframework.security.userdetails.userdetailsservice] property 'userdetailsservice': no matching editors or conversion strategy found 

can help?

you refer authenticationprovider bean user service, not.

<authentication-provider user-service-ref='authenticationprovider'> 

with old version of framework, can guess way use custom auth provider correctly described here.

needless highly recommended upgrade, if nothing else, in order support easier.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -