Search in sources :

Example 6 with RangerAccessTypeDef

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;
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) ArrayList(java.util.ArrayList) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) RangerPolicyConditionDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef) Date(java.util.Date) RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) RangerContextEnricherDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Example 7 with RangerAccessTypeDef

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;
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) ArrayList(java.util.ArrayList) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) RangerPolicyConditionDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef) Date(java.util.Date) RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) RangerContextEnricherDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Example 8 with RangerAccessTypeDef

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);
        }
    }
}
Also used : RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) ArrayList(java.util.ArrayList) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Example 9 with RangerAccessTypeDef

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);
        }
    }
}
Also used : RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) ArrayList(java.util.ArrayList) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Example 10 with RangerAccessTypeDef

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;
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) ArrayList(java.util.ArrayList) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) RangerPolicyConditionDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef) Date(java.util.Date) RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) RangerContextEnricherDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Aggregations

RangerAccessTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef)33 ArrayList (java.util.ArrayList)22 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)17 RangerResourceDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)13 RangerContextEnricherDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef)11 RangerEnumDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef)11 RangerPolicyConditionDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef)11 RangerServiceConfigDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef)11 Date (java.util.Date)10 Test (org.junit.Test)9 XXServiceDef (org.apache.ranger.entity.XXServiceDef)8 VXString (org.apache.ranger.view.VXString)7 HashSet (java.util.HashSet)6 XXAccessTypeDef (org.apache.ranger.entity.XXAccessTypeDef)5 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)5 XXServiceDao (org.apache.ranger.db.XXServiceDao)4 XXServiceDefDao (org.apache.ranger.db.XXServiceDefDao)4 XXService (org.apache.ranger.entity.XXService)4 RangerDataMaskDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerDataMaskDef)3 RangerDataMaskTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerDataMaskTypeDef)3