title: SecurityContext.getAuthentication() is null
body: <p>I have a very strange problem. I try to use Spring Security (4.1.0) for user authentication on a WildFly Server. I tried WildFly 9 and 10. 
  My authentication data is stored after the login and Spring can use it, when it calls <code>getAuthentication()</code> of <code>SecurityContext</code>, but if I call 
  <code>SecurityContextHolder.getContext().getAuthentication()</code> it returns <code>null</code>. I already recognized, that I get a different <code>SecurityContextImpl</code> (different object ID).
  I tried already to use the three different modes of <code>SecurityContextHolder</code>, but it made no difference.</p>
  
  <p>My security.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;b:beans xmlns="http://www.springframework.org/schema/security"
  xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
      http://www.springframework.org/schema/security
      http://www.springframework.org/schema/security/spring-security-4.1.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-4.2.xsd"&gt;
  
  &lt;b:bean id="passwordEncoder"
      class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" /&gt;
  
  &lt;b:bean id="accessDecisionManager"
      class="org.springframework.security.access.vote.AffirmativeBased"&gt;
      &lt;b:property name="allowIfAllAbstainDecisions" value="false" /&gt;
      &lt;b:constructor-arg&gt;
          &lt;b:list&gt;
              &lt;b:bean class="tool.security.RightVoter" /&gt;
          &lt;/b:list&gt;
      &lt;/b:constructor-arg&gt;
  &lt;/b:bean&gt;
  
  &lt;authentication-manager alias="authenticationManager"&gt;
      &lt;authentication-provider ref="loginAuthenticationProvider" /&gt;
  &lt;/authentication-manager&gt;
  
  &lt;b:bean id="authenticationProcessingFilter"
      class="tool.security.AuthenticationProcessingFilter"&gt;
      &lt;b:constructor-arg value="/processLogin" /&gt; &lt;!-- defaultFilterProcessesUrl --&gt;
      &lt;b:property name="authenticationManager" ref="authenticationManager" /&gt;
      &lt;!-- &lt;b:property name="filterProcessesUrl" value="/processLogin" /&gt; --&gt;
      &lt;b:property name="authenticationSuccessHandler"&gt;
          &lt;b:bean
              class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"&gt;
              &lt;b:property name="alwaysUseDefaultTargetUrl" value="true" /&gt;
              &lt;b:property name="defaultTargetUrl" value="/initLogin" /&gt;
          &lt;/b:bean&gt;
      &lt;/b:property&gt;
      &lt;b:property name="authenticationFailureHandler"&gt;
          &lt;b:bean class="tool.security.LoginFailureHandler"&gt;
              &lt;b:property name="redirectUrl" value="/login" /&gt;
          &lt;/b:bean&gt;
      &lt;/b:property&gt;
  &lt;/b:bean&gt;
  
  &lt;b:bean id="loginExistsFilter" class="tool.security.LoginExistsFilter"&gt;
      &lt;b:property name="loginUrl" value="/login" /&gt;
  &lt;/b:bean&gt;
  
  &lt;b:bean id="authenticationEntryPoint"
      class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"&gt;
      &lt;b:constructor-arg value="/login" /&gt; &lt;!-- loginFormUrl --&gt;
  &lt;/b:bean&gt;
  
  &lt;b:bean id="loginAuthenticationProvider"
      class="tool.security.LoginAuthenticationProvider"&gt;
      &lt;b:property name="loginService" ref="loginService" /&gt;
  &lt;/b:bean&gt;
  
  &lt;b:bean id="loginService" class="tool.security.LoginServiceImpl"&gt;
      &lt;b:property name="userDao" ref="userDao" /&gt;
      &lt;b:property name="userTF" ref="userTF" /&gt;
      &lt;b:property name="passwordEncoder" ref="passwordEncoder" /&gt;
  &lt;/b:bean&gt;
  
  &lt;b:bean id="userDao" class="tool.user.impl.MongoUserDao"&gt;&lt;/b:bean&gt;
  &lt;b:bean id="userTF" class="tool.user.UserTFImpl"&gt;&lt;/b:bean&gt;
  
  &lt;http security="none" pattern="/css/**" /&gt;
  &lt;http security="none" pattern="/js/**" /&gt;
  &lt;http security="none" pattern="/login" /&gt;
  &lt;http security="none" pattern="/loginRedirect" /&gt;
  &lt;http security="none" pattern="/invalidbrowser" /&gt;
  
  &lt;http entry-point-ref="authenticationEntryPoint"
      access-decision-manager-ref="accessDecisionManager"&gt;
      &lt;session-management invalid-session-url="/login?timeout=1"
          session-fixation-protection="newSession"&gt;
          &lt;concurrency-control max-sessions="1"
              error-if-maximum-exceeded="true" /&gt;
      &lt;/session-management&gt;
  
      &lt;custom-filter ref="authenticationProcessingFilter"
          position="FORM_LOGIN_FILTER" /&gt;
      &lt;custom-filter ref="loginExistsFilter" before="FILTER_SECURITY_INTERCEPTOR" /&gt;
  
      &lt;csrf disabled="true" /&gt;
  
  &lt;/http&gt;
  
  &lt;global-method-security
      access-decision-manager-ref="accessDecisionManager"
      secured-annotations="enabled" /&gt;
  </code></pre>
  
  <p></p>