title: Spring Security Digest Auth using JavaConfig Example
body: <p>How do you configure Spring 4.0 and Spring Security (3.2.0) for digest authentication exclusively using javaconfig (no XML)?  I am using the below configuration class, however all requests are getting denied with HTTP 401 and "Nonce should have yielded two tokens but was (... message just stops there)".</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  @EnableGlobalMethodSecurity(prePostEnabled = true)
  public class SecurityConfigurationDigest extends WebSecurityConfigurerAdapter
  {
  @Autowired
  public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception
  {
      auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
  }
  
  @Override
  protected void configure(HttpSecurity http) throws Exception
  {
      http.authorizeRequests().antMatchers("/**").authenticated().and().addFilter(digestAuthenticationFilter(digestEntryPoint()));
  }
  
  @Override
  @Bean
  public UserDetailsService userDetailsServiceBean() throws Exception
  {
      return super.userDetailsServiceBean();
  }
  
  public DigestAuthenticationFilter digestAuthenticationFilter(DigestAuthenticationEntryPoint digestAuthenticationEntryPoint) throws Exception
  {
      DigestAuthenticationFilter digestAuthenticationFilter = new DigestAuthenticationFilter();
      digestAuthenticationFilter.setAuthenticationEntryPoint(digestEntryPoint());
      digestAuthenticationFilter.setUserDetailsService(userDetailsServiceBean());
      return digestAuthenticationFilter;
  }
  
  @Bean
  public DigestAuthenticationEntryPoint digestEntryPoint()
  {
      DigestAuthenticationEntryPoint digestAuthenticationEntryPoint = new DigestAuthenticationEntryPoint();
      digestAuthenticationEntryPoint.setKey("mykey");
      digestAuthenticationEntryPoint.setRealmName("myrealm");
      return digestAuthenticationEntryPoint;
  }
  }
  </code></pre>
  
  <p>I am attempting to authorize on the client side by including the header:</p>
  
  <p>Authorization: Digest username="user", realm="myrealm", nonce="", uri="/service?param=98", response="fcd46faf42a583499d4e7f0371171ef2", opaque=""</p>
  
  <p>I am able to access the intended services if I revert this class to a HttpBasic based configuration.  Is the problem with my config or with my request?  Most of the above code was borrowed from another post, however I cannot get things working in this context.  All of this is running within Spring Boot 0.5.0M7.</p>
  
  <p>Thanks.</p>