class AmbariProxiedUserDetailsService implements UserDetailsService {

  boolean validateHost(AmbariTProxyConfiguration tProxyConfiguration, String proxyUserName, String remoteAddress) {
    String allowedHosts = tProxyConfiguration.getAllowedHosts(proxyUserName);

    if (StringUtils.isNotEmpty(allowedHosts)) {
      Set<String> hostSpecs = Arrays.stream(allowedHosts.split("\\s*,\\s*"))
          .map(s -> s.trim().toLowerCase())
          .collect(toSet());

      if (hostSpecs.contains("*")) {
        return true;
      } else {
        for (String hostSpec : hostSpecs) {
          if (isIPAddress(hostSpec)) {
            if (hostSpec.equals(remoteAddress)) {
              return true;
            }
          } else if (isIPAddressRange(hostSpec)) {
            if (isInIpAddressRange(hostSpec, remoteAddress)) {
              return true;
            }
          } else if (matchesHostname(hostSpec, remoteAddress)) {
            return true;
          }
        }
      }
    }

    return false;
  }

    AmbariProxiedUserDetailsService(Configuration configuration, Users users);

}