@Test public void test_integration() { RangerIpMatcher ipMatcher = createMatcher(null); Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.4"))); ipMatcher = createMatcher(new String[]{}); Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.4"))); ipMatcher = createMatcher(new String[]{"*"}); Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.4"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("1:2:3:4:5:6"))); ipMatcher = createMatcher(new String[]{"1.2.3.*"} ); Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.4"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.123"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.123567"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3..123567"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.boo"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.31.123567"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.33.123567"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.0.0"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.255.255"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.254.254"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("0.0.0.0"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("255.255.255.255"))); ipMatcher = createMatcher(new String[]{"11.22.*.*"} ); Assert.assertTrue(ipMatcher.isMatched(createRequest("11.22.33.4"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("11.22.33.44"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("11.22.253.190"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("11.22.253.190"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("11.222.253.190"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("11.21.253.190"))); ipMatcher = createMatcher(new String[]{"193.214.*"} ); Assert.assertTrue(ipMatcher.isMatched(createRequest("193.214.3.4"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("193.21.253.190"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("193:214:3:4"))); ipMatcher = createMatcher(new String[]{"193:214:*"} ); Assert.assertTrue(ipMatcher.isMatched(createRequest("193:214:3:4:5:6"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("193:214:13:94:a90:b4f"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("193:215:13:94:a90:b4f"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("193.214.3.4"))); ipMatcher = createMatcher(new String[]{"99:a9:b9:c9:d9:e9"} ); Assert.assertTrue(ipMatcher.isMatched(createRequest("99:a9:b9:c9:d9:e9"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("99:a9:b9:c9:d0:e9"))); ipMatcher = createMatcher(new String[]{"10.20.30.*", "99:a9:b9:c9:d9:*"} ); Assert.assertTrue(ipMatcher.isMatched(createRequest("99:a9:b9:c9:d9:e9"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("99:a9:b9:c9:d9:e9"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("99:a9:b9:c9:dd:e9"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("89:a9:b9:c9:d9:e9"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("10.20.30.10"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("10.20.30.20"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("10.20.3.10"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("10.20.33.10"))); }
@Override public boolean isMatched(final RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isMatched(" + request + ")"); } boolean ipMatched = true; if (_allowAny) { LOG.debug("isMatched: allowAny flag is true. Matched!"); } else { String requestIp = extractIp(request); if (requestIp == null) { LOG.debug("isMatched: couldn't get ip address from request. Ok. Implicitly matched!"); } else { ipMatched = isWildcardMatched(_wildCardIps, requestIp) || isExactlyMatched(_exactIps, requestIp); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isMatched(" + request+ "): " + ipMatched); } return ipMatched; }
RangerIpMatcher extends RangerAbstractConditionEvaluator { @Override public boolean isMatched(final RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isMatched(" + request + ")"); } boolean ipMatched = true; if (_allowAny) { LOG.debug("isMatched: allowAny flag is true. Matched!"); } else { String requestIp = extractIp(request); if (requestIp == null) { LOG.debug("isMatched: couldn't get ip address from request. Ok. Implicitly matched!"); } else { ipMatched = isWildcardMatched(_wildCardIps, requestIp) || isExactlyMatched(_exactIps, requestIp); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isMatched(" + request+ "): " + ipMatched); } return ipMatched; } }
RangerIpMatcher extends RangerAbstractConditionEvaluator { @Override public boolean isMatched(final RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isMatched(" + request + ")"); } boolean ipMatched = true; if (_allowAny) { LOG.debug("isMatched: allowAny flag is true. Matched!"); } else { String requestIp = extractIp(request); if (requestIp == null) { LOG.debug("isMatched: couldn't get ip address from request. Ok. Implicitly matched!"); } else { ipMatched = isWildcardMatched(_wildCardIps, requestIp) || isExactlyMatched(_exactIps, requestIp); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isMatched(" + request+ "): " + ipMatched); } return ipMatched; }  }
RangerIpMatcher extends RangerAbstractConditionEvaluator { @Override public boolean isMatched(final RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isMatched(" + request + ")"); } boolean ipMatched = true; if (_allowAny) { LOG.debug("isMatched: allowAny flag is true. Matched!"); } else { String requestIp = extractIp(request); if (requestIp == null) { LOG.debug("isMatched: couldn't get ip address from request. Ok. Implicitly matched!"); } else { ipMatched = isWildcardMatched(_wildCardIps, requestIp) || isExactlyMatched(_exactIps, requestIp); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isMatched(" + request+ "): " + ipMatched); } return ipMatched; }  @Override void init(); @Override boolean isMatched(final RangerAccessRequest request); }
RangerIpMatcher extends RangerAbstractConditionEvaluator { @Override public boolean isMatched(final RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerIpMatcher.isMatched(" + request + ")"); } boolean ipMatched = true; if (_allowAny) { LOG.debug("isMatched: allowAny flag is true. Matched!"); } else { String requestIp = extractIp(request); if (requestIp == null) { LOG.debug("isMatched: couldn't get ip address from request. Ok. Implicitly matched!"); } else { ipMatched = isWildcardMatched(_wildCardIps, requestIp) || isExactlyMatched(_exactIps, requestIp); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerIpMatcher.isMatched(" + request+ "): " + ipMatched); } return ipMatched; }  @Override void init(); @Override boolean isMatched(final RangerAccessRequest request);  }