From e259a583e8e7428b0e2fdaa404e256c2bc33b993 Mon Sep 17 00:00:00 2001 From: Nikhil P Bonte Date: Mon, 1 Apr 2024 16:16:35 +0530 Subject: [PATCH] Fix DaapVisibility policies --- .../CachePolicyTransformerImpl.java | 36 ++++++++++++++++++- .../repository/util/AccessControlUtils.java | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/auth-agents-common/src/main/java/org/apache/atlas/policytransformer/CachePolicyTransformerImpl.java b/auth-agents-common/src/main/java/org/apache/atlas/policytransformer/CachePolicyTransformerImpl.java index 41129bf085..66ca9f1e59 100644 --- a/auth-agents-common/src/main/java/org/apache/atlas/policytransformer/CachePolicyTransformerImpl.java +++ b/auth-agents-common/src/main/java/org/apache/atlas/policytransformer/CachePolicyTransformerImpl.java @@ -53,6 +53,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -71,6 +72,7 @@ import static org.apache.atlas.repository.util.AccessControlUtils.ATTR_POLICY_PRIORITY; import static org.apache.atlas.repository.util.AccessControlUtils.ATTR_POLICY_SERVICE_NAME; import static org.apache.atlas.repository.util.AccessControlUtils.ATTR_POLICY_SUB_CATEGORY; +import static org.apache.atlas.repository.util.AccessControlUtils.POLICY_CATEGORY_DATAMESH; import static org.apache.atlas.repository.util.AccessControlUtils.POLICY_CATEGORY_PERSONA; import static org.apache.atlas.repository.util.AccessControlUtils.POLICY_CATEGORY_PURPOSE; import static org.apache.atlas.repository.util.AccessControlUtils.getIsPolicyEnabled; @@ -239,6 +241,18 @@ private List transformAtlasPoliciesToRangerPolicies(List resources = getFinalResources(atlasPolicy); + + if (resources.containsKey("entity-classification")) { + RangerPolicyResource resource = new RangerPolicyResource(Arrays.asList("*"), false, false); + resources.put("entity-classification", resource); + } + + if (resources.containsKey("entity-type")) { + RangerPolicyResource resource = new RangerPolicyResource(Arrays.asList("*"), false, false); + resources.put("entity-type", resource); + } + + rangerPolicy.setResources(resources); + } + + private Map getFinalResources(AtlasEntityHeader atlasPolicy) { List atlasResources = (List) atlasPolicy.getAttribute("policyResources"); Map> resourceValuesMap = new HashMap<>(); @@ -285,7 +319,7 @@ private void setPolicyResources(RangerPolicy rangerPolicy, AtlasEntityHeader atl resources.put(key, resource); } - rangerPolicy.setResources(resources); + return resources; } private T getResourceAsObject(String resourceName, Class clazz) throws IOException { diff --git a/repository/src/main/java/org/apache/atlas/repository/util/AccessControlUtils.java b/repository/src/main/java/org/apache/atlas/repository/util/AccessControlUtils.java index f222d909b6..c58d07534f 100644 --- a/repository/src/main/java/org/apache/atlas/repository/util/AccessControlUtils.java +++ b/repository/src/main/java/org/apache/atlas/repository/util/AccessControlUtils.java @@ -101,6 +101,7 @@ public final class AccessControlUtils { public static final String POLICY_CATEGORY_PERSONA = "persona"; public static final String POLICY_CATEGORY_PURPOSE = "purpose"; + public static final String POLICY_CATEGORY_DATAMESH = "datamesh"; public static final String POLICY_CATEGORY_BOOTSTRAP = "bootstrap"; public static final String POLICY_SUB_CATEGORY_COLLECTION = "collection";