public class PxtSessionDelegateImpl extends java.lang.Object implements PxtSessionDelegate
PxtSessionDelegate
,
RequestContext
Modifier | Constructor and Description |
---|---|
protected |
PxtSessionDelegateImpl() |
Modifier and Type | Method and Description |
---|---|
protected WebSession |
createPxtSession(java.lang.Long uid)
Creates a new pxt session.
|
protected WebSession |
findPxtSessionById(java.lang.Long id)
Retrieves the pxt session with the given ID.
|
WebSession |
getPxtSession(javax.servlet.http.HttpServletRequest request)
Retrieve the pxt session.
|
protected java.lang.Long |
getPxtSessionId(javax.servlet.http.HttpServletRequest request)
Parses the pxt session id out of the pxt cookie if it included in the request.
|
WebSession |
getPxtSessionIfExists(javax.servlet.http.HttpServletRequest request)
Retrieve the pxt session if there is a cookie identifying it or if it was
already bound.
|
java.lang.Long |
getWebUserId(javax.servlet.http.HttpServletRequest request)
Returns the
webUserId property of the pxt session bound to the specified
request. |
void |
invalidatePxtSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Invalidates the pxt session for the given request.
|
boolean |
isPxtSessionExpired(javax.servlet.http.HttpServletRequest request)
Return
true if the pxt session for the current request has expired. |
boolean |
isPxtSessionKeyValid(javax.servlet.http.HttpServletRequest request)
Validates the pxt session ID that is stored in the pxt cookie with a secret key in
the pxt session.
|
protected void |
loadPxtSession(javax.servlet.http.HttpServletRequest request)
Loads the pxt session and stores it in the request as an attribute named
session . |
void |
refreshPxtSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Refreshes the pxt session, effectively reseting the timeout of the session.
|
protected void |
savePxtSession(WebSession pxtSession)
This method is a hook for testing.
|
void |
updateWebUserId(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Long id)
Sets the
webUserId property of the pxt session bound to the specified
request. |
public WebSession getPxtSession(javax.servlet.http.HttpServletRequest request)
session
.getPxtSession
in interface PxtSessionDelegate
request
- The current requestpublic WebSession getPxtSessionIfExists(javax.servlet.http.HttpServletRequest request)
session
.getPxtSessionIfExists
in interface PxtSessionDelegate
request
- The current requestpublic java.lang.Long getWebUserId(javax.servlet.http.HttpServletRequest request)
webUserId
property of the pxt session bound to the specified
request.getWebUserId
in interface PxtSessionDelegate
request
- The current requestwebUserId
property of the pxt session.public void updateWebUserId(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Long id)
webUserId
property of the pxt session bound to the specified
request. Note that this operation triggers a session refresh.updateWebUserId
in interface PxtSessionDelegate
request
- The current requestresponse
- The current responseid
- The ID to be assigned to the webUserId
property.PxtSessionDelegate.refreshPxtSession(HttpServletRequest, HttpServletResponse)
public boolean isPxtSessionExpired(javax.servlet.http.HttpServletRequest request)
true
if the pxt session for the current request has expired.isPxtSessionExpired
in interface PxtSessionDelegate
request
- The current requesttrue
if the pxt session for the current request has expired,
false
otherwisepublic boolean isPxtSessionKeyValid(javax.servlet.http.HttpServletRequest request)
true
if the encoded session ID matches the
secret key.isPxtSessionKeyValid
in interface PxtSessionDelegate
request
- The current requesttrue
if the encoded session ID matches the secret key,
false
otherwise.protected void loadPxtSession(javax.servlet.http.HttpServletRequest request)
session
. If the pxt session is not already present in the request,
it is fetched from the database if the pxt cookie is available. If the pxt cookie
is not available, a new pxt session is created.request
- The current request.protected java.lang.Long getPxtSessionId(javax.servlet.http.HttpServletRequest request)
request
- The current request.null
if the pxt cookie is not found or if the key
is invalid.protected WebSession findPxtSessionById(java.lang.Long id)
WebSessionFactory
. This makes it easier to write tests that can avoid
calls to WebSessionFactory
, which would result in database calls.id
- The session ID to search by.null
if no session is found.WebSessionFactory.lookupById(Long)
protected WebSession createPxtSession(java.lang.Long uid)
SessionManager
. This makes it easier to write tests that can avoid calls to
SessionManager
, which would result in database calls.uid
- The user id to create the session for.SessionManager.makeSession(Long, long)
public void refreshPxtSession(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
expires
property of the session to an appropriate value.
refreshPxtSession
in interface PxtSessionDelegate
request
- The current requestresponse
- The current responseprotected void savePxtSession(WebSession pxtSession)
pxtSession
- The session to be savedpublic void invalidatePxtSession(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
invalidatePxtSession
in interface PxtSessionDelegate
request
- The current requestresponse
- The current response