Class TransactionalStateSupport
java.lang.Object
org.sourceid.saml20.adapter.state.TransactionalStateSupport
Provides state persistence functionality for user attributes between HTTP invocations to the server on a per transaction basis.
This class is similar to
Transactional state is maintained using the same underlying mechanisms at
There are some server configurations where transactional state differentiation is not possible. In those cases, use of this API will default to behaving like
Attributes must be added or updated using the
It's recommended that clients of this API 'clean up after themselves' and remove attributes when finished with them.
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
ConstructorsConstructorDescriptionTransactionalStateSupport(String resumePath) Creates a new TransactionalStateSupport object for a user's transactional context. -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(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.booleanIndicates 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.voidsetAttribute(String name, Object value, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) Sets a named attribute for the user's transactional context.
-
Constructor Details
-
TransactionalStateSupport
Creates a new TransactionalStateSupport object for a user's transactional context.- Parameters:
resumePath- the resumePath parameter passed from the plugin interface. One such example isIdpAuthenticationAdapter.lookupAuthN(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, String, org.sourceid.saml20.adapter.idp.authn.AuthnPolicy, String)- Since:
- 6.5
-
-
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 attributevalue- value the attribute valuereq- HTTP requestresp- 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 attributereq- HTTP requestresp- 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 viaremoveAttribute(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 attributereq- HTTP requestresp- HTTP response- Returns:
- the value of the attribute that was removed, if it exists, null otherwise.
- Since:
- 6.5
-
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.
-