Class TreeContext


  • @SupportedAll
    public final class TreeContext
    extends Object
    A representation of the context of the current tree authentication process.
    • Field Detail

      • IDM_IDENTITY_RESOURCE

        public static final String IDM_IDENTITY_RESOURCE
        The tree config key for the storage of the IDM identity resource.
        See Also:
        Constant Field Values
      • DEFAULT_IDM_IDENTITY_RESOURCE

        public static final String DEFAULT_IDM_IDENTITY_RESOURCE
        The default IDM identity resource.
        See Also:
        Constant Field Values
      • sharedState

        @Deprecated
        public final JsonValue sharedState
        Deprecated.
        Use getStateFor(Node) instead as this method does not leak implementation detail of the specific type of state.
        The shared state that has accumulated so far by traversing the tree.
      • request

        public final ExternalRequestContext request
        The HTTP request associated with the current authentication request.
      • transientState

        @Deprecated
        public final JsonValue transientState
        Deprecated.
        Use getStateFor(Node) instead as this method does not leak implementation detail of the specific type of state.
        The state that is transient and is encrypted and stored across requests only if downstream nodes declare they use it.
      • universalId

        public final Optional<String> universalId
        The identity objects universal id.
      • identityResource

        public final String identityResource
        The IDM identity resource container for all IDM object interactions in this tree.
    • Constructor Detail

      • TreeContext

        public TreeContext​(String identityResource,
                           JsonValue sharedState,
                           ExternalRequestContext request,
                           List<? extends Callback> callbacks)
        Construct a tree context for the current state.
        Parameters:
        identityResource - The IDM identity resource.
        sharedState - The shared state.
        request - The request associated with the current authentication request.
        callbacks - The callbacks received in the current authentication request.
      • TreeContext

        public TreeContext​(JsonValue sharedState,
                           ExternalRequestContext request,
                           List<? extends Callback> callbacks,
                           Optional<String> universalId)
        Construct a tree context for the current state.
        Parameters:
        sharedState - The shared state.
        request - The request associated with the current authentication request.
        callbacks - The callbacks received in the current authentication request.
        universalId - The universal id of the identity object.
      • TreeContext

        public TreeContext​(String identityResource,
                           JsonValue sharedState,
                           JsonValue transientState,
                           ExternalRequestContext request,
                           List<? extends Callback> callbacks,
                           Optional<String> universalId)
        Construct a tree context for the current state.
        Parameters:
        identityResource - The IDM identity resource.
        sharedState - The shared state.
        transientState - The transient state.
        request - The request associated with the current authentication request.
        callbacks - The callbacks received in the current authentication request.
        universalId - The universal id of the identity object.
      • TreeContext

        public TreeContext​(JsonValue sharedState,
                           JsonValue transientState,
                           ExternalRequestContext request,
                           List<? extends Callback> callbacks,
                           Optional<String> universalId)
        Construct a tree context for the current state.
        Parameters:
        sharedState - The shared state.
        transientState - The transient state.
        request - The request associated with the current authentication request.
        callbacks - The callbacks received in the current authentication request.
        universalId - The universal id of the identity object.
      • TreeContext

        public TreeContext​(String identityResource,
                           JsonValue sharedState,
                           JsonValue transientState,
                           JsonValue secureState,
                           ExternalRequestContext request,
                           List<? extends Callback> callbacks,
                           Optional<String> universalId)
        Construct a tree context for the current state.
        Parameters:
        identityResource - The IDM identity resource.
        sharedState - The shared state.
        transientState - The transient state.
        secureState - The secure state.
        request - The request associated with the current authentication request.
        callbacks - The callbacks received in the current authentication request.
        universalId - The universal id of the identity object.
      • TreeContext

        public TreeContext​(JsonValue sharedState,
                           JsonValue transientState,
                           JsonValue secureState,
                           ExternalRequestContext request,
                           List<? extends Callback> callbacks,
                           Optional<String> universalId)
        Construct a tree context for the current state.
        Parameters:
        sharedState - The shared state.
        transientState - The transient state.
        secureState - The secure state.
        request - The request associated with the current authentication request.
        callbacks - The callbacks received in the current authentication request.
        universalId - The universal id of the identity object.
      • TreeContext

        public TreeContext​(String identityResource,
                           JsonValue sharedState,
                           JsonValue transientState,
                           JsonValue secureState,
                           ExternalRequestContext request,
                           List<? extends Callback> callbacks,
                           boolean resumedFromSuspend,
                           Optional<String> universalId)
        Construct a tree context for the current state.
        Parameters:
        identityResource - The IDM identity resource.
        sharedState - The shared state.
        transientState - The transient state.
        secureState - The secure state.
        request - The request associated with the current authentication request.
        callbacks - The callbacks received in the current authentication request.
        resumedFromSuspend - whether the tree has been resumed from having been suspended.
        universalId - The universal id of the identity object.
      • TreeContext

        public TreeContext​(JsonValue sharedState,
                           JsonValue transientState,
                           JsonValue secureState,
                           ExternalRequestContext request,
                           List<? extends Callback> callbacks,
                           boolean resumedFromSuspend,
                           Optional<String> universalId)
        Construct a tree context for the current state.
        Parameters:
        sharedState - The shared state.
        transientState - The transient state.
        secureState - The secure state.
        request - The request associated with the current authentication request.
        callbacks - The callbacks received in the current authentication request.
        resumedFromSuspend - whether the tree has been resumed from having been suspended.
        universalId - The universal id of the identity object.
    • Method Detail

      • getCallback

        public <T extends CallbackOptional<T> getCallback​(Class<T> callbackType)
        Get the first callback of a particular type from the callbacks in the context.
        Type Parameters:
        T - The generic type of the callback.
        Parameters:
        callbackType - The type of callback.
        Returns:
        An optional of the callback or empty if no callback of that type existed.
      • getCallbacks

        public <T extends CallbackList<T> getCallbacks​(Class<T> callbackType)
        Get the callbacks of a particular type from the callbacks in the context.
        Type Parameters:
        T - The generic type of the callback.
        Parameters:
        callbackType - The type of callback.
        Returns:
        An list of callbacks or empty if no callback of that type existed.
      • getAllCallbacks

        public List<? extends Callback> getAllCallbacks()
        Gets all the callbacks sent in the request.

        Use getCallback(Class) in preference to this method.

        Returns:
        An unmodifiable list of callbacks.
      • hasCallbacks

        public boolean hasCallbacks()
        Check if any callbacks have been submitted in this authenticate request.
        Returns:
        true if there are callbacks available.
      • getStateFor

        public NodeState getStateFor​(Node node)
        Returns a new instance of NodeState encapsulating all types of state and allowing access to state in the following order.
        1. transient
        2. secure
        3. shared
        Parameters:
        node - The node whose state is being requested.
        Returns:
        The unified NodeState.
      • getState

        @Deprecated
        public JsonValue getState​(String stateKey)
        Deprecated.
        Use getStateFor(Node) instead as this method performs the same function but supports filtering of the available state based on the nodes declared inputs.
        Retrieves a field from one of the three supported state locations, or null if the key is not found in any of the state locations.
        Parameters:
        stateKey - The key to look for.
        Returns:
        The first occurrence of the key from the states, in order: Transient, Secure, Shared.
      • getSecureState

        @Deprecated
        public JsonValue getSecureState​(String stateKey)
        Deprecated.
        Use getStateFor(Node) instead as this method does not leak implementation detail of the specific type of state.
        Retrieves a field from one the secure state, or null if the key is not found.
        Parameters:
        stateKey - The key to look for.
        Returns:
        The key value from secure state if present.
      • getTransientState

        @Deprecated
        public JsonValue getTransientState​(String stateKey)
        Deprecated.
        Use getStateFor(Node) instead as this method does not leak implementation detail of the specific type of state.
        Retrieves a field from either transient or secured state, or null if the key is not found in any of the state locations.
        Parameters:
        stateKey - The key to look for.
        Returns:
        The first occurrence of the key from the states, in order: Secure, Transient.
      • hasResumedFromSuspend

        public boolean hasResumedFromSuspend()
        Whether the tree has been resumed from having been suspended.
        Returns:
        whether the tree has been resumed from having been suspended
      • copyWithCallbacks

        public TreeContext copyWithCallbacks​(List<? extends Callback> callbacks)
        Copies this TreeContext instance, replacing the callbacks in the context with the provided callbacks.
        Parameters:
        callbacks - The new callbacks.
        Returns:
        A new TreeContext instance.
      • copyWithCallbacksAndState

        public TreeContext copyWithCallbacksAndState​(JsonValue sharedState,
                                                     JsonValue transientState,
                                                     JsonValue secureState,
                                                     List<? extends Callback> callbacks)
        Copies this TreeContext instance, replacing the callbacks in the context with the provided callbacks and with the provided new state if input state parameter is not null.
        Parameters:
        sharedState - The new sharedState, if null use previous value.
        transientState - The new transientState, if null use previous value.
        secureState - The new secureState, if null use previous value.
        callbacks - The new callbacks.
        Returns:
        A new TreeContext instance.