@Override
  public boolean execute(HookContext hookContext) {
    LOGGER.info("Executing user hook for {}. ", hookContext);

    PostUserCreationHookContext hookCtx = validateHookInput(hookContext);

    if (!checkUserHookPrerequisites()) {
      LOGGER.warn("Prerequisites for user hook are not satisfied. Hook not triggered");
      return false;
    }

    if (hookCtx.getUserGroups().isEmpty()) {
      LOGGER.info("No users found for executing user hook for");
      return false;
    }

    UserCreatedEvent userCreatedEvent = (UserCreatedEvent) eventFactory.newUserCreatedEvent(hookCtx);

    LOGGER.info("Triggering user hook for user: {}", hookContext);
    ambariEventPublisher.publish(userCreatedEvent);

    return true;
  }
Service in charge for handling user initialization related logic.
It's expected that this implementation encapsulates all the logic around the user initialization hook:
1. validates the context  (all the input is available)
2. checks if prerequisites are satisfied for the hook execution
3. triggers the hook execution flow
4. executes the flow (on a separate thread)
ambari-server/src/main/java/org/apache/ambari/server/hooks/users/UserHookService.java