title: Spring @Scheduled method SecurityContext
body: <p>Is <code>@Scheduled</code> annotated method out of any <code>SecurityContext</code>? When I try to use the following it always has <code>securitycontext/auth</code> as null. If this is not possible then what could be the right way to run user specific authentication aware scheduled task?</p>
  
  <pre><code>    @Scheduled(fixedDelay = 10000)
      // This method will send notifications to the current user
      public void sendUserNotifications() {
          SecurityContext sc = SecurityContextHolder.getContext();
          Authentication auth = sc.getAuthentication();
  
          if(auth == null) {
  
              log.info("&gt;&gt; SecurityContext=[{}], Authentication[auth] is {}, please login to receive notifications", sc, auth);
  
              return;
          }
  </code></pre>