class NodeDefinitionCollection(backingCollection: Map<KClass<out Node>, NodeDefinition>, val beanFactory: BeanFactory, val configurationProperties: GraphglueCoreConfigurationProperties) : Collection<NodeDefinition>

Stores a collection of NodeDefinitions Also handles generation and storage of authorization conditions

Parameters

backingCollection

the provided list of NodeDefinitions

beanFactory

used to get condition defining beans for authorization

configurationProperties

configuration properties for Graphglue core

Constructors

Link copied to clipboard
constructor(backingCollection: Map<KClass<out Node>, NodeDefinition>, beanFactory: BeanFactory, configurationProperties: GraphglueCoreConfigurationProperties)

Properties

Link copied to clipboard

Set of all known authorization names Used to detect misspelled authorization names

Link copied to clipboard

For each authorization name, all NodeDefinitions that are always allowed

Link copied to clipboard

For each authorization name and NodeDefinition, the list of allow rules to check

Link copied to clipboard

Lookup for disallow rules by authorization name

Link copied to clipboard

Defensive copy of provided backingCollection, used to store NodeDefinitions

Link copied to clipboard
private val beanFactory: BeanFactory
Link copied to clipboard

NodeDefinitions by GraphQL name lookup

Link copied to clipboard

Associates each NodeDefinition with all sub-NodeDefinitions and super-NodeDefinitions

Link copied to clipboard
open override val size: Int
Link copied to clipboard

Lookup from set of all subtype GraphQL names to common parent type NodeDefinition Can be used to generate Cypher queries and conditions more efficiently by not having to check for multiple different labels, but only for a common label Keys contain only GraphQL names of NodeDefinitions which are object types in the schema (no interfaces)

Functions

Link copied to clipboard
private fun checkIfRelationIsAllowed(relationshipDefinition: RelationshipDefinition, authorizationName: String): Boolean

Checks if a relation is allowed. A relation is allowed if allow on the parent side of the relation implies allow on the remote side of the relation. Can be used to improve authorization checking when fetching nested data structures. Allow is implied if the inverse relation (if existing) is allowed from related or if this is a one-side and allows from the related side (and has no other allow rules, neither other allow from related nor allow rules).

Link copied to clipboard
open operator override fun contains(element: NodeDefinition): Boolean
Link copied to clipboard
open override fun containsAll(elements: Collection<NodeDefinition>): Boolean

Generates a set of always allowed NodeDefinitions for each authorization name

Link copied to clipboard

Associates each authorization name and NodeDefinition with a set of NodeAllowRules used to generate the allow condition

Link copied to clipboard

Generates the authorization condition

private fun generateAuthorizationCondition(nodeDefinition: NodeDefinition, permission: Permission, isAllowed: Boolean): CypherConditionGenerator

Generates the authorization condition for a specific type

Link copied to clipboard

Associates each authorization name with a set of all disallow rules (by NodeDefinition

Link copied to clipboard

Generates the set of NodeAllowRule for a specific authorization name and NodeDefinition Also see generateAuthorizationAllowRules

Link copied to clipboard
private fun generateDisallowRule(permission: Permission, nodeDefinition: NodeDefinition, node: Node): Condition

Creates a Condition to check for disallowed nodes that must be true

Link copied to clipboard
private fun generateFinalAllowRules(tempAllowRules: Set<NodeAllowRule>, allowAllNodeDefinitions: Set<NodeDefinition>): Set<NodeAllowRule>

Takes a temporary set of NodeAllowRule and a set of allow all NodeDefinitions and creates the final set of NodeAllowRules

Link copied to clipboard
private fun generateFullAuthorizationCondition(allowRules: Set<NodeAllowRule>, node: Node, permission: Permission): Condition

Generates the full authorization condition. This includes both the allowRules and all disallow rules.

Link copied to clipboard

Associates each NodeDefinition with all sub-NodeDefinitions and super-NodeDefinitions

Generates the authorization condition for the remote side of a relationship It is assumed that allow is present on the parent side!

Link copied to clipboard

Generates the supertype node definition lookup

Link copied to clipboard

If present, returns nodeDefinition.mergedAuthorizations[name] If not, checks if the name is known, it returns an empty Authorization Otherwise throws an exception, has this hints at a misspelled name

Link copied to clipboard

Gets a NodeDefinition by defining class

Link copied to clipboard

Gets the list of NodeDefinitions associated with names If a common supertype is found (and the provided names include all subtypes), returns that supertype Otherwise the provided list is mapped to NodeDefinitions

Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
fun <T> Collection<T>.iterateGraph(action: (T) -> Collection<T>)

Helper function to iterate over a graph The Collection on which it is called is treated as the set of starting nodes action is called for each node in the graph exactly once, and returns a set of nodes to iterate over. This returned set of nodes may contain duplicates, or nodes which have already been iterated over.

Link copied to clipboard
open operator override fun iterator(): Iterator<NodeDefinition>