Class ContextPolicyEnforcementPoint
Context collection.
Applies role-based visibility filtering on top of the raw context data served
by ContextRepository (Redis-first, DB fallback) and enforces
administrative write-permission rules before delegating mutations.
ContextRepository has zero auth logic and zero visibility filters.
This class owns all role/visibility policy and is the single entry point for
REST-facing context operations.
Internal reads that need unfiltered data (e.g. state checks, path lookups)
must go directly through ContextRepository.
- Author:
- Luca Frosini (ISTI - CNR)
-
Nested Class Summary
Nested classes/interfaces inherited from class org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint
PolicyEnforcementPoint.EndpointPolicySpec, PolicyEnforcementPoint.QueryParamSpec, PolicyEnforcementPoint.TokenScopeRule -
Field Summary
Fields inherited from class org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint
ALL_ADMIN_ROLES, ALL_OPERATIONAL_ROLES, CONTEXT_MANAGER, DEPTH_DEFAULT, GLOBAL_PRIVILEGED_ROLES, INFRASTRUCTURE_MANAGER, IS_ADMIN, IS_CONTRIBUTOR, IS_EDITOR, IS_MANAGER, IS_MEMBER, LEGACY_ALL_META_QUERY_PARAMETER, LEGACY_INCLUDE_META_QUERY_PARAMETER, LIMIT_DEFAULT, LIMIT_MAX, MEMBERSHIP_SCOPE_PARAM_SPEC, OFFSET_DEFAULT, requestContext, UNIVERSAL_ROLES -
Constructor Summary
ConstructorsConstructorDescriptionContextPolicyEnforcementPoint(jakarta.ws.rs.container.ContainerRequestContext requestContext) Creates a new PEP instance for the current HTTP request. -
Method Summary
Modifier and TypeMethodDescriptionall()Returns the role-filtered, paginated JSON array of all contexts as aPageResult.all(boolean polymorphic) Returns the role-filtered, paginated JSON array of all contexts as aPageResult.changeState(UUID uuid, String json) Applies a validated tracked update to an existing live Context under immediate-parent scope or, for a reparenting, under the scope of the closest common ancestor of the two parents.Creates a Context after validating its complete creation representation and strict immediate-parent authorization scope.voidMoves the live Context identified byuuidto the cemetery under strict parent scope.booleanReturns whether the Root Context Bootstrap Exception's token-scope check is currently bypassed.Executes a JSON query against the Context collection under authorized constraints, returning a role-filtered, paginatedPageResult.Returns the role-filtered JSON for the context identified byuuid.Returns the role-filtered JSON for the context associated with the caller's current authorization token, resolving the context UUID from the request environment.readHistory(UUID uuid) Reads the reverse-chronological audit trail of the Context identified byuuid, enforcing administrative read privileges and the role-specific token scope.voidsetBypassRootScopeCheck(boolean bypass) Sets whether the Root Context Bootstrap Exception's token-scope check should be bypassed.Methods inherited from class org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint
addContentWarning, addIgnoredFieldsWarning, addLink, addPaginationLinks, addPreferenceApplied, addQueryParameterWarning, addResultScope, buildUri, enforceAllowedRoles, enforcePolicy, enforcePrivilegedQueryParameters, enforceTargetContextWithinTokenSubtree, getAllWarnings, getContentLocation, getContentWarnings, getIgnoredFieldsWarnings, getLinks, getPreferenceApplied, getQueryParameterWarnings, getResolvedContextPath, getResultScopes, getUriInfo, invalidQueryParameterValue, isAdministrativeUser, isPrivilegedUser, isUniversalUser, isUserAllowed, reportStateFilteredInstances, resolveAllMeta, resolveBoolean, resolveBypassHierarchyCheck, resolveContextsPolicy, resolveDepth, resolveDepth, resolveDryRun, resolveEnum, resolveHierarchical, resolveIncludeMeta, resolveLimit, resolveMembershipScope, resolveMembershipView, resolveMetadataPolicy, resolveOffset, resolvePolymorphic, resolvePropagationMode, resolveRawResult, resolveSyncExistingHierarchy, resolveTokenContextUuid, setContentLocation, validateQueryParameters, warnEnrichmentParametersIgnored, warnEnrichmentParametersIgnoredByEmitProjection
-
Constructor Details
-
ContextPolicyEnforcementPoint
public ContextPolicyEnforcementPoint(jakarta.ws.rs.container.ContainerRequestContext requestContext) Creates a new PEP instance for the current HTTP request.- Parameters:
requestContext- the JAX-RSContainerRequestContextfor the current request
-
-
Method Details
-
setBypassRootScopeCheck
public void setBypassRootScopeCheck(boolean bypass) Sets whether the Root Context Bootstrap Exception's token-scope check should be bypassed. Internal API only — must never be wired to a REST query parameter.- Parameters:
bypass-trueto bypass the check,falsefor normal enforcement
-
isBypassRootScopeCheck
public boolean isBypassRootScopeCheck()Returns whether the Root Context Bootstrap Exception's token-scope check is currently bypassed.- Returns:
trueif bypassed,falseotherwise
-
readCurrent
public String readCurrent() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the role-filtered JSON for the context associated with the caller's current authorization token, resolving the context UUID from the request environment.- Returns:
- role-filtered JSON string for the current context
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be found or read
-
read
public String read(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Returns the role-filtered JSON for the context identified byuuid. Delegates data retrieval toContextRepository.read(UUID, int, ContextProjection, ContextLifecycle)(Redis-first, DB fallback) and then applies the visibility filter for the current request.Query parameters are validated before the read; unrecognised or inapplicable parameters accumulate as
X-Warningentries (seePolicyEnforcementPoint.getAllWarnings()).- Parameters:
uuid- the UUID of the context to read- Returns:
- role-filtered JSON string
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be found or read
-
all
public PageResult all() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the role-filtered, paginated JSON array of all contexts as aPageResult. Equivalent toall(false).- Returns:
PageResultwith the page JSON and pagination state- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if contexts cannot be read
-
all
public PageResult all(boolean polymorphic) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Returns the role-filtered, paginated JSON array of all contexts as aPageResult.Resolves
limit,offset, and visibility flags from the current request and delegates toContextRepository.all(boolean, ContextProjection, int, int, ContextLifecycle).- Parameters:
polymorphic- whether to include subclasses of Context- Returns:
PageResultwith the page JSON and pagination state- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if contexts cannot be read
-
query
public PageResult query(String jsonQuery) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Executes a JSON query against the Context collection under authorized constraints, returning a role-filtered, paginatedPageResult.Resolves
limit,offset,lifecycle, and visibility flags from the current request and delegates toContextRepository.query(String, ContextProjection, int, int, ContextLifecycle).- Parameters:
jsonQuery- the JSON query payload describing the Context search criteria- Returns:
PageResultwith the page JSON and pagination state- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the query syntax or structure is invalidorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if contexts cannot be read
-
create
public ContextCreationResult create(UUID uuid, String json) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates a Context after validating its complete creation representation and strict immediate-parent authorization scope.The body must explicitly define matching
id, validname, andparent; a JSON null parent denotes Root creation. For a Root Context,enforceRootScopeCheck(String)additionally validates that the caller's token was issued for that exact Root Context, unlesssetBypassRootScopeCheck(boolean)was set by an internal caller. A deleted Root with the same path does not prevent the creation.- Parameters:
uuid- the UUID of the context to createjson- the JSON body of the request- Returns:
- the
ContextCreationResultwrapping the serialized JSON of the created Context and whether a brand new Context was registered (created = falsefor an idempotent re-submit of an already-existing, congruent Context) - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the operation fails
-
changeState
public String changeState(UUID uuid, String json) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Applies a validated tracked update to an existing live Context under immediate-parent scope or, for a reparenting, under the scope of the closest common ancestor of the two parents.- Parameters:
uuid- the UUID of the contextjson- the JSON merge-patch containingstate,name,parent, orpreviousPaths- Returns:
- the serialized JSON of the updated context
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the operation fails
-
delete
public void delete(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Moves the live Context identified byuuidto the cemetery under strict parent scope. Deleting a Context that is already in the cemetery is a no-op for the global managers.- Parameters:
uuid- the UUID of the context to delete- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the operation fails
-
readHistory
public String readHistory(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads the reverse-chronological audit trail of the Context identified byuuid, enforcing administrative read privileges and the role-specific token scope.Only IS-Manager, Infrastructure-Manager, IS-Admin, and Context-Manager are authorized to view Context history (see
enforceHistoryReadScope(UUID)). Thewhoof every event is returned in full to the universal roles and as"[REDACTED]"to Context-Manager.- Parameters:
uuid- the UUID of the context whose history to read- Returns:
- JSON array string of history events, newest first
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the lookup fails, or if the caller lacks authorization
-