i'm using spring 3 , trying populate authorities of spring security authentication bean database after user logs in.
i have service that's used accessing database like
@service public class userservice { public user getuser(string username){...} } normally, can @autowire service, because authentication bean created spring security, can't seem access service. tried using applicationcontextaware interface, spring security seems have separate applicationcontext.
i can access authentication bean mvc through getuserprincipal() there way can access @service somewhere in spring security authentication?
i'm not sure what's setup or you're trying i'll try based on basic spring-security setup.
first of all, userservice should implement userdetailsservice
in web.xml
<!-- context configuration locations spring xml files --> <context-param> <param-name>contextconfiglocation</param-name> <param-value> classpath*:meta-inf/spring/some-application-service.xml /web-inf/security.xml </param-value> </context-param> /web-inf/security.xml
<!-- assuming userservice in com.sample.security package. --> <context:component-scan base-package="com.sample.security"/> <authentication-manager> <authentication-provider user-service-ref="userservice" /> </authentication-manager>
Comments
Post a Comment