title: Spring: SecurityContextHolder.getContext().getAuthentication().getPrincipal() returns null
body: <p>In My MVC application, even after login when I am trying to get the principal object using,</p>
  
  <pre><code>Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  </code></pre>
  
  <p>the authentication is returned as null.</p>
  
  <p>In Spring-security context, </p>
  
  <pre><code>&lt;intercept-url pattern="/test/user/login" access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt;
  </code></pre>
  
  <p>Servlet mapping in Web.xml:</p>
  
  <pre><code>&lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I am new to MVC implementation. Please help me in fixing this. </p>