class KeycloakUserManager extends PersonalAccountUserManager {

  public User getOrCreateUser(String id, String email, String username)
      throws ServerException, ConflictException {
    Optional<User> userById = getUserById(id);
    if (!userById.isPresent()) {
      synchronized (this) {
        userById = getUserById(id);
        if (!userById.isPresent()) {
          Optional<User> userByEmail = getUserByEmail(email);
          if (userByEmail.isPresent()) {
            remove(userByEmail.get().getId());
          }
          final UserImpl cheUser = new UserImpl(id, email, username, generate("", 12), emptyList());
          try {
            return create(cheUser, false);
          } catch (ConflictException ex) {
            cheUser.setName(generate(cheUser.getName(), 4));
            return create(cheUser, false);
          }
        }
      }
    }
    return actualizeUserEmail(userById.get(), email);
  }

  @Inject public  KeycloakUserManager(
      UserDao userDao,
      ProfileDao profileDao,
      PreferenceDao preferencesDao,
      AccountManager accountManager,
      EventService eventService,
      @Named("che.auth.reserved_user_names") String[] reservedNames);

}