Announcement Announcement Module
Collapse
No announcement yet.
AuthenticationManager not autowiring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 04:47 AM.

  • #2
    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.

    Comment


    • #3
      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!

      Comment

      Working...
      X