use of org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher in project ranger by apache.
the class RangerDefaultPolicyResourceMatcher method createResourceMatcher.
private static RangerResourceMatcher createResourceMatcher(RangerResourceDef resourceDef, RangerPolicyResource resource) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> RangerDefaultPolicyResourceMatcher.createResourceMatcher(" + resourceDef + ", " + resource + ")");
}
RangerResourceMatcher ret = null;
if (resourceDef != null) {
String resName = resourceDef.getName();
String clsName = resourceDef.getMatcher();
if (!StringUtils.isEmpty(clsName)) {
try {
@SuppressWarnings("unchecked") Class<RangerResourceMatcher> matcherClass = (Class<RangerResourceMatcher>) Class.forName(clsName);
ret = matcherClass.newInstance();
} catch (Exception excp) {
LOG.error("failed to instantiate resource matcher '" + clsName + "' for '" + resName + "'. Default resource matcher will be used", excp);
}
}
if (ret == null) {
ret = new RangerDefaultResourceMatcher();
}
ret.setResourceDef(resourceDef);
ret.setPolicyResource(resource);
ret.init();
} else {
LOG.error("RangerDefaultPolicyResourceMatcher: RangerResourceDef is null");
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== RangerDefaultPolicyResourceMatcher.createResourceMatcher(" + resourceDef + ", " + resource + "): " + ret);
}
return ret;
}
Aggregations