title: Custom WebAuthenticationDetails programmatically in spring security
body: <p>I am currently moving from an xml-based configuration of spring security to a java based one. I need to setup a custom WebAuthenticationDetails via Java. Is there a way to do that? In XML, I would just set that authenticationDetailsSource of the UsernamePasswordAuthenticationFilter. Relevant sample below</p>
  
  <pre><code>&lt;http entry-point-ref="loginUrlAuthenticationEntryPoint"&gt;
       &lt;custom-filter  ref="rememberMeFilter" position="REMEMBER_ME_FILTER"/&gt;
       &lt;custom-filter ref="loginFilter" position="FORM_LOGIN_FILTER"/&gt;    
       &lt;intercept-url pattern="/access/**" access="ROLE_USER" /&gt;
       &lt;csrf/&gt;
      &lt;access-denied-handler error-page="/login" /&gt;
      &lt;logout logout-success-url="/login?logout" /&gt;
  &lt;/http&gt;
  
  
      &lt;beans:bean id="myWebAuthDetails"
      class="com.auth.CustomWebAuthenticationDetailsSource"&gt;
  &lt;/beans:bean&gt;
  
       &lt;beans:bean id="loginFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"&gt;
    &lt;beans:property name="authenticationManager" ref="authenticationManager" /&gt;
    &lt;beans:property name="rememberMeServices" ref="rememberMeServices" /&gt;
    &lt;beans:property name="usernameParameter" value="username" /&gt;
    &lt;beans:property name="passwordParameter" value="password" /&gt;
    &lt;beans:property name="sessionAuthenticationStrategy" ref="sas" /&gt;
    &lt;beans:property name="allowSessionCreation" value="true" /&gt;
    &lt;beans:property name="authenticationDetailsSource" ref="myWebAuthDetails" /&gt;
    &lt;beans:property name="authenticationFailureHandler" ref="failureHandler" /&gt;
    &lt;beans:property name="authenticationSuccessHandler" ref="successHandler" /&gt;
    &lt;beans:property name="filterProcessesUrl" value="/processlogin" /&gt;
  &lt;/beans:bean&gt;
  </code></pre>