code: public Authorizable getOrCreateUser(JackrabbitSession session, UserManager userManager,
                                          String path, boolean systemUser)
              throws RepositoryException {
          String[] pathAndName = pathAndName(path);
          Authorizable user = userManager.getAuthorizable(pathAndName[1]);
          LOG.debug("user.check: " + pathAndName[1] + " - " + user);
          if (user == null) {
              LOG.info("user.create: " + pathAndName[1]);
              Principal principal = new NamePrincipal(pathAndName[1]);
              if (systemUser) {
                  try {
                      // using reflection to create systems users for compatibility to older API versions
                      Method createSystemUser = userManager.getClass().getMethod("createSystemUser", String.class, String.class);
                      user = (User) createSystemUser.invoke(userManager, pathAndName[1], pathAndName[0]);
                  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                      LOG.error(ex.toString());
                  }
              } else {
                  user = userManager.createUser(pathAndName[1], pathAndName[1],
                          principal, pathAndName[0]);
              }
          }
          return user;
      }
docs: Retrieves a user by its name; if the user doesn't exist the user will be created.
  
  @param path the name of the user with an optional prepended intermediate path for user creation