@Override
  public void run() {
    Authentication savedAuthContext = SecurityContextHolder.getContext().getAuthentication();
    try {
      InternalAuthenticationToken authenticationToken = new InternalAuthenticationToken(TopologyManager.INTERNAL_AUTH_TOKEN);
      authenticationToken.setAuthenticated(true);
      SecurityContextHolder.getContext().setAuthentication(authenticationToken);
      runTask();
    } finally {
      SecurityContextHolder.getContext().setAuthentication(savedAuthContext);
    }
  }
Run with an InternalAuthenticationToken as when running these tasks we might not have any active security context.
ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/TopologyHostTask.java