title: SecurityContextHolder.getContext().getAuthentication().getPrincipal() is null on Controller
body: <p>I have a Spring MVC application where I'm exposing an endpoint, and a small library where I wrote some common functionality. </p>
  
  <p>I have an utility class like this:</p>
  
  <pre><code>class SecurityUtil {
      public static Principal getPrincipal(){
         return SecurityContextHolder.getContext().getAuthentication()
                .getPrincipal();
      } 
  }
  </code></pre>
  
  <p>And from the Controller I'm doing something like:</p>
  
  <pre><code> class MyController {
  
        public ResponseEntity&lt;Void&gt; myEndpoint(){
             // do something
             Principal principal = SecurityUtil.getPrincipal();
             // use the principal information for some audit processes
        }
   }
  </code></pre>
  
  <p>In this case the <code>Principal</code> is null, but if replace my code like this:</p>
  
  <pre><code> class MyController {
  
        public ResponseEntity&lt;Void&gt; myEndpoint(){
             // do something
             Principal principal = SecurityContextHolder.getContext()
                                                        .getAuthentication()
                                                        .getPrincipal();
             // use the principal information for some audit processes
        }
   }
  </code></pre>
  
  <p>In this case the <code>Principal</code> is not null and it has the information that I need.<br>
  Do you know what could be happening?</p>