@@ -1074,49 +1074,48 @@ private void updateFromGdsResult(RangerAccessResult result) {
10741074 if (result .getPolicyType () == RangerPolicy .POLICY_TYPE_ACCESS ) {
10751075 // pick access result from GDS policies only if there is no decision yet
10761076 if (!result .getIsAccessDetermined () && gdsResult .getIsAllowed ()) {
1077- result .setIsAllowed (true );
1078- result .setIsAccessDetermined (true );
1079- result .setPolicyId (gdsResult .getPolicyId ());
1080- result .setPolicyVersion (gdsResult .getPolicyVersion ());
1081- result .setPolicyPriority (RangerPolicy .POLICY_PRIORITY_NORMAL );
1077+ copyFromGdsResult (gdsResult , result );
10821078 }
10831079 } else if (result .getPolicyType () == RangerPolicy .POLICY_TYPE_ROWFILTER ) {
10841080 // pick row-filter from GDS policies only if there is no decision yet
10851081 if (result .getPolicyId () == -1 && CollectionUtils .isNotEmpty (gdsResult .getRowFilters ())) {
1086- result .setIsAllowed (true );
1087- result .setIsAccessDetermined (true );
1088- result .setPolicyId (gdsResult .getPolicyId ());
1089- result .setPolicyVersion (gdsResult .getPolicyVersion ());
1090- result .setPolicyPriority (RangerPolicy .POLICY_PRIORITY_NORMAL );
1082+ copyFromGdsResult (gdsResult , result );
1083+
10911084 result .setFilterExpr (gdsResult .getRowFilters ().get (0 ));
10921085 }
10931086 } else if (result .getPolicyType () == RangerPolicy .POLICY_TYPE_DATAMASK ) {
10941087 // pick data-mask from GDS policies only if there is no decision yet
10951088 if (result .getPolicyId () == -1 && StringUtils .isNotEmpty (gdsResult .getMaskType ())) {
1096- result .setIsAllowed (true );
1097- result .setIsAccessDetermined (true );
1098- result .setPolicyId (gdsResult .getPolicyId ());
1099- result .setPolicyVersion (gdsResult .getPolicyVersion ());
1100- result .setPolicyPriority (RangerPolicy .POLICY_PRIORITY_NORMAL );
1089+ copyFromGdsResult (gdsResult , result );
1090+
11011091 result .setMaskType (gdsResult .getMaskType ());
11021092 result .setMaskedValue (gdsResult .getMaskedValue ());
11031093 result .setMaskCondition (gdsResult .getMaskCondition ());
11041094 }
11051095 }
1106-
1107- if (!result .getIsAuditedDetermined () && gdsResult .getIsAudited ()) {
1108- result .setIsAudited (true );
1109- }
1110-
1111- result .setDatasets (gdsResult .getDatasets ());
1112- result .setProjects (gdsResult .getProjects ());
11131096 } else {
11141097 LOG .debug ("updateFromGdsResult(): no GdsAccessResult found in request context({})" , request );
11151098 }
11161099
11171100 LOG .debug ("<== updateFromGdsResult(result={})" , result );
11181101 }
11191102
1103+ private void copyFromGdsResult (GdsAccessResult gdsResult , RangerAccessResult result ) {
1104+ if (gdsResult != null && result != null ) {
1105+ result .setIsAllowed (true );
1106+ result .setIsAccessDetermined (true );
1107+ result .setPolicyId (gdsResult .getPolicyId ());
1108+ result .setPolicyVersion (gdsResult .getPolicyVersion ());
1109+ result .setPolicyPriority (RangerPolicy .POLICY_PRIORITY_NORMAL );
1110+ result .setDatasets (gdsResult .getDatasets ());
1111+ result .setProjects (gdsResult .getProjects ());
1112+
1113+ if (!result .getIsAuditedDetermined () && gdsResult .getIsAudited ()) {
1114+ result .setIsAudited (true );
1115+ }
1116+ }
1117+ }
1118+
11201119 private static class ServiceConfig {
11211120 private final Set <String > auditExcludedUsers ;
11221121 private final Set <String > auditExcludedGroups ;
0 commit comments