Class TokenContextResolution

java.lang.Object
org.gcube.informationsystem.resourceregistry.contexts.TokenContextResolution

public final class TokenContextResolution extends Object
The single resolution of the caller's token path to a live Context, done once per request (reference 08, Token path resolution): the token path is matched against current paths first and then against previousPaths.

Every consumer that derives its Context from the token reads it from here, and ResultScopeResponseFilter emits X-Result-Scope: previous-path and X-Resolved-Context-Path on every response whose request resolved the token through a previous path. The outcome is kept for the thread's current Secret, so a new request (a new secret) always resolves again; the response filter also clears it.

Author:
Luca Frosini (ISTI - CNR)
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Forgets the outcome kept for this thread, at the end of a request.
    static org.gcube.informationsystem.contexts.reference.entities.Context
    Returns the live Context the caller's token path resolves to, resolving it on the first call of the request.
    static String
    Returns the current path of the live Context of the caller's token, which differs from the token path when the token carries a previous path.
    static UUID
    Returns the UUID of the live Context of the caller's token.
    static String
    Returns the current path the token resolved to during this request when the token carried a previous path, null otherwise (no resolution, or a direct match).
    static void
    record(org.gcube.informationsystem.contexts.reference.entities.Context context)
    Records a Context resolved from the caller's token path by a lookup other than current() (e.g. the cemetery-inclusive lookup of Read Current), so that the response reports a previous-path match in the same way.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • current

      public static org.gcube.informationsystem.contexts.reference.entities.Context current() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the live Context the caller's token path resolves to, resolving it on the first call of the request.
      Returns:
      the live Context of the token
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException - if the thread carries no token Context
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the path matches no live Context, or the lookup fails
    • currentUUID

      public static UUID currentUUID() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the UUID of the live Context of the caller's token.
      Returns:
      the UUID of the token Context
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the token Context cannot be resolved
      See Also:
    • currentPath

      public static String currentPath() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the current path of the live Context of the caller's token, which differs from the token path when the token carries a previous path.
      Returns:
      the current path of the token Context
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the token Context cannot be resolved
      See Also:
    • record

      public static void record(org.gcube.informationsystem.contexts.reference.entities.Context context)
      Records a Context resolved from the caller's token path by a lookup other than current() (e.g. the cemetery-inclusive lookup of Read Current), so that the response reports a previous-path match in the same way.
      Parameters:
      context - the Context the token path resolved to
    • getPreviousPathResolution

      public static String getPreviousPathResolution()
      Returns the current path the token resolved to during this request when the token carried a previous path, null otherwise (no resolution, or a direct match).
      Returns:
      the resolved current path after a previous-path match, or null
    • clear

      public static void clear()
      Forgets the outcome kept for this thread, at the end of a request.