Search in sources :

Example 1 with PolicyACLSummary

use of org.apache.ranger.plugin.policyevaluator.RangerPolicyEvaluator.PolicyACLSummary in project ranger by apache.

the class RangerPolicyEngineImpl method updateRowFiltersFromPolicy.

private void updateRowFiltersFromPolicy(RangerPolicyEvaluator evaluator, Set<Long> policyIdForTemporalTags, RangerResourceACLs resourceACLs) {
    PolicyACLSummary aclSummary = evaluator.getPolicyACLSummary();
    if (aclSummary != null) {
        boolean isConditional = policyIdForTemporalTags.contains(evaluator.getId()) || evaluator.getValidityScheduleEvaluatorsCount() != 0;
        for (RowFilterResult rowFilterResult : aclSummary.getRowFilters()) {
            rowFilterResult = copyRowFilter(rowFilterResult);
            if (isConditional) {
                rowFilterResult.setIsConditional(true);
            }
            resourceACLs.getRowFilters().add(rowFilterResult);
        }
    }
}
Also used : PolicyACLSummary(org.apache.ranger.plugin.policyevaluator.RangerPolicyEvaluator.PolicyACLSummary) RowFilterResult(org.apache.ranger.plugin.policyengine.RangerResourceACLs.RowFilterResult)

Example 2 with PolicyACLSummary

use of org.apache.ranger.plugin.policyevaluator.RangerPolicyEvaluator.PolicyACLSummary in project ranger by apache.

the class RangerPolicyEngineImpl method updateFromPolicyACLs.

private void updateFromPolicyACLs(RangerPolicyEvaluator evaluator, Set<Long> policyIdForTemporalTags, RangerResourceACLs resourceACLs) {
    PolicyACLSummary aclSummary = evaluator.getPolicyACLSummary();
    if (aclSummary == null) {
        return;
    }
    boolean isConditional = policyIdForTemporalTags.contains(evaluator.getId()) || evaluator.getValidityScheduleEvaluatorsCount() != 0;
    for (Map.Entry<String, Map<String, PolicyACLSummary.AccessResult>> userAccessInfo : aclSummary.getUsersAccessInfo().entrySet()) {
        final String userName = userAccessInfo.getKey();
        for (Map.Entry<String, PolicyACLSummary.AccessResult> accessInfo : userAccessInfo.getValue().entrySet()) {
            Integer accessResult;
            if (isConditional) {
                accessResult = ACCESS_CONDITIONAL;
            } else {
                accessResult = accessInfo.getValue().getResult();
                if (accessResult.equals(RangerPolicyEvaluator.ACCESS_UNDETERMINED)) {
                    accessResult = RangerPolicyEvaluator.ACCESS_DENIED;
                }
            }
            RangerPolicy policy = evaluator.getPolicy();
            resourceACLs.setUserAccessInfo(userName, accessInfo.getKey(), accessResult, policy);
        }
    }
    for (Map.Entry<String, Map<String, PolicyACLSummary.AccessResult>> groupAccessInfo : aclSummary.getGroupsAccessInfo().entrySet()) {
        final String groupName = groupAccessInfo.getKey();
        for (Map.Entry<String, PolicyACLSummary.AccessResult> accessInfo : groupAccessInfo.getValue().entrySet()) {
            Integer accessResult;
            if (isConditional) {
                accessResult = ACCESS_CONDITIONAL;
            } else {
                accessResult = accessInfo.getValue().getResult();
                if (accessResult.equals(RangerPolicyEvaluator.ACCESS_UNDETERMINED)) {
                    accessResult = RangerPolicyEvaluator.ACCESS_DENIED;
                }
            }
            RangerPolicy policy = evaluator.getPolicy();
            resourceACLs.setGroupAccessInfo(groupName, accessInfo.getKey(), accessResult, policy);
        }
    }
    for (Map.Entry<String, Map<String, PolicyACLSummary.AccessResult>> roleAccessInfo : aclSummary.getRolesAccessInfo().entrySet()) {
        final String roleName = roleAccessInfo.getKey();
        for (Map.Entry<String, PolicyACLSummary.AccessResult> accessInfo : roleAccessInfo.getValue().entrySet()) {
            Integer accessResult;
            if (isConditional) {
                accessResult = ACCESS_CONDITIONAL;
            } else {
                accessResult = accessInfo.getValue().getResult();
                if (accessResult.equals(RangerPolicyEvaluator.ACCESS_UNDETERMINED)) {
                    accessResult = RangerPolicyEvaluator.ACCESS_DENIED;
                }
            }
            RangerPolicy policy = evaluator.getPolicy();
            resourceACLs.setRoleAccessInfo(roleName, accessInfo.getKey(), accessResult, policy);
        }
    }
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) PolicyACLSummary(org.apache.ranger.plugin.policyevaluator.RangerPolicyEvaluator.PolicyACLSummary) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with PolicyACLSummary

use of org.apache.ranger.plugin.policyevaluator.RangerPolicyEvaluator.PolicyACLSummary in project ranger by apache.

the class RangerPolicyEngineImpl method updateDataMasksFromPolicy.

private void updateDataMasksFromPolicy(RangerPolicyEvaluator evaluator, Set<Long> policyIdForTemporalTags, RangerResourceACLs resourceACLs) {
    PolicyACLSummary aclSummary = evaluator.getPolicyACLSummary();
    if (aclSummary != null) {
        boolean isConditional = policyIdForTemporalTags.contains(evaluator.getId()) || evaluator.getValidityScheduleEvaluatorsCount() != 0;
        for (DataMaskResult dataMaskResult : aclSummary.getDataMasks()) {
            dataMaskResult = copyDataMask(dataMaskResult);
            if (isConditional) {
                dataMaskResult.setIsConditional(true);
            }
            resourceACLs.getDataMasks().add(dataMaskResult);
        }
    }
}
Also used : PolicyACLSummary(org.apache.ranger.plugin.policyevaluator.RangerPolicyEvaluator.PolicyACLSummary) DataMaskResult(org.apache.ranger.plugin.policyengine.RangerResourceACLs.DataMaskResult)

Aggregations

PolicyACLSummary (org.apache.ranger.plugin.policyevaluator.RangerPolicyEvaluator.PolicyACLSummary)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)1 DataMaskResult (org.apache.ranger.plugin.policyengine.RangerResourceACLs.DataMaskResult)1 RowFilterResult (org.apache.ranger.plugin.policyengine.RangerResourceACLs.RowFilterResult)1