Source:
<code>public void onUnsuccessfulAuthentication(AmbariAuthenticationFilter filter, HttpServletRequest servletRequest, HttpServletResponse servletResponse, AmbariAuthenticationException cause) { String username; String message; String logMessage; String proxyUser; Integer consecutiveFailures = null; boolean incrementFailureCount; if (cause == null) { username = null; message = "Unknown cause"; proxyUser = null; incrementFailureCount = false; } else { username = cause.getUsername(); <START> proxyUser = RequestUtils.getQueryStringParameterValue(servletRequest, "doAs"); <END> message = cause.getLocalizedMessage(); incrementFailureCount = cause.isCredentialFailure(); } if (!StringUtils.isEmpty(username)) { if(incrementFailureCount && filter.shouldIncrementFailureCount()) { consecutiveFailures = users.incrementConsecutiveAuthenticationFailures(username); if (consecutiveFailures == null) { logMessage = String.format("Failed to authenticate %s: The user does not exist in the Ambari database", username); } else { logMessage = String.format("Failed to authenticate %s (attempt #%d): %s", username, consecutiveFailures, message); } } else { logMessage = String.format("Failed to authenticate %s: %s", username, message); } } else { logMessage = String.format("Failed to authenticate an unknown user: %s", message); } if (LOG.isDebugEnabled()) { LOG.debug(logMessage, cause); } else { LOG.info(logMessage); } if (auditLogger.isEnabled()) { AuditEvent loginFailedAuditEvent = LoginAuditEvent.builder() .withRemoteIp(RequestUtils.getRemoteAddress(servletRequest)) .withTimestamp(System.currentTimeMillis()) .withReasonOfFailure(message) .withConsecutiveFailures(consecutiveFailures) .withUserName(username) .withProxyUserName(proxyUser) .build(); auditLogger.log(loginFailedAuditEvent); } }</code><technical_language>add proxyuser info AmbariAuthenticationException get request</technical_language>

Target:
public void onUnsuccessfulAuthentication(AmbariAuthenticationFilter filter, HttpServletRequest servletRequest, HttpServletResponse servletResponse, AmbariAuthenticationException cause) { String username; String message; String logMessage; Integer consecutiveFailures = null; boolean incrementFailureCount; if (cause == null) { username = null; message = "Unknown cause"; incrementFailureCount = false; } else { username = cause.getUsername(); message = cause.getLocalizedMessage(); incrementFailureCount = cause.isCredentialFailure(); } if (!StringUtils.isEmpty(username)) { if(incrementFailureCount && filter.shouldIncrementFailureCount()) { consecutiveFailures = users.incrementConsecutiveAuthenticationFailures(username); if (consecutiveFailures == null) { logMessage = String.format("Failed to authenticate %s: The user does not exist in the Ambari database", username); } else { logMessage = String.format("Failed to authenticate %s (attempt #%d): %s", username, consecutiveFailures, message); } } else { logMessage = String.format("Failed to authenticate %s: %s", username, message); } } else { logMessage = String.format("Failed to authenticate an unknown user: %s", message); } if (LOG.isDebugEnabled()) { LOG.debug(logMessage, cause); } else { LOG.info(logMessage); } if (auditLogger.isEnabled()) { AuditEvent loginFailedAuditEvent = LoginAuditEvent.builder() .withRemoteIp(RequestUtils.getRemoteAddress(servletRequest)) .withTimestamp(System.currentTimeMillis()) .withReasonOfFailure(message) .withConsecutiveFailures(consecutiveFailures) .withUserName(username) .withProxyUserName(null) .build(); auditLogger.log(loginFailedAuditEvent); } }