Source:
public UserDetails loadProxiedUser(String proxiedUserName, String proxyUserName, TrustedProxyAuthenticationDetails trustedProxyAuthenticationDetails) throws AuthenticationException { LOG.info("Proxy user specified as proxied user.", proxyUserName, proxiedUserName); if (StringUtils.isEmpty(proxiedUserName)) { String message = "No proxied username was specified."; LOG.warn(message); throw new UsernameNotFoundException(message); } if (trustedProxyAuthenticationDetails == null) { String message = "Trusted proxy details have not been provided."; LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } AmbariTProxyConfiguration tProxyConfiguration = ambariTProxyConfigurationProvider.get(); if (!tProxyConfiguration.isEnabled()) { String message = "Trusted proxy support is not enabled."; LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } if (!validateHost(tProxyConfiguration, proxyUserName, trustedProxyAuthenticationDetails.getRemoteAddress())) { String message = String.format("Trusted proxy is not allowed for %s -> %s: host match not found.", proxyUserName, proxiedUserName); LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } if (!validateUser(tProxyConfiguration, proxyUserName, proxiedUserName)) { String message = String.format("Trusted proxy is not allowed for %s -> %s: user match not found.", proxyUserName, proxiedUserName); LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } UserEntity userEntity = users.getUserEntity(proxiedUserName); if (userEntity == null) { String message = String.format("Failed to find and account for proxied user, %s.", proxiedUserName); LOG.warn(message); throw new UsernameNotFoundException(message); } if (!validateGroup(tProxyConfiguration, proxyUserName, userEntity)) { String message = String.format("Trusted proxy is not allowed for %s -> %s: group match not found.", proxyUserName, proxiedUserName); LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } return createUserDetails(userEntity); }

Target:
public UserDetails loadProxiedUser(String proxiedUserName, String proxyUserName, TrustedProxyAuthenticationDetails trustedProxyAuthenticationDetails) throws AuthenticationException { LOG.info("Proxy user specified as proxied user.", proxyUserName, proxiedUserName); if (StringUtils.isEmpty(proxiedUserName)) { String message = "No proxied username was specified."; LOG.warn(message); throw new UsernameNotFoundException(message); } if (trustedProxyAuthenticationDetails == null) { String message = "Trusted proxy details have not been provided."; LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } AmbariTProxyConfiguration tProxyConfiguration = ambariTProxyConfigurationProvider.get(); if (!tProxyConfiguration.isEnabled()) { String message = "Trusted proxy support is not enabled."; LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } if (!validateHost(tProxyConfiguration, proxyUserName, trustedProxyAuthenticationDetails.getRemoteAddress())) { String message = String.format("Trusted proxy is not allowed for %s -> %s: host match not found.", proxyUserName, proxiedUserName); LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } if (!validateUser(tProxyConfiguration, proxyUserName, proxiedUserName)) { String message = String.format("Trusted proxy is not allowed for %s -> %s: user match not found.", proxyUserName, proxiedUserName); LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } UserEntity userEntity = users.getUserEntity(proxiedUserName); if (userEntity == null) { String message = String.format("Failed to find an account for the proxied user, %s.", proxiedUserName); LOG.warn(message); throw new UsernameNotFoundException(message); } if (!validateGroup(tProxyConfiguration, proxyUserName, userEntity)) { String message = String.format("Trusted proxy is not allowed for %s -> %s: group match not found.", proxyUserName, proxiedUserName); LOG.warn(message); throw new TrustedProxyAuthenticationNotAllowedException(message); } return createUserDetails(userEntity); }