Search in sources :

Example 1 with XXPolicyItemRowFilterInfo

use of org.apache.ranger.entity.XXPolicyItemRowFilterInfo in project ranger by apache.

the class ServiceDBStore method createNewRowFilterPolicyItemsForPolicy.

private void createNewRowFilterPolicyItemsForPolicy(RangerPolicy policy, XXPolicy xPolicy, List<RangerRowFilterPolicyItem> policyItems, XXServiceDef xServiceDef, int policyItemType) throws Exception {
    if (CollectionUtils.isNotEmpty(policyItems)) {
        for (int itemOrder = 0; itemOrder < policyItems.size(); itemOrder++) {
            RangerRowFilterPolicyItem policyItem = policyItems.get(itemOrder);
            XXPolicyItem xPolicyItem = createNewPolicyItemForPolicy(policy, xPolicy, policyItem, xServiceDef, itemOrder, policyItemType);
            RangerPolicyItemRowFilterInfo dataMaskInfo = policyItem.getRowFilterInfo();
            if (dataMaskInfo != null) {
                XXPolicyItemRowFilterInfo xxRowFilterInfo = new XXPolicyItemRowFilterInfo();
                xxRowFilterInfo.setPolicyItemId(xPolicyItem.getId());
                xxRowFilterInfo.setFilterExpr(dataMaskInfo.getFilterExpr());
                xxRowFilterInfo = daoMgr.getXXPolicyItemRowFilterInfo().create(xxRowFilterInfo);
            }
        }
    }
}
Also used : XXPolicyItem(org.apache.ranger.entity.XXPolicyItem) RangerRowFilterPolicyItem(org.apache.ranger.plugin.model.RangerPolicy.RangerRowFilterPolicyItem) RangerPolicyItemRowFilterInfo(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemRowFilterInfo) XXPolicyItemRowFilterInfo(org.apache.ranger.entity.XXPolicyItemRowFilterInfo)

Example 2 with XXPolicyItemRowFilterInfo

use of org.apache.ranger.entity.XXPolicyItemRowFilterInfo in project ranger by apache.

the class ServiceDBStore method deleteExistingPolicyItems.

private Boolean deleteExistingPolicyItems(RangerPolicy policy) {
    if (policy == null) {
        return false;
    }
    XXPolicyItemDao policyItemDao = daoMgr.getXXPolicyItem();
    List<XXPolicyItem> policyItems = policyItemDao.findByPolicyId(policy.getId());
    for (XXPolicyItem policyItem : policyItems) {
        Long polItemId = policyItem.getId();
        XXPolicyItemConditionDao polCondDao = daoMgr.getXXPolicyItemCondition();
        List<XXPolicyItemCondition> conditions = polCondDao.findByPolicyItemId(polItemId);
        for (XXPolicyItemCondition condition : conditions) {
            polCondDao.remove(condition);
        }
        XXPolicyItemGroupPermDao grpPermDao = daoMgr.getXXPolicyItemGroupPerm();
        List<XXPolicyItemGroupPerm> groups = grpPermDao.findByPolicyItemId(polItemId);
        for (XXPolicyItemGroupPerm group : groups) {
            grpPermDao.remove(group);
        }
        XXPolicyItemUserPermDao userPermDao = daoMgr.getXXPolicyItemUserPerm();
        List<XXPolicyItemUserPerm> users = userPermDao.findByPolicyItemId(polItemId);
        for (XXPolicyItemUserPerm user : users) {
            userPermDao.remove(user);
        }
        XXPolicyItemAccessDao polItemAccDao = daoMgr.getXXPolicyItemAccess();
        List<XXPolicyItemAccess> accesses = polItemAccDao.findByPolicyItemId(polItemId);
        for (XXPolicyItemAccess access : accesses) {
            polItemAccDao.remove(access);
        }
        XXPolicyItemDataMaskInfoDao polItemDataMaskInfoDao = daoMgr.getXXPolicyItemDataMaskInfo();
        List<XXPolicyItemDataMaskInfo> dataMaskInfos = polItemDataMaskInfoDao.findByPolicyItemId(polItemId);
        for (XXPolicyItemDataMaskInfo dataMaskInfo : dataMaskInfos) {
            polItemDataMaskInfoDao.remove(dataMaskInfo);
        }
        XXPolicyItemRowFilterInfoDao polItemRowFilterInfoDao = daoMgr.getXXPolicyItemRowFilterInfo();
        List<XXPolicyItemRowFilterInfo> rowFilterInfos = polItemRowFilterInfoDao.findByPolicyItemId(polItemId);
        for (XXPolicyItemRowFilterInfo rowFilterInfo : rowFilterInfos) {
            polItemRowFilterInfoDao.remove(rowFilterInfo);
        }
        policyItemDao.remove(policyItem);
    }
    return true;
}
Also used : XXPolicyItemGroupPerm(org.apache.ranger.entity.XXPolicyItemGroupPerm) XXPolicyItemConditionDao(org.apache.ranger.db.XXPolicyItemConditionDao) XXPolicyItemUserPermDao(org.apache.ranger.db.XXPolicyItemUserPermDao) XXPolicyItemUserPerm(org.apache.ranger.entity.XXPolicyItemUserPerm) XXPolicyItemGroupPermDao(org.apache.ranger.db.XXPolicyItemGroupPermDao) XXPolicyItemRowFilterInfo(org.apache.ranger.entity.XXPolicyItemRowFilterInfo) XXPolicyItemCondition(org.apache.ranger.entity.XXPolicyItemCondition) XXPolicyItemDataMaskInfo(org.apache.ranger.entity.XXPolicyItemDataMaskInfo) XXPolicyItemDao(org.apache.ranger.db.XXPolicyItemDao) XXPolicyItemDataMaskInfoDao(org.apache.ranger.db.XXPolicyItemDataMaskInfoDao) XXPolicyItem(org.apache.ranger.entity.XXPolicyItem) XXPolicyItemAccess(org.apache.ranger.entity.XXPolicyItemAccess) XXPolicyItemAccessDao(org.apache.ranger.db.XXPolicyItemAccessDao) XXPolicyItemRowFilterInfoDao(org.apache.ranger.db.XXPolicyItemRowFilterInfoDao)

Aggregations

XXPolicyItem (org.apache.ranger.entity.XXPolicyItem)2 XXPolicyItemRowFilterInfo (org.apache.ranger.entity.XXPolicyItemRowFilterInfo)2 XXPolicyItemAccessDao (org.apache.ranger.db.XXPolicyItemAccessDao)1 XXPolicyItemConditionDao (org.apache.ranger.db.XXPolicyItemConditionDao)1 XXPolicyItemDao (org.apache.ranger.db.XXPolicyItemDao)1 XXPolicyItemDataMaskInfoDao (org.apache.ranger.db.XXPolicyItemDataMaskInfoDao)1 XXPolicyItemGroupPermDao (org.apache.ranger.db.XXPolicyItemGroupPermDao)1 XXPolicyItemRowFilterInfoDao (org.apache.ranger.db.XXPolicyItemRowFilterInfoDao)1 XXPolicyItemUserPermDao (org.apache.ranger.db.XXPolicyItemUserPermDao)1 XXPolicyItemAccess (org.apache.ranger.entity.XXPolicyItemAccess)1 XXPolicyItemCondition (org.apache.ranger.entity.XXPolicyItemCondition)1 XXPolicyItemDataMaskInfo (org.apache.ranger.entity.XXPolicyItemDataMaskInfo)1 XXPolicyItemGroupPerm (org.apache.ranger.entity.XXPolicyItemGroupPerm)1 XXPolicyItemUserPerm (org.apache.ranger.entity.XXPolicyItemUserPerm)1 RangerPolicyItemRowFilterInfo (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemRowFilterInfo)1 RangerRowFilterPolicyItem (org.apache.ranger.plugin.model.RangerPolicy.RangerRowFilterPolicyItem)1