Hello:
I am trying to get to PreAuthentication working. I am following the official Spring docs but have missed something. I get the following error:
"Cannot convert value of type [yyy.zzz.security.XXXXAuthenticationUserDetailsServ ice] to required type [org.springframework.security.core.userdetails.User DetailsService] for property 'userDetailsService': no matching editors or conversion strategy found"
Somehow I am not wrapping my service correctly. Any help would appreciated. Eric.
Code:public class XXXAuthenticationUserDetailsService implements AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> { private XXXService xxxService = null; @Override public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) throws UsernameNotFoundException { ... some processing to get authorities ... user.setGrantedAuthroities(~~~~~~); return user; }
Code:public class BBBPreAuthenticationFilter extends RequestHeaderAuthenticationFilter { @Override public Object getPreAuthenticatedPrincipal(HttpServletRequest request) { String authHeader = request.getHeader("Authorization"); if (authHeader == null || authHeader.equals("")) { Log.getGeneralLogger().fatal("No authorization header"); throw new AccessDeniedException("Internal problem. Please contact ABC."); } return authHeader; } }
HTML Code:<http realm="Spring Security Application" use-expressions="true" entry-point-ref="tokenAuthenticationEntryPoint"> <intercept-url pattern="/blah/nonsecure" access="permitAll"/> <intercept-url pattern="/blah/lookup" access="hasRole('ROLE_JJJJ')"/> <custom-filter position="PRE_AUTH_FILTER" ref="BBBPreAuthenticationFilter" /> </http> <beans:bean id="BBBPreAuthenticationFilter" class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter"> <beans:property name="principalRequestHeader" value="Authorization"/> <beans:property name="authenticationManager" ref="authenticationManager" /> </beans:bean> <authentication-manager alias="authenticationManager" > <authentication-provider ref="preauthAuthProvider" /> </authentication-manager> <beans:bean name="xxxService" class="yyy.zzz.service.ASMServiceImpl"/> <beans:bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider"> <beans:property name="preAuthenticatedUserDetailsService" ref="userDetailsServiceWrapper"/> </beans:bean> <beans:bean id="userDetailsServiceWrapper" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"> <beans:property name="userDetailsService" ref="xxxAuthenticationUserDetailsService"/> </beans:bean> <beans:bean id="xxxAuthenticationUserDetailsService" class="yyy.zzz.security.XXXAuthenticationUserDetailsService"> <beans:property name="xxxService" ref="xxxService"/> </beans:bean>


Reply With Quote