title: Autowiring Spring Authentication Manager in Java Config
body: <p>I've set a custom authentication provider:</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  @EnableGlobalAuthentication
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      @Qualifier("samlAuthenticationProvider")
      SAMLAuthenticationProvider samlAuthenticationProvider;
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          /**
           * Do your stuff here
           */
      }
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.authenticationProvider(samlAuthenticationProvider);
      }   
  
  }
  </code></pre>
  
  <p>Now, I'd like to set also an alias for the authentication-manager, then I'd like to autowire it in another bean definition.</p>
  
  <p>Eg:</p>
  
  <pre><code>&lt;!-- Register authentication manager with SAML provider --&gt;
  &lt;security:authentication-manager alias="authenticationManager"&gt;
      &lt;security:authentication-provider
          ref="samlAuthenticationProvider" /&gt;
  &lt;/security:authentication-manager&gt;
  
  &lt;!-- Processing filter for WebSSO Holder-of-Key profile --&gt;
  &lt;bean id="samlWebSSOHoKProcessingFilter"
      class="org.springframework.security.saml.SAMLWebSSOHoKProcessingFilter"&gt;
      &lt;property name="authenticationManager" ref="authenticationManager" /&gt;
      &lt;property name="authenticationSuccessHandler" ref="successRedirectHandler" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Is there a way to do that only in Java Config?</p>