-
Feb 4th, 2011, 04:19 AM
#1
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.
-
Feb 4th, 2011, 05:58 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.
-
Feb 4th, 2011, 06:15 AM
#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!
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
-
Forum Rules