This is an automated email from the ASF dual-hosted git repository. pradeep pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push: new 0baf6a4 RANGER: 2574 Ranger Import of fails if policy type is not passed 0baf6a4 is described below commit 0baf6a4c9bc0a35c0d635fa6001c1a0842b20423 Author: mateenmansoori <ma3naus...@gmail.com> AuthorDate: Thu Sep 19 14:55:25 2019 +0530 RANGER: 2574 Ranger Import of fails if policy type is not passed Signed-off-by: Pradeep <prad...@apache.org> --- .../apache/ranger/service/RangerPolicyService.java | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java index 78954af..14ab451 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java @@ -195,19 +195,26 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range return trxLogList; } - public String restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(String fieldName, RangerPolicy vObj, - int action) { - String result = ""; + public String restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(String fieldName, RangerPolicy vObj) { + if (logger.isDebugEnabled()) { + logger.debug("==> RangerPolicyService( Field Name : (" + fieldName +") RangerPolicy : ("+ vObj + ")"); + } + String ret = ""; if (StringUtils.isNotBlank(fieldName) && StringUtils.equalsIgnoreCase(fieldName.trim(), POLICY_IS_DENY_ALL_ELSE_CLASS_FIELD_NAME) && vObj != null) { - - if (vObj.getPolicyType() == RangerPolicy.POLICY_TYPE_ROWFILTER - || vObj.getPolicyType() == RangerPolicy.POLICY_TYPE_DATAMASK) { - result = null; + Integer policyType = vObj.getPolicyType(); + if (policyType == null || policyType == RangerPolicy.POLICY_TYPE_ACCESS) { + return ret; + } else if (policyType == RangerPolicy.POLICY_TYPE_ROWFILTER + || policyType == RangerPolicy.POLICY_TYPE_DATAMASK) { + ret = null; } } - return result; + if (logger.isDebugEnabled()) { + logger.debug("<== RangerPolicyService( Field Name : (" + fieldName +") RangerPolicy : ("+ vObj + ") ret : ( "+ret+" )"); + } + return ret; } private XXTrxLog processFieldToCreateTrxLog(Field field, String objectName, RangerPolicy vObj, XXPolicy mObj, RangerPolicy oldPolicy, int action) { @@ -285,7 +292,7 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range } if (action == OPERATION_CREATE_CONTEXT) { - if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj, action) == null) { + if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj) == null) { return null; } if (stringUtil.isEmpty(value)) { @@ -294,13 +301,13 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range xTrxLog.setNewValue(value); actionString = actionCreate; } else if (action == OPERATION_DELETE_CONTEXT) { - if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj, action) == null) { + if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj) == null) { return null; } xTrxLog.setPreviousValue(value); actionString = actionDelete; } else if (action == OPERATION_UPDATE_CONTEXT) { - if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj, action) == null) { + if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj) == null) { return null; } actionString = actionUpdate; @@ -487,7 +494,7 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range xTrxLog.setNewValue(value); } else if (action == OPERATION_IMPORT_CREATE_CONTEXT) { - if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj, action) == null) { + if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj) == null) { return null; } if (stringUtil.isEmpty(value)) { @@ -496,7 +503,7 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range xTrxLog.setNewValue(value); actionString = actionImportCreate; } else if (action == OPERATION_IMPORT_DELETE_CONTEXT) { - if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj, action) == null) { + if(restrictIsDenyAllElseLogForMaskingAndRowfilterPolicy(fieldName, vObj) == null) { return null; } xTrxLog.setPreviousValue(value);