diff --git a/repository/src/main/java/org/apache/atlas/discovery/AtlasAuthorization.java b/repository/src/main/java/org/apache/atlas/discovery/AtlasAuthorization.java index 25bed2c365..8f264bb327 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/AtlasAuthorization.java +++ b/repository/src/main/java/org/apache/atlas/discovery/AtlasAuthorization.java @@ -322,18 +322,23 @@ private static boolean validateResourcesForCreateEntity(List resou //for tag based policy if ("tag".equals(resource)) { - if (entity.getClassifications() != null && !entity.getClassifications().isEmpty()) { - List assetTags = entity.getClassifications().stream().map(x -> x.getTypeName()).collect(Collectors.toList()); + if (entity.getClassifications() == null || entity.getClassifications().isEmpty()) { + //since entity does not have tags at all, it should not pass this evaluation + resourcesMatched = false; + break; + } - for (String assetTag : assetTags) { - Optional match = values.stream().filter(x -> assetTag.matches(x.replace("*", ".*"))).findFirst(); + List assetTags = entity.getClassifications().stream().map(x -> x.getTypeName()).collect(Collectors.toList()); - if (!match.isPresent()) { - resourcesMatched = false; - break; - } + for (String assetTag : assetTags) { + Optional match = values.stream().filter(x -> assetTag.matches(x.replace("*", ".*"))).findFirst(); + + if (!match.isPresent()) { + resourcesMatched = false; + break; } } + } }