class RangerIpMatcher extends RangerAbstractConditionEvaluator {

	boolean isWildcardMatched(final List<String> ips, final String requestIp) {

		if(LOG.isDebugEnabled()) {
			LOG.debug("==> RangerIpMatcher.isWildcardMatched(" + ips+ ", " + requestIp + ")");
		}

		boolean matchFound = false;
		Iterator<String> iterator = ips.iterator();
		while (iterator.hasNext() && !matchFound) {
			String ip = iterator.next();
			if (requestIp.contains(".") && requestIp.startsWith(ip)) {
				if (LOG.isDebugEnabled()) {
					LOG.debug("Wildcard Policy IP[" + ip + "] matches request IPv4[" + requestIp + "].");
				}
				matchFound = true;
			} else if (requestIp.toLowerCase().startsWith(ip)) {
					if (LOG.isDebugEnabled()) {
						LOG.debug("Wildcard Policy IP[" + ip + "] matches request IPv6[" + requestIp + "].");
					}
					matchFound = true;
			} else {
				LOG.debug("Wildcard policy IP[" + ip + "] did not match request IP[" + requestIp + "].");
			}
		}
		
		if(LOG.isDebugEnabled()) {
			LOG.debug("<== RangerIpMatcher.isWildcardMatched(" + ips+ ", " + requestIp + "): " + matchFound);
		}
		return matchFound;
	}

}