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 toSessionStateSupportbut 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 atSessionStateSupportbut 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 likeSessionStateSupport.
Attributes must be added or updated using thesetAttribute(String, Object, HttpServletRequest, HttpServletResponse)orremoveAttribute(String, HttpServletRequest, HttpServletResponse)methods before the associatedHttpServletResponseresponse 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 TransactionalStateSupport(String resumePath)Creates a new TransactionalStateSupport object for a user's transactional context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetAttribute(String name, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Retrieves a named attribute from the user's transactional context.StringgetTransactionalContextId()Gets the transactional qualifier id that was embedded/encoded into the resume path.booleanhasTransactionalContextId()Indicates if a transactional qualifier id embedded/encoded into the resume path.ObjectremoveAttribute(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 Detail
-
TransactionalStateSupport
public TransactionalStateSupport(String resumePath)
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 Detail
-
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
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.
-
-