Java Code Examples for org.apache.ranger.plugin.model.RangerServiceDef#RangerDataMaskDef

The following examples show how to use org.apache.ranger.plugin.model.RangerServiceDef#RangerDataMaskDef . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractServiceStore.java    From ranger with Apache License 2.0 5 votes vote down vote up
private void updateTagServiceDefForDeletingDataMaskDef(RangerServiceDef tagServiceDef, String serviceDefName) {
	if (LOG.isDebugEnabled()) {
		LOG.debug("==> AbstractServiceStore.updateTagServiceDefForDeletingDataMaskDef(" + serviceDefName + ")");
	}
	RangerServiceDef.RangerDataMaskDef tagDataMaskDef = tagServiceDef.getDataMaskDef();

	if (tagDataMaskDef == null) {
		return;
	}

	String prefix = serviceDefName + COMPONENT_ACCESSTYPE_SEPARATOR;

	List<RangerServiceDef.RangerAccessTypeDef> accessTypes = new ArrayList<>();

	for (RangerServiceDef.RangerAccessTypeDef accessType : tagDataMaskDef.getAccessTypes()) {
		if (accessType.getName().startsWith(prefix)) {
			accessTypes.add(accessType);
		}
	}
	List<RangerServiceDef.RangerDataMaskTypeDef> maskTypes = new ArrayList<>();
	for (RangerServiceDef.RangerDataMaskTypeDef maskType : tagDataMaskDef.getMaskTypes()) {
		if (maskType.getName().startsWith(prefix)) {
			maskTypes.add(maskType);
		}
	}
	tagDataMaskDef.getAccessTypes().removeAll(accessTypes);
	tagDataMaskDef.getMaskTypes().removeAll(maskTypes);

	if (LOG.isDebugEnabled()) {
		LOG.debug("<== AbstractServiceStore.updateTagServiceDefForDeletingDataMaskDef(" + serviceDefName + ")");
	}
}
 
Example 2
Source File: PatchForTagServiceDefUpdate_J10028.java    From ranger with Apache License 2.0 4 votes vote down vote up
private boolean updateResourceInTagServiceDef(RangerServiceDef tagServiceDef) {
	if (logger.isDebugEnabled()) {
		logger.debug("==> PatchForTagServiceDefUpdate_J10028.updateResourceInTagServiceDef(" + tagServiceDef + ")");
	}
	boolean ret = false;

	final RangerServiceDef.RangerResourceDef accessPolicyTagResource = getResourceDefForTagResource(tagServiceDef.getResources());

	if (accessPolicyTagResource != null) {

		RangerServiceDef.RangerDataMaskDef dataMaskDef = tagServiceDef.getDataMaskDef();

		if (dataMaskDef != null) {
			if (CollectionUtils.isNotEmpty(dataMaskDef.getAccessTypes())) {
				addOrUpdateResourceDefForTagResource(dataMaskDef.getResources(), accessPolicyTagResource);
				ret = true;
			} else {
				if (CollectionUtils.isNotEmpty(dataMaskDef.getResources())) {
					dataMaskDef.setResources(null);
					ret = true;
				}
			}
		}

		RangerServiceDef.RangerRowFilterDef rowFilterDef = tagServiceDef.getRowFilterDef();

		if (rowFilterDef != null) {
			boolean autopropagateRowfilterdefToTag = config.getBoolean(AbstractServiceStore.AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP, AbstractServiceStore.AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP_DEFAULT);
			if (autopropagateRowfilterdefToTag) {
				if (CollectionUtils.isNotEmpty(rowFilterDef.getAccessTypes())) {
					addOrUpdateResourceDefForTagResource(rowFilterDef.getResources(), accessPolicyTagResource);
					ret = true;
				} else {
					if (CollectionUtils.isNotEmpty(rowFilterDef.getResources())) {
						rowFilterDef.setResources(null);
						ret = true;
					}
				}
			}
		}
	} else {
		logger.warn("Resource with name :[" + RangerServiceTag.TAG_RESOURCE_NAME + "] not found in  tag-service-definition!!");
	}

	if (logger.isDebugEnabled()) {
		logger.debug("<== PatchForTagServiceDefUpdate_J10028.updateResourceInTagServiceDef(" + tagServiceDef + ") : " + ret);
	}

	return ret;
}
 
Example 3
Source File: AbstractServiceStore.java    From ranger with Apache License 2.0 4 votes vote down vote up
private boolean updateResourceInTagServiceDef(RangerServiceDef tagServiceDef) throws Exception {
	if (LOG.isDebugEnabled()) {
		LOG.debug("==> AbstractServiceStore.updateResourceInTagServiceDef(" + tagServiceDef + ")");
	}
	boolean ret = false;

	final RangerServiceDef.RangerResourceDef accessPolicyTagResource = getResourceDefForTagResource(tagServiceDef.getResources());

	final List<RangerServiceDef.RangerResourceDef> resources = new ArrayList<>();

	if (accessPolicyTagResource == null) {
		LOG.warn("Resource with name :[" + RangerServiceTag.TAG_RESOURCE_NAME + "] not found in  tag-service-definition!!");
	} else {
		resources.add(accessPolicyTagResource);
	}

	RangerServiceDef.RangerDataMaskDef dataMaskDef = tagServiceDef.getDataMaskDef();

	if (dataMaskDef != null) {
		if (CollectionUtils.isNotEmpty(dataMaskDef.getAccessTypes())) {
			if (CollectionUtils.isEmpty(dataMaskDef.getResources())) {
				dataMaskDef.setResources(resources);
				ret = true;
			}
		} else {
			if (CollectionUtils.isNotEmpty(dataMaskDef.getResources())) {
				dataMaskDef.setResources(null);
				ret = true;
			}
		}
	}

	RangerServiceDef.RangerRowFilterDef rowFilterDef = tagServiceDef.getRowFilterDef();

	if (rowFilterDef != null) {
		boolean autopropagateRowfilterdefToTag = config.getBoolean(AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP, AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP_DEFAULT);
		if (autopropagateRowfilterdefToTag) {
			if (CollectionUtils.isNotEmpty(rowFilterDef.getAccessTypes())) {
				if (CollectionUtils.isEmpty(rowFilterDef.getResources())) {
					rowFilterDef.setResources(resources);
					ret = true;
				}
			} else {
				if (CollectionUtils.isNotEmpty(rowFilterDef.getResources())) {
					rowFilterDef.setResources(null);
					ret = true;
				}
			}
		}
	}

	if (LOG.isDebugEnabled()) {
		LOG.debug("<== AbstractServiceStore.updateResourceInTagServiceDef(" + tagServiceDef + ") : " + ret);
	}
	return ret;
}