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();

    // Make sure the trusted proxy support is enabled
    if (!tProxyConfiguration.isEnabled()) {
      String message = "Trusted proxy support is not enabled.";
      LOG.warn(message);
      throw new TrustedProxyAuthenticationNotAllowedException(message);
    }

    // Validate the host...
    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);
    }

    // Validate the user...
    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);
    }

    // Retrieve the userEntity so we can validate the groups now....
    // We also need this later if all validations succeed.
    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);
    }

    // Validate the proxied user's groups
    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);
  }
Constructor.
<p>
Given the Ambari {@link Configuration}, initializes the {@link KerberosName} class using
the <code>auth-to-local</code> rules from {@link AmbariKerberosAuthenticationProperties#getAuthToLocalRules()}.

@param configuration the Ambari configuration data
@param users         the Ambari users access object
ambari-server/src/main/java/org/apache/ambari/server/security/authentication/kerberos/AmbariProxiedUserDetailsService.java