Search in sources :

Example 1 with RangerPolicyItemDataMaskInfo

use of org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo in project ranger by apache.

the class ServiceDBStore method writeCSVForPolicyItems.

private void writeCSVForPolicyItems(RangerPolicy policy, RangerPolicyItem policyItem, RangerDataMaskPolicyItem dataMaskPolicyItem, RangerRowFilterPolicyItem rowFilterPolicyItem, StringBuilder csvBuffer, String policyConditionType) {
    if (LOG.isDebugEnabled()) {
        // To avoid PMD violation
        LOG.debug("policyConditionType:[" + policyConditionType + "]");
    }
    final String COMMA_DELIMITER = "|";
    final String LINE_SEPARATOR = "\n";
    List<String> groups = new ArrayList<String>();
    List<String> users = new ArrayList<String>();
    String groupNames = "";
    String userNames = "";
    String policyLabelName = "";
    String accessType = "";
    String policyStatus = "";
    String policyType = "";
    Boolean delegateAdmin = false;
    String isRecursive = "";
    String isExcludes = "";
    String serviceName = "";
    String description = "";
    Boolean isAuditEnabled = true;
    String isExcludesValue = "";
    String maskingInfo = "";
    List<RangerPolicyItemAccess> accesses = new ArrayList<RangerPolicyItemAccess>();
    List<RangerPolicyItemCondition> conditionsList = new ArrayList<RangerPolicyItemCondition>();
    String conditionKeyValue = "";
    String resValue = "";
    String resourceKeyVal = "";
    String isRecursiveValue = "";
    String resKey = "";
    String ServiceType = "";
    String filterExpr = "";
    String policyName = "";
    List<String> policyLabels = new ArrayList<String>();
    String policyConditionTypeValue = "";
    serviceName = policy.getService();
    description = policy.getDescription();
    isAuditEnabled = policy.getIsAuditEnabled();
    policyLabels = policy.getPolicyLabels();
    StringBuffer sb = new StringBuffer();
    StringBuffer sbIsRecursive = new StringBuffer();
    StringBuffer sbIsExcludes = new StringBuffer();
    Map<String, RangerPolicyResource> resources = policy.getResources();
    RangerPolicyItemDataMaskInfo dataMaskInfo = new RangerPolicyItemDataMaskInfo();
    RangerPolicyItemRowFilterInfo filterInfo = new RangerPolicyItemRowFilterInfo();
    policyName = policy.getName();
    policyName = policyName.replace("|", "");
    if (resources != null) {
        for (Entry<String, RangerPolicyResource> resource : resources.entrySet()) {
            resKey = resource.getKey();
            RangerPolicyResource policyResource = resource.getValue();
            List<String> resvalueList = policyResource.getValues();
            isExcludes = policyResource.getIsExcludes().toString();
            isRecursive = policyResource.getIsRecursive().toString();
            resValue = resvalueList.toString();
            sb = sb.append(resourceKeyVal).append(" ").append(resKey).append("=").append(resValue);
            sbIsExcludes = sbIsExcludes.append(resourceKeyVal).append(" ").append(resKey).append("=[").append(isExcludes).append("]");
            sbIsRecursive = sbIsRecursive.append(resourceKeyVal).append(" ").append(resKey).append("=[").append(isRecursive).append("]");
        }
        isExcludesValue = sbIsExcludes.toString();
        isExcludesValue = isExcludesValue.substring(1);
        isRecursiveValue = sbIsRecursive.toString();
        isRecursiveValue = isRecursiveValue.substring(1);
        resourceKeyVal = sb.toString();
        resourceKeyVal = resourceKeyVal.substring(1);
        if (policyItem != null && dataMaskPolicyItem == null && rowFilterPolicyItem == null) {
            groups = policyItem.getGroups();
            users = policyItem.getUsers();
            accesses = policyItem.getAccesses();
            delegateAdmin = policyItem.getDelegateAdmin();
            conditionsList = policyItem.getConditions();
        } else if (dataMaskPolicyItem != null && policyItem == null && rowFilterPolicyItem == null) {
            groups = dataMaskPolicyItem.getGroups();
            users = dataMaskPolicyItem.getUsers();
            accesses = dataMaskPolicyItem.getAccesses();
            delegateAdmin = dataMaskPolicyItem.getDelegateAdmin();
            conditionsList = dataMaskPolicyItem.getConditions();
            dataMaskInfo = dataMaskPolicyItem.getDataMaskInfo();
            String dataMaskType = dataMaskInfo.getDataMaskType();
            String conditionExpr = dataMaskInfo.getConditionExpr();
            String valueExpr = dataMaskInfo.getValueExpr();
            maskingInfo = "dataMasktype=[" + dataMaskType + "]";
            if (conditionExpr != null && !conditionExpr.isEmpty() && valueExpr != null && !valueExpr.isEmpty()) {
                maskingInfo = maskingInfo + "; conditionExpr=[" + conditionExpr + "]";
            }
        } else if (rowFilterPolicyItem != null && policyItem == null && dataMaskPolicyItem == null) {
            groups = rowFilterPolicyItem.getGroups();
            users = rowFilterPolicyItem.getUsers();
            accesses = rowFilterPolicyItem.getAccesses();
            delegateAdmin = rowFilterPolicyItem.getDelegateAdmin();
            conditionsList = rowFilterPolicyItem.getConditions();
            filterInfo = rowFilterPolicyItem.getRowFilterInfo();
            filterExpr = filterInfo.getFilterExpr();
        }
        if (CollectionUtils.isNotEmpty(accesses)) {
            for (RangerPolicyItemAccess access : accesses) {
                accessType = accessType + access.getType().replace("#", "").replace("|", "") + "#";
            }
            accessType = accessType.substring(0, accessType.lastIndexOf("#"));
        }
        if (CollectionUtils.isNotEmpty(groups)) {
            for (String group : groups) {
                group = group.replace("|", "");
                group = group.replace("#", "");
                groupNames = groupNames + group + "#";
            }
            groupNames = groupNames.substring(0, groupNames.lastIndexOf("#"));
        }
        if (CollectionUtils.isNotEmpty(users)) {
            for (String user : users) {
                user = user.replace("|", "");
                user = user.replace("#", "");
                userNames = userNames + user + "#";
            }
            userNames = userNames.substring(0, userNames.lastIndexOf("#"));
        }
        String conditionValue = "";
        for (RangerPolicyItemCondition conditions : conditionsList) {
            String conditionType = conditions.getType();
            List<String> conditionList = conditions.getValues();
            conditionValue = conditionList.toString();
            conditionKeyValue = conditionType + "=" + conditionValue;
        }
        XXService xxservice = daoMgr.getXXService().findByName(policy.getService());
        if (xxservice != null) {
            Long ServiceId = xxservice.getType();
            XXServiceDef xxservDef = daoMgr.getXXServiceDef().getById(ServiceId);
            if (xxservDef != null) {
                ServiceType = xxservDef.getName();
            }
        }
    }
    if (policyConditionType != null) {
        policyConditionTypeValue = policyConditionType;
    }
    if (policyConditionType == null && ServiceType.equalsIgnoreCase("tag")) {
        policyConditionTypeValue = POLICY_ALLOW_INCLUDE;
    } else if (policyConditionType == null) {
        policyConditionTypeValue = "";
    }
    if (policy.getIsEnabled()) {
        policyStatus = "Enabled";
    } else {
        policyStatus = "Disabled";
    }
    int policyTypeInt = policy.getPolicyType();
    switch(policyTypeInt) {
        case RangerPolicy.POLICY_TYPE_ACCESS:
            policyType = POLICY_TYPE_ACCESS;
            break;
        case RangerPolicy.POLICY_TYPE_DATAMASK:
            policyType = POLICY_TYPE_DATAMASK;
            break;
        case RangerPolicy.POLICY_TYPE_ROWFILTER:
            policyType = POLICY_TYPE_ROWFILTER;
            break;
    }
    if (CollectionUtils.isNotEmpty(policyLabels)) {
        for (String policyLabel : policyLabels) {
            policyLabel = policyLabel.replace("|", "");
            policyLabel = policyLabel.replace("#", "");
            policyLabelName = policyLabelName + policyLabel + "#";
        }
        policyLabelName = policyLabelName.substring(0, policyLabelName.lastIndexOf("#"));
    }
    csvBuffer.append(policy.getId());
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(policyName);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(resourceKeyVal);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(groupNames);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(userNames);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(accessType.trim());
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(ServiceType);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(policyStatus);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(policyType);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(delegateAdmin.toString().toUpperCase());
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(isRecursiveValue);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(isExcludesValue);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(serviceName);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(description);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(isAuditEnabled.toString().toUpperCase());
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(conditionKeyValue.trim());
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(policyConditionTypeValue);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(maskingInfo);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(filterExpr);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(policyLabelName);
    csvBuffer.append(COMMA_DELIMITER);
    csvBuffer.append(LINE_SEPARATOR);
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) RangerPolicyResource(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource) ArrayList(java.util.ArrayList) VXString(org.apache.ranger.view.VXString) RangerPolicyItemAccess(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess) RangerPolicyItemRowFilterInfo(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemRowFilterInfo) RangerPolicyItemCondition(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemCondition) XXService(org.apache.ranger.entity.XXService) RangerPolicyItemDataMaskInfo(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo)

Example 2 with RangerPolicyItemDataMaskInfo

use of org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo in project ranger by apache.

the class RangerPolicyRepository method normalizeAndPrunePolicyItems.

private List<? extends RangerPolicy.RangerPolicyItem> normalizeAndPrunePolicyItems(List<? extends RangerPolicy.RangerPolicyItem> policyItems, final String componentType) {
    if (CollectionUtils.isNotEmpty(policyItems)) {
        final String prefix = componentType + AbstractServiceStore.COMPONENT_ACCESSTYPE_SEPARATOR;
        List<RangerPolicy.RangerPolicyItem> itemsToPrune = null;
        for (RangerPolicy.RangerPolicyItem policyItem : policyItems) {
            List<RangerPolicy.RangerPolicyItemAccess> policyItemAccesses = policyItem.getAccesses();
            if (CollectionUtils.isNotEmpty(policyItemAccesses)) {
                List<RangerPolicy.RangerPolicyItemAccess> accessesToPrune = null;
                for (RangerPolicy.RangerPolicyItemAccess access : policyItemAccesses) {
                    String accessType = access.getType();
                    if (StringUtils.startsWith(accessType, prefix)) {
                        String newAccessType = StringUtils.removeStart(accessType, prefix);
                        access.setType(newAccessType);
                    } else if (accessType.contains(AbstractServiceStore.COMPONENT_ACCESSTYPE_SEPARATOR)) {
                        if (accessesToPrune == null) {
                            accessesToPrune = new ArrayList<>();
                        }
                        accessesToPrune.add(access);
                    }
                }
                if (accessesToPrune != null) {
                    policyItemAccesses.removeAll(accessesToPrune);
                }
                if (policyItemAccesses.isEmpty() && !policyItem.getDelegateAdmin()) {
                    if (itemsToPrune == null) {
                        itemsToPrune = new ArrayList<>();
                    }
                    itemsToPrune.add(policyItem);
                    continue;
                }
            }
            if (policyItem instanceof RangerPolicy.RangerDataMaskPolicyItem) {
                RangerPolicyItemDataMaskInfo dataMaskInfo = ((RangerPolicy.RangerDataMaskPolicyItem) policyItem).getDataMaskInfo();
                String maskType = dataMaskInfo.getDataMaskType();
                if (StringUtils.startsWith(maskType, prefix)) {
                    dataMaskInfo.setDataMaskType(StringUtils.removeStart(maskType, prefix));
                } else if (maskType.contains(AbstractServiceStore.COMPONENT_ACCESSTYPE_SEPARATOR)) {
                    if (itemsToPrune == null) {
                        itemsToPrune = new ArrayList<>();
                    }
                    itemsToPrune.add(policyItem);
                }
            }
        }
        if (itemsToPrune != null) {
            policyItems.removeAll(itemsToPrune);
        }
    }
    return policyItems;
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) ArrayList(java.util.ArrayList) RangerPolicyItemDataMaskInfo(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo)

Example 3 with RangerPolicyItemDataMaskInfo

use of org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo in project ranger by apache.

the class ServiceDBStore method createNewDataMaskPolicyItemsForPolicy.

private void createNewDataMaskPolicyItemsForPolicy(RangerPolicy policy, XXPolicy xPolicy, List<RangerDataMaskPolicyItem> policyItems, XXServiceDef xServiceDef, int policyItemType) throws Exception {
    if (CollectionUtils.isNotEmpty(policyItems)) {
        for (int itemOrder = 0; itemOrder < policyItems.size(); itemOrder++) {
            RangerDataMaskPolicyItem policyItem = policyItems.get(itemOrder);
            XXPolicyItem xPolicyItem = createNewPolicyItemForPolicy(policy, xPolicy, policyItem, xServiceDef, itemOrder, policyItemType);
            RangerPolicyItemDataMaskInfo dataMaskInfo = policyItem.getDataMaskInfo();
            if (dataMaskInfo != null) {
                XXDataMaskTypeDef dataMaskDef = daoMgr.getXXDataMaskTypeDef().findByNameAndServiceId(dataMaskInfo.getDataMaskType(), xPolicy.getService());
                if (dataMaskDef == null) {
                    throw new Exception(dataMaskInfo.getDataMaskType() + ": is not a valid datamask-type. policy='" + policy.getName() + "' service='" + policy.getService() + "'");
                }
                XXPolicyItemDataMaskInfo xxDataMaskInfo = new XXPolicyItemDataMaskInfo();
                xxDataMaskInfo.setPolicyItemId(xPolicyItem.getId());
                xxDataMaskInfo.setType(dataMaskDef.getId());
                xxDataMaskInfo.setConditionExpr(dataMaskInfo.getConditionExpr());
                xxDataMaskInfo.setValueExpr(dataMaskInfo.getValueExpr());
                daoMgr.getXXPolicyItemDataMaskInfo().create(xxDataMaskInfo);
            }
        }
    }
}
Also used : XXPolicyItem(org.apache.ranger.entity.XXPolicyItem) XXDataMaskTypeDef(org.apache.ranger.entity.XXDataMaskTypeDef) RangerDataMaskPolicyItem(org.apache.ranger.plugin.model.RangerPolicy.RangerDataMaskPolicyItem) RangerPolicyItemDataMaskInfo(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) JSONException(org.codehaus.jettison.json.JSONException) XXPolicyItemDataMaskInfo(org.apache.ranger.entity.XXPolicyItemDataMaskInfo)

Example 4 with RangerPolicyItemDataMaskInfo

use of org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo in project ranger by apache.

the class ServiceDBStore method writeBookForPolicyItems.

private void writeBookForPolicyItems(RangerPolicy policy, RangerPolicyItem policyItem, RangerDataMaskPolicyItem dataMaskPolicyItem, RangerRowFilterPolicyItem rowFilterPolicyItem, Row row, String policyConditionType) {
    if (LOG.isDebugEnabled()) {
        // To avoid PMD violation
        LOG.debug("policyConditionType:[" + policyConditionType + "]");
    }
    List<String> groups = new ArrayList<String>();
    List<String> users = new ArrayList<String>();
    String groupNames = "";
    String policyConditionTypeValue = "";
    String userNames = "";
    String policyLabelNames = "";
    String accessType = "";
    String policyStatus = "";
    String policyType = "";
    Boolean delegateAdmin = false;
    String isRecursive = "";
    String isExcludes = "";
    String serviceName = "";
    String description = "";
    Boolean isAuditEnabled = true;
    isAuditEnabled = policy.getIsAuditEnabled();
    String isExcludesValue = "";
    Cell cell = row.createCell(0);
    cell.setCellValue(policy.getId());
    List<RangerPolicyItemAccess> accesses = new ArrayList<RangerPolicyItemAccess>();
    List<RangerPolicyItemCondition> conditionsList = new ArrayList<RangerPolicyItemCondition>();
    String conditionKeyValue = "";
    List<String> policyLabels = new ArrayList<String>();
    String resValue = "";
    String resourceKeyVal = "";
    String isRecursiveValue = "";
    String resKey = "";
    StringBuffer sb = new StringBuffer();
    StringBuffer sbIsRecursive = new StringBuffer();
    StringBuffer sbIsExcludes = new StringBuffer();
    Map<String, RangerPolicyResource> resources = policy.getResources();
    RangerPolicyItemDataMaskInfo dataMaskInfo = new RangerPolicyItemDataMaskInfo();
    RangerPolicyItemRowFilterInfo filterInfo = new RangerPolicyItemRowFilterInfo();
    cell = row.createCell(1);
    cell.setCellValue(policy.getName());
    cell = row.createCell(2);
    if (resources != null) {
        for (Entry<String, RangerPolicyResource> resource : resources.entrySet()) {
            resKey = resource.getKey();
            RangerPolicyResource policyResource = resource.getValue();
            List<String> resvalueList = policyResource.getValues();
            isExcludes = policyResource.getIsExcludes().toString();
            isRecursive = policyResource.getIsRecursive().toString();
            resValue = resvalueList.toString();
            sb = sb.append(resourceKeyVal).append("; ").append(resKey).append("=").append(resValue);
            sbIsExcludes = sbIsExcludes.append(resourceKeyVal).append("; ").append(resKey).append("=[").append(isExcludes).append("]");
            sbIsRecursive = sbIsRecursive.append(resourceKeyVal).append("; ").append(resKey).append("=[").append(isRecursive).append("]");
        }
        isExcludesValue = sbIsExcludes.toString();
        isExcludesValue = isExcludesValue.substring(1);
        isRecursiveValue = sbIsRecursive.toString();
        isRecursiveValue = isRecursiveValue.substring(1);
        resourceKeyVal = sb.toString();
        resourceKeyVal = resourceKeyVal.substring(1);
        cell.setCellValue(resourceKeyVal);
        if (policyItem != null && dataMaskPolicyItem == null && rowFilterPolicyItem == null) {
            groups = policyItem.getGroups();
            users = policyItem.getUsers();
            accesses = policyItem.getAccesses();
            delegateAdmin = policyItem.getDelegateAdmin();
            conditionsList = policyItem.getConditions();
        } else if (dataMaskPolicyItem != null && policyItem == null && rowFilterPolicyItem == null) {
            groups = dataMaskPolicyItem.getGroups();
            users = dataMaskPolicyItem.getUsers();
            accesses = dataMaskPolicyItem.getAccesses();
            delegateAdmin = dataMaskPolicyItem.getDelegateAdmin();
            conditionsList = dataMaskPolicyItem.getConditions();
            dataMaskInfo = dataMaskPolicyItem.getDataMaskInfo();
            String dataMaskType = dataMaskInfo.getDataMaskType();
            String conditionExpr = dataMaskInfo.getConditionExpr();
            String valueExpr = dataMaskInfo.getValueExpr();
            String maskingInfo = "dataMasktype=[" + dataMaskType + "]";
            if (conditionExpr != null && !conditionExpr.isEmpty() && valueExpr != null && !valueExpr.isEmpty()) {
                maskingInfo = maskingInfo + "; conditionExpr=[" + conditionExpr + "]";
            }
            cell = row.createCell(17);
            cell.setCellValue(maskingInfo);
        } else if (rowFilterPolicyItem != null && policyItem == null && dataMaskPolicyItem == null) {
            groups = rowFilterPolicyItem.getGroups();
            users = rowFilterPolicyItem.getUsers();
            accesses = rowFilterPolicyItem.getAccesses();
            delegateAdmin = rowFilterPolicyItem.getDelegateAdmin();
            conditionsList = rowFilterPolicyItem.getConditions();
            filterInfo = rowFilterPolicyItem.getRowFilterInfo();
            String filterExpr = filterInfo.getFilterExpr();
            cell = row.createCell(18);
            cell.setCellValue(filterExpr);
        }
        if (CollectionUtils.isNotEmpty(accesses)) {
            for (RangerPolicyItemAccess access : accesses) {
                accessType = accessType + access.getType();
                accessType = accessType + " ,";
            }
            accessType = accessType.substring(0, accessType.lastIndexOf(","));
        }
        if (CollectionUtils.isNotEmpty(groups)) {
            groupNames = groupNames + groups.toString();
            StringTokenizer groupToken = new StringTokenizer(groupNames, "[]");
            groupNames = groupToken.nextToken().toString();
        }
        if (CollectionUtils.isNotEmpty(users)) {
            userNames = userNames + users.toString();
            StringTokenizer userToken = new StringTokenizer(userNames, "[]");
            userNames = userToken.nextToken().toString();
        }
        String conditionValue = "";
        for (RangerPolicyItemCondition conditions : conditionsList) {
            String conditionType = conditions.getType();
            List<String> conditionList = conditions.getValues();
            conditionValue = conditionList.toString();
            conditionKeyValue = conditionType + "=" + conditionValue;
        }
        cell = row.createCell(3);
        cell.setCellValue(groupNames);
        cell = row.createCell(4);
        cell.setCellValue(userNames);
        cell = row.createCell(5);
        cell.setCellValue(accessType.trim());
        cell = row.createCell(6);
        XXService xxservice = daoMgr.getXXService().findByName(policy.getService());
        String ServiceType = "";
        if (xxservice != null) {
            Long ServiceId = xxservice.getType();
            XXServiceDef xxservDef = daoMgr.getXXServiceDef().getById(ServiceId);
            if (xxservDef != null) {
                ServiceType = xxservDef.getName();
            }
        }
        if (policyConditionType != null) {
            policyConditionTypeValue = policyConditionType;
        }
        if (policyConditionType == null && ServiceType.equalsIgnoreCase("tag")) {
            policyConditionTypeValue = POLICY_ALLOW_INCLUDE;
        } else if (policyConditionType == null) {
            policyConditionTypeValue = "";
        }
        cell.setCellValue(ServiceType);
        cell = row.createCell(7);
    }
    if (policy.getIsEnabled()) {
        policyStatus = "Enabled";
    } else {
        policyStatus = "Disabled";
    }
    policyLabels = policy.getPolicyLabels();
    if (CollectionUtils.isNotEmpty(policyLabels)) {
        policyLabelNames = policyLabelNames + policyLabels.toString();
        StringTokenizer policyLabelToken = new StringTokenizer(policyLabelNames, "[]");
        policyLabelNames = policyLabelToken.nextToken().toString();
    }
    cell.setCellValue(policyStatus);
    cell = row.createCell(8);
    int policyTypeInt = policy.getPolicyType();
    switch(policyTypeInt) {
        case RangerPolicy.POLICY_TYPE_ACCESS:
            policyType = POLICY_TYPE_ACCESS;
            break;
        case RangerPolicy.POLICY_TYPE_DATAMASK:
            policyType = POLICY_TYPE_DATAMASK;
            break;
        case RangerPolicy.POLICY_TYPE_ROWFILTER:
            policyType = POLICY_TYPE_ROWFILTER;
            break;
    }
    cell.setCellValue(policyType);
    cell = row.createCell(9);
    cell.setCellValue(delegateAdmin.toString().toUpperCase());
    cell = row.createCell(10);
    cell.setCellValue(isRecursiveValue);
    cell = row.createCell(11);
    cell.setCellValue(isExcludesValue);
    cell = row.createCell(12);
    serviceName = policy.getService();
    cell.setCellValue(serviceName);
    cell = row.createCell(13);
    description = policy.getDescription();
    cell.setCellValue(description);
    cell = row.createCell(14);
    cell.setCellValue(isAuditEnabled.toString().toUpperCase());
    cell = row.createCell(15);
    cell.setCellValue(conditionKeyValue.trim());
    cell = row.createCell(16);
    cell.setCellValue(policyConditionTypeValue);
    cell = row.createCell(19);
    cell.setCellValue(policyLabelNames);
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) RangerPolicyResource(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource) ArrayList(java.util.ArrayList) VXString(org.apache.ranger.view.VXString) StringTokenizer(java.util.StringTokenizer) RangerPolicyItemAccess(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess) RangerPolicyItemRowFilterInfo(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemRowFilterInfo) RangerPolicyItemCondition(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemCondition) XXService(org.apache.ranger.entity.XXService) Cell(org.apache.poi.ss.usermodel.Cell) RangerPolicyItemDataMaskInfo(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo)

Example 5 with RangerPolicyItemDataMaskInfo

use of org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo in project ranger by apache.

the class RangerDefaultDataMaskPolicyItemEvaluator method updateAccessResult.

@Override
public void updateAccessResult(RangerAccessResult result, RangerPolicyResourceMatcher.MatchType matchType, RangerPolicy policy) {
    RangerPolicyItemDataMaskInfo dataMaskInfo = getDataMaskInfo();
    if (dataMaskInfo != null) {
        result.setIsAllowed(true);
        result.setIsAccessDetermined(true);
        result.setMaskType(dataMaskInfo.getDataMaskType());
        result.setMaskCondition(dataMaskInfo.getConditionExpr());
        result.setMaskedValue(dataMaskInfo.getValueExpr());
        result.setPolicyPriority(policy.getPolicyPriority());
        result.setPolicyId(policyId);
    }
}
Also used : RangerPolicyItemDataMaskInfo(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo)

Aggregations

RangerPolicyItemDataMaskInfo (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo)5 ArrayList (java.util.ArrayList)3 XXService (org.apache.ranger.entity.XXService)2 XXServiceDef (org.apache.ranger.entity.XXServiceDef)2 RangerPolicyItemAccess (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess)2 RangerPolicyItemCondition (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemCondition)2 RangerPolicyItemRowFilterInfo (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemRowFilterInfo)2 RangerPolicyResource (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource)2 VXString (org.apache.ranger.view.VXString)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 StringTokenizer (java.util.StringTokenizer)1 Cell (org.apache.poi.ss.usermodel.Cell)1 XXDataMaskTypeDef (org.apache.ranger.entity.XXDataMaskTypeDef)1 XXPolicyItem (org.apache.ranger.entity.XXPolicyItem)1 XXPolicyItemDataMaskInfo (org.apache.ranger.entity.XXPolicyItemDataMaskInfo)1 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)1 RangerDataMaskPolicyItem (org.apache.ranger.plugin.model.RangerPolicy.RangerDataMaskPolicyItem)1 JSONException (org.codehaus.jettison.json.JSONException)1