@Test public void test_isExactlyMatched() { List<String> ips = Arrays.asList("1.2.3.1", "1.2.3.11", "1.2.3.111", "a0:b0:c0:d0:e0:f0", "a0:b0:c0:d0:e0:f1", "a0:b0:c0:d0:e0:f2"); RangerIpMatcher matcher = new RangerIpMatcher(); Assert.assertTrue(matcher.isExactlyMatched(ips, "1.2.3.1")); Assert.assertTrue(matcher.isExactlyMatched(ips, "1.2.3.111")); Assert.assertTrue(matcher.isExactlyMatched(ips, "A0:B0:C0:D0:E0:F1")); Assert.assertTrue(matcher.isExactlyMatched(ips, "a0:b0:c0:d0:e0:f1")); Assert.assertFalse(matcher.isExactlyMatched(ips, "1.2.3.2")); Assert.assertFalse(matcher.isExactlyMatched(ips, "a0:b0:c0:d0:e0:f3")); }
boolean isExactlyMatched(final List<String> ips, final String requestIp) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + ")"); } boolean matchFound = false; if (requestIp.contains(".")) { matchFound = ips.contains(requestIp); } else { matchFound = ips.contains(requestIp.toLowerCase()); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + "): " + matchFound); } return matchFound; }
RangerIpMatcher extends RangerAbstractConditionEvaluator { boolean isExactlyMatched(final List<String> ips, final String requestIp) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + ")"); } boolean matchFound = false; if (requestIp.contains(".")) { matchFound = ips.contains(requestIp); } else { matchFound = ips.contains(requestIp.toLowerCase()); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + "): " + matchFound); } return matchFound; } }
RangerIpMatcher extends RangerAbstractConditionEvaluator { boolean isExactlyMatched(final List<String> ips, final String requestIp) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + ")"); } boolean matchFound = false; if (requestIp.contains(".")) { matchFound = ips.contains(requestIp); } else { matchFound = ips.contains(requestIp.toLowerCase()); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + "): " + matchFound); } return matchFound; }  }
RangerIpMatcher extends RangerAbstractConditionEvaluator { boolean isExactlyMatched(final List<String> ips, final String requestIp) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + ")"); } boolean matchFound = false; if (requestIp.contains(".")) { matchFound = ips.contains(requestIp); } else { matchFound = ips.contains(requestIp.toLowerCase()); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + "): " + matchFound); } return matchFound; }  @Override void init(); @Override boolean isMatched(final RangerAccessRequest request); }
RangerIpMatcher extends RangerAbstractConditionEvaluator { boolean isExactlyMatched(final List<String> ips, final String requestIp) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + ")"); } boolean matchFound = false; if (requestIp.contains(".")) { matchFound = ips.contains(requestIp); } else { matchFound = ips.contains(requestIp.toLowerCase()); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isExactlyMatched(" + ips+ ", " + requestIp + "): " + matchFound); } return matchFound; }  @Override void init(); @Override boolean isMatched(final RangerAccessRequest request);  }