Results 1 to 3 of 3

Thread: AuthenticationManager not autowiring

  1. #1
    Join Date
    Feb 2011
    Posts
    2

    Default AuthenticationManager not autowiring

    Hi,

    Im trying to autowire my authenticationManager in my CallbackHandler...something like this:

    @Component
    public class ServerPasswordCallback implements CallbackHandler {

    protected Logger log = Logger.getLogger(ServerPasswordCallback.class);

    @Autowired
    AuthenticationManager authenticationManager;

    public void handle(Callback[] callbacks) throws IOException,
    UnsupportedCallbackException {

    //if a type of WSPasswordhandler comes by,
    WSPasswordCallback pc = null;
    for (Callback callback : callbacks) {
    if (callback instanceof WSPasswordCallback) {
    pc = (WSPasswordCallback)callback;
    break;
    }
    }
    etc....

    But I cant get the @Autowired to work...The authenticationManager stays empty. I have declared the alias on it like:

    <security:authentication-manager alias="authenticationManager">
    <security:authentication-provider user-service-ref="customUserDetailsService">
    </security:authentication-provider>
    </security:authentication-manager>

    and if i autowire the AuthenticationManager in a junit test...it works fine. Can somebody tell me why this wont work in my callback handler?

    Im using Spring 3.0.5.RELEASE with Spring security 3.0.1.RELEASE and WSS4J 1.5.10 of org.apache.ws.security.

    Best regards!
    Last edited by misterPom; Feb 4th, 2011 at 04:47 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Please use [ code][/code ] tags when posting code, that way it remains readable.

    Is the bean you want to use for autowiring defined in the same context as the AuthenticationManager or a child context of the context that defines the authenticationmanager. Also is the context enabled for autowiring (ie. context:annotation-config or context:component-scan).

    Also maker sure you aren't instantiating a component yourself use the one defined/scanned in the applicationcontext.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Feb 2011
    Posts
    2

    Default

    I used <context:component-scan in my applicationContext.xml. In applicationContext-security.xml I declared the AuthenticationManager. I missed it that the AuthenticationManager is not on my scan path ofcourse...stupid mistake. I added context:annotation-config to the security context and it wires fine. Thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •