@Test public void testIsMatched_happyPath() { RangerSampleSimpleMatcher ipMatcher = createMatcher(new String[]{"US", "C*"} ); Assert.assertTrue(ipMatcher.isMatched(createRequest("US"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("CA"))); Assert.assertTrue(ipMatcher.isMatched(createRequest("C---"))); Assert.assertFalse(ipMatcher.isMatched(createRequest(" US "))); Assert.assertFalse(ipMatcher.isMatched(createRequest("Us"))); Assert.assertFalse(ipMatcher.isMatched(createRequest("ca"))); }
@Override public boolean isMatched(RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerSampleSimpleMatcher.isMatched(" + request + ")"); } boolean matched = false; if (_allowAny) { matched = true; } else { String requestValue = extractValue(request, _contextName); if (StringUtils.isNotBlank(requestValue)) { for (String policyValue : _values) { if (FilenameUtils.wildcardMatch(requestValue, policyValue)) { matched = true; break; } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerSampleSimpleMatcher.isMatched(" + request+ "): " + matched); } return matched; }
RangerSampleSimpleMatcher extends RangerAbstractConditionEvaluator { @Override public boolean isMatched(RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerSampleSimpleMatcher.isMatched(" + request + ")"); } boolean matched = false; if (_allowAny) { matched = true; } else { String requestValue = extractValue(request, _contextName); if (StringUtils.isNotBlank(requestValue)) { for (String policyValue : _values) { if (FilenameUtils.wildcardMatch(requestValue, policyValue)) { matched = true; break; } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerSampleSimpleMatcher.isMatched(" + request+ "): " + matched); } return matched; } }
RangerSampleSimpleMatcher extends RangerAbstractConditionEvaluator { @Override public boolean isMatched(RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerSampleSimpleMatcher.isMatched(" + request + ")"); } boolean matched = false; if (_allowAny) { matched = true; } else { String requestValue = extractValue(request, _contextName); if (StringUtils.isNotBlank(requestValue)) { for (String policyValue : _values) { if (FilenameUtils.wildcardMatch(requestValue, policyValue)) { matched = true; break; } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerSampleSimpleMatcher.isMatched(" + request+ "): " + matched); } return matched; }  }
RangerSampleSimpleMatcher extends RangerAbstractConditionEvaluator { @Override public boolean isMatched(RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerSampleSimpleMatcher.isMatched(" + request + ")"); } boolean matched = false; if (_allowAny) { matched = true; } else { String requestValue = extractValue(request, _contextName); if (StringUtils.isNotBlank(requestValue)) { for (String policyValue : _values) { if (FilenameUtils.wildcardMatch(requestValue, policyValue)) { matched = true; break; } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerSampleSimpleMatcher.isMatched(" + request+ "): " + matched); } return matched; }  @Override void init(); @Override boolean isMatched(RangerAccessRequest request); }
RangerSampleSimpleMatcher extends RangerAbstractConditionEvaluator { @Override public boolean isMatched(RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerSampleSimpleMatcher.isMatched(" + request + ")"); } boolean matched = false; if (_allowAny) { matched = true; } else { String requestValue = extractValue(request, _contextName); if (StringUtils.isNotBlank(requestValue)) { for (String policyValue : _values) { if (FilenameUtils.wildcardMatch(requestValue, policyValue)) { matched = true; break; } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerSampleSimpleMatcher.isMatched(" + request+ "): " + matched); } return matched; }  @Override void init(); @Override boolean isMatched(RangerAccessRequest request); static final String CONTEXT_NAME; }