test_class.file: model/enforcers/src/test/java/org/eclipse/ditto/model/enforcers/tree/TreeBasedPolicyEnforcerTest.java
test_class.identifier: TreeBasedPolicyEnforcerTest
test_case.body: @Test
      public void tryToCreateInstanceWithNullPolicy() {
          assertThatExceptionOfType(NullPointerException.class)
                  .isThrownBy(() -> TreeBasedPolicyEnforcer.createInstance(null))
                  .withMessage("The %s must not be null!", "policy")
                  .withNoCause();
      }
test_case.class_method_signature: TreeBasedPolicyEnforcerTest.tryToCreateInstanceWithNullPolicy()
test_case.full_signature: @Test public void tryToCreateInstanceWithNullPolicy()
test_case.identifier: tryToCreateInstanceWithNullPolicy
test_case.invocations: withNoCause withMessage isThrownBy assertThatExceptionOfType createInstance
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void tryToCreateInstanceWithNullPolicy()
focal_class.declarator: ROOT_RESOURCE = "/"
focal_class.modifier: private static final
focal_class.original_string: private static final String ROOT_RESOURCE = "/";
focal_class.type: String
focal_class.var_name: ROOT_RESOURCE
focal_class.declarator: tree
focal_class.modifier: private final
focal_class.original_string: private final Map<String, PolicyTreeNode> tree;
focal_class.type: Map<String, PolicyTreeNode>
focal_class.var_name: tree
focal_class.file: model/enforcers/src/main/java/org/eclipse/ditto/model/enforcers/tree/TreeBasedPolicyEnforcer.java
focal_class.identifier: TreeBasedPolicyEnforcer
focal_class.interfaces: implements Enforcer
focal_class.class_method_signature: TreeBasedPolicyEnforcer.TreeBasedPolicyEnforcer(final Map<String, PolicyTreeNode> tree)
focal_class.full_signature: private  TreeBasedPolicyEnforcer(final Map<String, PolicyTreeNode> tree)
focal_class.identifier: TreeBasedPolicyEnforcer
focal_class.modifiers: private
focal_class.parameters: (final Map<String, PolicyTreeNode> tree)
focal_class.signature:  TreeBasedPolicyEnforcer(final Map<String, PolicyTreeNode> tree)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.createInstance(final Policy policy)
focal_class.full_signature: public static TreeBasedPolicyEnforcer createInstance(final Policy policy)
focal_class.identifier: createInstance
focal_class.modifiers: public static
focal_class.parameters: (final Policy policy)
focal_class.return: TreeBasedPolicyEnforcer
focal_class.signature: TreeBasedPolicyEnforcer createInstance(final Policy policy)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.addResourceSubTree(final ResourceNode parentNode, final Resource resource,
              final JsonPointer path)
focal_class.full_signature: private static void addResourceSubTree(final ResourceNode parentNode, final Resource resource,
              final JsonPointer path)
focal_class.identifier: addResourceSubTree
focal_class.modifiers: private static
focal_class.parameters: (final ResourceNode parentNode, final Resource resource,
              final JsonPointer path)
focal_class.return: void
focal_class.signature: void addResourceSubTree(final ResourceNode parentNode, final Resource resource,
              final JsonPointer path)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.mergePermissions(final Resource resource, final ResourceNode existingChild)
focal_class.full_signature: private static void mergePermissions(final Resource resource, final ResourceNode existingChild)
focal_class.identifier: mergePermissions
focal_class.modifiers: private static
focal_class.parameters: (final Resource resource, final ResourceNode existingChild)
focal_class.return: void
focal_class.signature: void mergePermissions(final Resource resource, final ResourceNode existingChild)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.hasUnrestrictedPermissions(final ResourceKey resourceKey,
              final AuthorizationContext authorizationContext, final Permissions permissions)
focal_class.full_signature: @Override public boolean hasUnrestrictedPermissions(final ResourceKey resourceKey,
              final AuthorizationContext authorizationContext, final Permissions permissions)
focal_class.identifier: hasUnrestrictedPermissions
focal_class.modifiers: @Override public
focal_class.parameters: (final ResourceKey resourceKey,
              final AuthorizationContext authorizationContext, final Permissions permissions)
focal_class.return: boolean
focal_class.signature: boolean hasUnrestrictedPermissions(final ResourceKey resourceKey,
              final AuthorizationContext authorizationContext, final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.checkPermissions(final Permissions permissions)
focal_class.full_signature: private static void checkPermissions(final Permissions permissions)
focal_class.identifier: checkPermissions
focal_class.modifiers: private static
focal_class.parameters: (final Permissions permissions)
focal_class.return: void
focal_class.signature: void checkPermissions(final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.createAbsoluteResourcePointer(final ResourceKey resourceKey)
focal_class.full_signature: private static JsonPointer createAbsoluteResourcePointer(final ResourceKey resourceKey)
focal_class.identifier: createAbsoluteResourcePointer
focal_class.modifiers: private static
focal_class.parameters: (final ResourceKey resourceKey)
focal_class.return: JsonPointer
focal_class.signature: JsonPointer createAbsoluteResourcePointer(final ResourceKey resourceKey)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.getAuthorizationSubjectIds(final AuthorizationContext authorizationContext)
focal_class.full_signature: private static Collection<String> getAuthorizationSubjectIds(final AuthorizationContext authorizationContext)
focal_class.identifier: getAuthorizationSubjectIds
focal_class.modifiers: private static
focal_class.parameters: (final AuthorizationContext authorizationContext)
focal_class.return: Collection<String>
focal_class.signature: Collection<String> getAuthorizationSubjectIds(final AuthorizationContext authorizationContext)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.visitTree(final Visitor<T> visitor)
focal_class.full_signature: private T visitTree(final Visitor<T> visitor)
focal_class.identifier: visitTree
focal_class.modifiers: private
focal_class.parameters: (final Visitor<T> visitor)
focal_class.return: T
focal_class.signature: T visitTree(final Visitor<T> visitor)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.getSubjectIdsWithPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.full_signature: @Override public EffectedSubjectIds getSubjectIdsWithPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.identifier: getSubjectIdsWithPermission
focal_class.modifiers: @Override public
focal_class.parameters: (final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.return: EffectedSubjectIds
focal_class.signature: EffectedSubjectIds getSubjectIdsWithPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.getSubjectsWithPermission(final ResourceKey resourceKey, final Permissions permissions)
focal_class.full_signature: @Override public EffectedSubjects getSubjectsWithPermission(final ResourceKey resourceKey, final Permissions permissions)
focal_class.identifier: getSubjectsWithPermission
focal_class.modifiers: @Override public
focal_class.parameters: (final ResourceKey resourceKey, final Permissions permissions)
focal_class.return: EffectedSubjects
focal_class.signature: EffectedSubjects getSubjectsWithPermission(final ResourceKey resourceKey, final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.checkResourceKey(final ResourceKey resourceKey)
focal_class.full_signature: private static void checkResourceKey(final ResourceKey resourceKey)
focal_class.identifier: checkResourceKey
focal_class.modifiers: private static
focal_class.parameters: (final ResourceKey resourceKey)
focal_class.return: void
focal_class.signature: void checkResourceKey(final ResourceKey resourceKey)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.getSubjectIdsWithPartialPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.full_signature: @Override public Set<String> getSubjectIdsWithPartialPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.identifier: getSubjectIdsWithPartialPermission
focal_class.modifiers: @Override public
focal_class.parameters: (final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.return: Set<String>
focal_class.signature: Set<String> getSubjectIdsWithPartialPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.getSubjectsWithPartialPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.full_signature: @Override public Set<AuthorizationSubject> getSubjectsWithPartialPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.identifier: getSubjectsWithPartialPermission
focal_class.modifiers: @Override public
focal_class.parameters: (final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.return: Set<AuthorizationSubject>
focal_class.signature: Set<AuthorizationSubject> getSubjectsWithPartialPermission(final ResourceKey resourceKey,
              final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.hasPartialPermissions(final ResourceKey resourceKey, final AuthorizationContext authorizationContext,
              final Permissions permissions)
focal_class.full_signature: @Override public boolean hasPartialPermissions(final ResourceKey resourceKey, final AuthorizationContext authorizationContext,
              final Permissions permissions)
focal_class.identifier: hasPartialPermissions
focal_class.modifiers: @Override public
focal_class.parameters: (final ResourceKey resourceKey, final AuthorizationContext authorizationContext,
              final Permissions permissions)
focal_class.return: boolean
focal_class.signature: boolean hasPartialPermissions(final ResourceKey resourceKey, final AuthorizationContext authorizationContext,
              final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.buildJsonView(
              final ResourceKey resourceKey,
              final Iterable<JsonField> jsonFields,
              final AuthorizationContext authorizationContext,
              final Permissions permissions)
focal_class.full_signature: @Override public JsonObject buildJsonView(
              final ResourceKey resourceKey,
              final Iterable<JsonField> jsonFields,
              final AuthorizationContext authorizationContext,
              final Permissions permissions)
focal_class.identifier: buildJsonView
focal_class.modifiers: @Override public
focal_class.parameters: (
              final ResourceKey resourceKey,
              final Iterable<JsonField> jsonFields,
              final AuthorizationContext authorizationContext,
              final Permissions permissions)
focal_class.return: JsonObject
focal_class.signature: JsonObject buildJsonView(
              final ResourceKey resourceKey,
              final Iterable<JsonField> jsonFields,
              final AuthorizationContext authorizationContext,
              final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.extractJsonPointers(final Collection<PointerAndPermission> resources)
focal_class.full_signature: private static Set<JsonPointer> extractJsonPointers(final Collection<PointerAndPermission> resources)
focal_class.identifier: extractJsonPointers
focal_class.modifiers: private static
focal_class.parameters: (final Collection<PointerAndPermission> resources)
focal_class.return: Set<JsonPointer>
focal_class.signature: Set<JsonPointer> extractJsonPointers(final Collection<PointerAndPermission> resources)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.class_method_signature: TreeBasedPolicyEnforcer.collectFlatPointers(final JsonPointer createdPointer, final JsonField field,
              final List<PointerAndValue> flattenedFields)
focal_class.full_signature: private static List<PointerAndValue> collectFlatPointers(final JsonPointer createdPointer, final JsonField field,
              final List<PointerAndValue> flattenedFields)
focal_class.identifier: collectFlatPointers
focal_class.modifiers: private static
focal_class.parameters: (final JsonPointer createdPointer, final JsonField field,
              final List<PointerAndValue> flattenedFields)
focal_class.return: List<PointerAndValue>
focal_class.signature: List<PointerAndValue> collectFlatPointers(final JsonPointer createdPointer, final JsonField field,
              final List<PointerAndValue> flattenedFields)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.filterEntries(
              final Collection<PointerAndValue> candidates,
              final Collection<JsonPointer> grantedResources,
              final Collection<JsonPointer> revokedResources,
              final JsonPointer resourcePath)
focal_class.full_signature: private static JsonObject filterEntries(
              final Collection<PointerAndValue> candidates,
              final Collection<JsonPointer> grantedResources,
              final Collection<JsonPointer> revokedResources,
              final JsonPointer resourcePath)
focal_class.identifier: filterEntries
focal_class.modifiers: private static
focal_class.parameters: (
              final Collection<PointerAndValue> candidates,
              final Collection<JsonPointer> grantedResources,
              final Collection<JsonPointer> revokedResources,
              final JsonPointer resourcePath)
focal_class.return: JsonObject
focal_class.signature: JsonObject filterEntries(
              final Collection<PointerAndValue> candidates,
              final Collection<JsonPointer> grantedResources,
              final Collection<JsonPointer> revokedResources,
              final JsonPointer resourcePath)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.getPrefixPointerOrThrow(final JsonPointer pointer, final int level)
focal_class.full_signature: private static JsonPointer getPrefixPointerOrThrow(final JsonPointer pointer, final int level)
focal_class.identifier: getPrefixPointerOrThrow
focal_class.modifiers: private static
focal_class.parameters: (final JsonPointer pointer, final int level)
focal_class.return: JsonPointer
focal_class.signature: JsonPointer getPrefixPointerOrThrow(final JsonPointer pointer, final int level)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.containsPrefixPointer(final JsonPointer prefix, final Collection<JsonPointer> resources)
focal_class.full_signature: private static boolean containsPrefixPointer(final JsonPointer prefix, final Collection<JsonPointer> resources)
focal_class.identifier: containsPrefixPointer
focal_class.modifiers: private static
focal_class.parameters: (final JsonPointer prefix, final Collection<JsonPointer> resources)
focal_class.return: boolean
focal_class.signature: boolean containsPrefixPointer(final JsonPointer prefix, final Collection<JsonPointer> resources)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.getGrantedAndRevokedSubResource(final JsonPointer resource,
              final String type,
              final Iterable<String> subjectIds,
              final Permissions permissions)
focal_class.full_signature: private EffectedResources getGrantedAndRevokedSubResource(final JsonPointer resource,
              final String type,
              final Iterable<String> subjectIds,
              final Permissions permissions)
focal_class.identifier: getGrantedAndRevokedSubResource
focal_class.modifiers: private
focal_class.parameters: (final JsonPointer resource,
              final String type,
              final Iterable<String> subjectIds,
              final Permissions permissions)
focal_class.return: EffectedResources
focal_class.signature: EffectedResources getGrantedAndRevokedSubResource(final JsonPointer resource,
              final String type,
              final Iterable<String> subjectIds,
              final Permissions permissions)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.removeDeeperRevokes(final JsonPointer resource,
              final Iterable<PointerAndPermission> grantedResources,
              final Collection<PointerAndPermission> revokedResources)
focal_class.full_signature: private static Set<PointerAndPermission> removeDeeperRevokes(final JsonPointer resource,
              final Iterable<PointerAndPermission> grantedResources,
              final Collection<PointerAndPermission> revokedResources)
focal_class.identifier: removeDeeperRevokes
focal_class.modifiers: private static
focal_class.parameters: (final JsonPointer resource,
              final Iterable<PointerAndPermission> grantedResources,
              final Collection<PointerAndPermission> revokedResources)
focal_class.return: Set<PointerAndPermission>
focal_class.signature: Set<PointerAndPermission> removeDeeperRevokes(final JsonPointer resource,
              final Iterable<PointerAndPermission> grantedResources,
              final Collection<PointerAndPermission> revokedResources)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.retainElements(final Collection<PointerAndPermission> grans1,
              final Collection<PointerAndPermission> grans2)
focal_class.full_signature: private static Set<PointerAndPermission> retainElements(final Collection<PointerAndPermission> grans1,
              final Collection<PointerAndPermission> grans2)
focal_class.identifier: retainElements
focal_class.modifiers: private static
focal_class.parameters: (final Collection<PointerAndPermission> grans1,
              final Collection<PointerAndPermission> grans2)
focal_class.return: Set<PointerAndPermission>
focal_class.signature: Set<PointerAndPermission> retainElements(final Collection<PointerAndPermission> grans1,
              final Collection<PointerAndPermission> grans2)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.checkPermissionOnAnySubResource(final JsonPointer resourcePath,
              final String resourceType,
              final Iterable<String> subjectIds,
              final String permission)
focal_class.full_signature: private EffectedResources checkPermissionOnAnySubResource(final JsonPointer resourcePath,
              final String resourceType,
              final Iterable<String> subjectIds,
              final String permission)
focal_class.identifier: checkPermissionOnAnySubResource
focal_class.modifiers: private
focal_class.parameters: (final JsonPointer resourcePath,
              final String resourceType,
              final Iterable<String> subjectIds,
              final String permission)
focal_class.return: EffectedResources
focal_class.signature: EffectedResources checkPermissionOnAnySubResource(final JsonPointer resourcePath,
              final String resourceType,
              final Iterable<String> subjectIds,
              final String permission)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.traverseSubtreeForPermissionAccess(final String permission,
              final JsonPointer resource,
              final String type,
              @Nullable final PolicyTreeNode policyTreeNode,
              final Set<PointerAndPermission> grantedResources,
              final Set<PointerAndPermission> revokedResources,
              final int level,
              final boolean followingResource)
focal_class.full_signature: private static void traverseSubtreeForPermissionAccess(final String permission,
              final JsonPointer resource,
              final String type,
              @Nullable final PolicyTreeNode policyTreeNode,
              final Set<PointerAndPermission> grantedResources,
              final Set<PointerAndPermission> revokedResources,
              final int level,
              final boolean followingResource)
focal_class.identifier: traverseSubtreeForPermissionAccess
focal_class.modifiers: private static
focal_class.parameters: (final String permission,
              final JsonPointer resource,
              final String type,
              @Nullable final PolicyTreeNode policyTreeNode,
              final Set<PointerAndPermission> grantedResources,
              final Set<PointerAndPermission> revokedResources,
              final int level,
              final boolean followingResource)
focal_class.return: void
focal_class.signature: void traverseSubtreeForPermissionAccess(final String permission,
              final JsonPointer resource,
              final String type,
              @Nullable final PolicyTreeNode policyTreeNode,
              final Set<PointerAndPermission> grantedResources,
              final Set<PointerAndPermission> revokedResources,
              final int level,
              final boolean followingResource)
focal_class.class_method_signature: TreeBasedPolicyEnforcer.addPermission(final String permission,
              final JsonPointer resource,
              final Collection<PointerAndPermission> grantedResources,
              final Collection<PointerAndPermission> revokedResources,
              final int level,
              final ResourceNode resourceNode)
focal_class.full_signature: private static void addPermission(final String permission,
              final JsonPointer resource,
              final Collection<PointerAndPermission> grantedResources,
              final Collection<PointerAndPermission> revokedResources,
              final int level,
              final ResourceNode resourceNode)
focal_class.identifier: addPermission
focal_class.modifiers: private static
focal_class.parameters: (final String permission,
              final JsonPointer resource,
              final Collection<PointerAndPermission> grantedResources,
              final Collection<PointerAndPermission> revokedResources,
              final int level,
              final ResourceNode resourceNode)
focal_class.return: void
focal_class.signature: void addPermission(final String permission,
              final JsonPointer resource,
              final Collection<PointerAndPermission> grantedResources,
              final Collection<PointerAndPermission> revokedResources,
              final int level,
              final ResourceNode resourceNode)
focal_method.body: public static TreeBasedPolicyEnforcer createInstance(final Policy policy) {
          checkNotNull(policy, "policy");
          final Map<String, PolicyTreeNode> tree = new HashMap<>();
  
          final Set<PolicyEntry> policyEntries = policy.getEntriesSet();
          policyEntries.forEach(policyEntry -> {
  
              final Subjects subjects = policyEntry.getSubjects();
              subjects.forEach(subject -> {
                  final SubjectId subjectId = subject.getId();
                  final String subjectIdString = subjectId.toString();
                  final PolicyTreeNode parentNode = tree.computeIfAbsent(subjectIdString, SubjectNode::of);
  
                  final Resources resources = policyEntry.getResources();
                  resources.forEach(resource -> {
                      final PolicyTreeNode rootChild = parentNode.computeIfAbsent(resource.getType(), t -> {
                          final Set<String> emptySet = Collections.emptySet();
                          return ResourceNode.of(parentNode, t, EffectedPermissions.newInstance(emptySet, emptySet));
                      });
                      addResourceSubTree((ResourceNode) rootChild, resource, resource.getPath());
                  });
              });
          });
  
          return new TreeBasedPolicyEnforcer(tree);
      }
focal_method.class_method_signature: TreeBasedPolicyEnforcer.createInstance(final Policy policy)
focal_method.full_signature: public static TreeBasedPolicyEnforcer createInstance(final Policy policy)
focal_method.identifier: createInstance
focal_method.invocations: checkNotNull getEntriesSet forEach getSubjects forEach getId toString computeIfAbsent getResources forEach computeIfAbsent getType emptySet of newInstance addResourceSubTree getPath
focal_method.modifiers: public static
focal_method.parameters: (final Policy policy)
focal_method.return: TreeBasedPolicyEnforcer
focal_method.signature: TreeBasedPolicyEnforcer createInstance(final Policy policy)