title: Spring Security 3.2 inject AuthenticationManager (ProviderManager)
body: <p>I am using the java configuration capabilities of Spring Security 3.2 and I was wondering if there is a way to inject the default AuthenticationManager instance into a custom (authentication) filter.
  All attempts that I did so far ended in </p>
  
  <p>No qualifying bean of type [org.springframework.security.authentication.AuthenticationManager]</p>
  
  <p>Here my current bean definition:</p>
  
  <pre><code>@Bean(name="tokenAuthenticationFilter")
  public Filter getTokenAuthenticationFilter(AuthenticationManager authenticationManager) {
          TokenAuthenticationFilter filter = new TokenAuthenticationFilter(authenticationManager);
  
          return filter;
  }
  </code></pre>
  
  <p>I read that the following would implicitly tell spring security to use the default authentication manager.</p>
  
  <pre><code>&lt;authentication-manager&gt;
      &lt;authentication-provider&gt;
          ...
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p>That I wanted to translate into the following java configuration snippet:</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
      @Autowired
      private TokenAuthenticationProvider tokenAuthenticationProvider = null;
  
  
      @Override
      protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
          auth.authenticationProvider(tokenAuthenticationProvider);
      }
  </code></pre>