Class TransactionalStateSupport

java.lang.Object
org.sourceid.saml20.adapter.state.TransactionalStateSupport

public class TransactionalStateSupport extends Object
Provides state persistence functionality for user attributes between HTTP invocations to the server on a per transaction basis. This class is similar to SessionStateSupport but the attributes are only available though the course of a single transaction rather than for a full session. The scope of a transaction is a single set of interactions between the server and an adapter to accomplish a single task (i.e. looking up a login context, even when spanning multiple HTTP request/response interactions, is a single transactional context).
Transactional state is maintained using the same underlying mechanisms at SessionStateSupport but with an additional qualifier on the key to distinguish one transaction from another. This enables better support for concurrent and nested transactions. The transactional qualifier is a short opaque value encoded into the resume path that is passed to the adapter in front channel invocations.
There are some server configurations where transactional state differentiation is not possible. In those cases, use of this API will default to behaving like SessionStateSupport.
Attributes must be added or updated using the setAttribute(String, Object, HttpServletRequest, HttpServletResponse) or removeAttribute(String, HttpServletRequest, HttpServletResponse) methods before the associated HttpServletResponse response is committed.
It's recommended that clients of this API 'clean up after themselves' and remove attributes when finished with them.
Since:
6.5
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new TransactionalStateSupport object for a user's transactional context.
  • Method Summary

    Modifier and Type
    Method
    Description
    getAttribute(String name, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
    Retrieves a named attribute from the user's transactional context.
    Gets the transactional qualifier id that was embedded/encoded into the resume path.
    boolean
    Indicates if a transactional qualifier id embedded/encoded into the resume path.
    removeAttribute(String name, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
    Removes the named attribute from the user's transactional context.
    void
    setAttribute(String name, Object value, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
    Sets a named attribute for the user's transactional context.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • setAttribute

      public void setAttribute(String name, Object value, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Sets a named attribute for the user's transactional context.
      Parameters:
      name - the name of the attribute
      value - value the attribute value
      req - HTTP request
      resp - HTTP response
      Since:
      6.5
    • getAttribute

      public Object getAttribute(String name, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Retrieves a named attribute from the user's transactional context.
      Parameters:
      name - the name of the attribute
      req - HTTP request
      resp - HTTP response
      Returns:
      the value of the attribute as previously set by setAttribute(String, Object, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), or null if the attribute was never set, was removed via removeAttribute(String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), or if transactional context has been lost.
      Since:
      6.5
    • removeAttribute

      public Object removeAttribute(String name, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Removes the named attribute from the user's transactional context.
      Parameters:
      name - the name of the attribute
      req - HTTP request
      resp - HTTP response
      Returns:
      the value of the attribute that was removed, if it exists, null otherwise.
      Since:
      6.5
    • getTransactionalContextId

      public String getTransactionalContextId()
      Gets the transactional qualifier id that was embedded/encoded into the resume path.
      Returns:
      transactional qualifier id or null if no such qualifier was not present.
    • hasTransactionalContextId

      public boolean hasTransactionalContextId()
      Indicates if a transactional qualifier id embedded/encoded into the resume path.
      Returns:
      true if the resume path contains such an id, and false otherwise.