use of org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef in project ranger by apache.
the class TestAssetREST method rangerServiceDef.
private RangerServiceDef rangerServiceDef() {
List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerPolicyConditionDef>();
List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerContextEnricherDef>();
List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
RangerServiceDef rangerServiceDef = new RangerServiceDef();
rangerServiceDef.setId(Id);
rangerServiceDef.setImplClass("RangerServiceHdfs");
rangerServiceDef.setLabel("HDFS Repository");
rangerServiceDef.setDescription("HDFS Repository");
rangerServiceDef.setRbKeyDescription(null);
rangerServiceDef.setUpdatedBy("Admin");
rangerServiceDef.setUpdateTime(new Date());
rangerServiceDef.setConfigs(configs);
rangerServiceDef.setResources(resources);
rangerServiceDef.setAccessTypes(accessTypes);
rangerServiceDef.setPolicyConditions(policyConditions);
rangerServiceDef.setContextEnrichers(contextEnrichers);
rangerServiceDef.setEnums(enums);
return rangerServiceDef;
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef in project ranger by apache.
the class TestPublicAPIsv2 method rangerServiceDef.
private RangerServiceDef rangerServiceDef() {
List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerPolicyConditionDef>();
List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerContextEnricherDef>();
List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
RangerServiceDef rangerServiceDef = new RangerServiceDef();
rangerServiceDef.setId(Id);
rangerServiceDef.setName("RangerServiceHdfs");
rangerServiceDef.setImplClass("RangerServiceHdfs");
rangerServiceDef.setLabel("HDFS Repository");
rangerServiceDef.setDescription("HDFS Repository");
rangerServiceDef.setRbKeyDescription(null);
rangerServiceDef.setUpdatedBy("Admin");
rangerServiceDef.setUpdateTime(new Date());
rangerServiceDef.setConfigs(configs);
rangerServiceDef.setResources(resources);
rangerServiceDef.setAccessTypes(accessTypes);
rangerServiceDef.setPolicyConditions(policyConditions);
rangerServiceDef.setContextEnrichers(contextEnrichers);
rangerServiceDef.setEnums(enums);
return rangerServiceDef;
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef in project ranger by apache.
the class ServiceDefUtil method normalizeDataMaskDef.
private static void normalizeDataMaskDef(RangerServiceDef serviceDef) {
if (serviceDef != null && serviceDef.getDataMaskDef() != null) {
List<RangerResourceDef> dataMaskResources = serviceDef.getDataMaskDef().getResources();
List<RangerAccessTypeDef> dataMaskAccessTypes = serviceDef.getDataMaskDef().getAccessTypes();
if (CollectionUtils.isNotEmpty(dataMaskResources)) {
List<RangerResourceDef> resources = serviceDef.getResources();
List<RangerResourceDef> processedDefs = new ArrayList<RangerResourceDef>(dataMaskResources.size());
for (RangerResourceDef dataMaskResource : dataMaskResources) {
RangerResourceDef processedDef = dataMaskResource;
for (RangerResourceDef resourceDef : resources) {
if (StringUtils.equals(resourceDef.getName(), dataMaskResource.getName())) {
processedDef = ServiceDefUtil.mergeResourceDef(resourceDef, dataMaskResource);
break;
}
}
processedDefs.add(processedDef);
}
serviceDef.getDataMaskDef().setResources(processedDefs);
}
if (CollectionUtils.isNotEmpty(dataMaskAccessTypes)) {
List<RangerAccessTypeDef> accessTypes = serviceDef.getAccessTypes();
List<RangerAccessTypeDef> processedDefs = new ArrayList<RangerAccessTypeDef>(accessTypes.size());
for (RangerAccessTypeDef dataMaskAccessType : dataMaskAccessTypes) {
RangerAccessTypeDef processedDef = dataMaskAccessType;
for (RangerAccessTypeDef accessType : accessTypes) {
if (StringUtils.equals(accessType.getName(), dataMaskAccessType.getName())) {
processedDef = ServiceDefUtil.mergeAccessTypeDef(accessType, dataMaskAccessType);
break;
}
}
processedDefs.add(processedDef);
}
serviceDef.getDataMaskDef().setAccessTypes(processedDefs);
}
}
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef in project ranger by apache.
the class ServiceDefUtil method normalizeRowFilterDef.
private static void normalizeRowFilterDef(RangerServiceDef serviceDef) {
if (serviceDef != null && serviceDef.getRowFilterDef() != null) {
List<RangerResourceDef> rowFilterResources = serviceDef.getRowFilterDef().getResources();
List<RangerAccessTypeDef> rowFilterAccessTypes = serviceDef.getRowFilterDef().getAccessTypes();
if (CollectionUtils.isNotEmpty(rowFilterResources)) {
List<RangerResourceDef> resources = serviceDef.getResources();
List<RangerResourceDef> processedDefs = new ArrayList<RangerResourceDef>(rowFilterResources.size());
for (RangerResourceDef rowFilterResource : rowFilterResources) {
RangerResourceDef processedDef = rowFilterResource;
for (RangerResourceDef resourceDef : resources) {
if (StringUtils.equals(resourceDef.getName(), rowFilterResource.getName())) {
processedDef = ServiceDefUtil.mergeResourceDef(resourceDef, rowFilterResource);
break;
}
}
processedDefs.add(processedDef);
}
serviceDef.getRowFilterDef().setResources(processedDefs);
}
if (CollectionUtils.isNotEmpty(rowFilterAccessTypes)) {
List<RangerAccessTypeDef> accessTypes = serviceDef.getAccessTypes();
List<RangerAccessTypeDef> processedDefs = new ArrayList<RangerAccessTypeDef>(accessTypes.size());
for (RangerAccessTypeDef rowFilterAccessType : rowFilterAccessTypes) {
RangerAccessTypeDef processedDef = rowFilterAccessType;
for (RangerAccessTypeDef accessType : accessTypes) {
if (StringUtils.equals(accessType.getName(), rowFilterAccessType.getName())) {
processedDef = ServiceDefUtil.mergeAccessTypeDef(accessType, rowFilterAccessType);
break;
}
}
processedDefs.add(processedDef);
}
serviceDef.getRowFilterDef().setAccessTypes(processedDefs);
}
}
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef in project ranger by apache.
the class TestServiceDBStore method rangerServiceDef.
private RangerServiceDef rangerServiceDef() {
List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
RangerServiceConfigDef serviceConfigDefObj = new RangerServiceConfigDef();
serviceConfigDefObj.setDefaultValue("xyz");
serviceConfigDefObj.setDescription("ServiceDef");
serviceConfigDefObj.setItemId(Id);
serviceConfigDefObj.setLabel("Username");
serviceConfigDefObj.setMandatory(true);
serviceConfigDefObj.setName("username");
serviceConfigDefObj.setRbKeyDescription(null);
serviceConfigDefObj.setRbKeyLabel(null);
serviceConfigDefObj.setRbKeyValidationMessage(null);
serviceConfigDefObj.setSubType(null);
configs.add(serviceConfigDefObj);
List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerPolicyConditionDef>();
List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerContextEnricherDef>();
List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
RangerServiceDef rangerServiceDef = new RangerServiceDef();
rangerServiceDef.setId(Id);
rangerServiceDef.setName("RangerServiceHdfs");
rangerServiceDef.setImplClass("RangerServiceHdfs");
rangerServiceDef.setLabel("HDFS Repository");
rangerServiceDef.setDescription("HDFS Repository");
rangerServiceDef.setRbKeyDescription(null);
rangerServiceDef.setUpdatedBy("Admin");
rangerServiceDef.setUpdateTime(new Date());
rangerServiceDef.setConfigs(configs);
rangerServiceDef.setResources(resources);
rangerServiceDef.setAccessTypes(accessTypes);
rangerServiceDef.setPolicyConditions(policyConditions);
rangerServiceDef.setContextEnrichers(contextEnrichers);
rangerServiceDef.setEnums(enums);
return rangerServiceDef;
}
Aggregations