title: Accessing the current user, in a spring controller, getAuthentication() returns null
body: <p>I have attempted to implement the solutions provided in this <a href="https://stackoverflow.com/q/248562/106261">question.</a></p>
  <p>However, none of them are working for me. In my abstract base controller, I have the following method (I also tried in helper class with static methods, but same problem):</p>
  <pre><code>public User getUser() {
    User user = 
      (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();       
  }
  </code></pre>
  <p>the <strong>getAuthentication() is returning null</strong>, even though in my jsps, the following is working perfectly:</p>
  <pre><code>&lt;sec:authentication property=&quot;principal.firstname&quot; /&gt; 
  </code></pre>
  <p>In that my custom user object is accesible.</p>
  <p>Why does getAuthentication return null ?</p>
  <p>Also, I tried passing in the Principal as parameter to my specific controller method, this is null resolves to null too ...</p>
  <p>Why is my principal null, but yet the jsp is working ?</p>