class RangerIpMatcher extends RangerAbstractConditionEvaluator {

	String digestPolicyIp(final String policyIp) {
		if (LOG.isDebugEnabled()) {
			LOG.debug("==> RangerIpMatcher.digestPolicyIp(" + policyIp + ")");
		}

		String result;
		Matcher matcher = allWildcards.matcher(policyIp);
		if (matcher.matches()) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("digestPolicyIp: policyIP[" + policyIp +"] all wildcards.");
			}
			result = "";
		} else if (policyIp.contains(".")) {
			matcher = trailingWildcardsIp4.matcher(policyIp);
			result = matcher.replaceFirst(".");
		} else {
			matcher = trailingWildcardsIp6.matcher(policyIp);
			// also lower cases the ipv6 items
			result = matcher.replaceFirst(":").toLowerCase();
		}
		
		if (LOG.isDebugEnabled()) {
			LOG.debug("<== RangerIpMatcher.digestPolicyIp(" + policyIp + "): " + policyIp);
		}
		return result;
	}

}