@Override
  public void loginFailure(HttpRequest request, AuthenticationException e) {
    checkRequest(request);
    requireNonNull(e, "AuthenticationException can't be null");
    if (!LOGGER.isDebugEnabled()) {
      return;
    }
    Source source = e.getSource();
    LOGGER.debug("login failure [cause|{}][method|{}][provider|{}|{}][IP|{}|{}][login|{}]",
      emptyIfNull(e.getMessage()),
      source.getMethod(), source.getProvider(), source.getProviderName(),
      request.getRemoteAddr(), getAllIps(request),
      preventLogFlood(emptyIfNull(e.getLogin())));
  }
@Test
  public void login_failure_logs_remote_ip_from_request() {
    AuthenticationException exception = newBuilder()
      .setSource(Source.realm(Method.EXTERNAL, "bar"))
      .setMessage("Damn it!")
      .setLogin("Baaad")
      .build();
    underTest.loginFailure(mockRequest("1.2.3.4"), exception);

    verifyLog("login failure [cause|Damn it!][method|EXTERNAL][provider|REALM|bar][IP|1.2.3.4|][login|Baaad]",
      Set.of("logout", "login success"));
  }