class UserFunctionExecution implements InternalFunction<Object[]> {

  boolean loginRequired(SecurityService securityService) {
    try {
      // if the function is executed on a server with jmx-manager that user is already logged into
      // then we do not need to do login/logout here.
      Subject subject = securityService.getSubject();
      return subject == null || !subject.isAuthenticated();
    } catch (AuthenticationRequiredException e) {
      return true;
    }
  }

}