java.lang.Object
cloud.piranha.webapp.impl.DefaultHttpSessionManager
- All Implemented Interfaces:
HttpSessionManager
,SessionCookieConfig
public class DefaultHttpSessionManager extends java.lang.Object implements HttpSessionManager, SessionCookieConfig
The default HttpSessionManager.
- Author:
- Manfred Riem ([email protected])
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<HttpSessionAttributeListener>
attributeListeners
Stores the session listeners.protected java.lang.String
comment
Stores the comment.protected java.util.Set<SessionTrackingMode>
defaultSessionTrackingModes
Stores the default session tracking modes.protected java.lang.String
domain
Stores the domain.protected boolean
httpOnly
Stores the HTTP only flag.protected java.util.ArrayList<HttpSessionIdListener>
idListeners
Stores the session id listeners.protected int
maxAge
Stores the max age.protected java.lang.String
name
Stores the name.protected java.lang.String
path
Stores the path.protected boolean
secure
Stores the secure flag.protected java.util.ArrayList<HttpSessionListener>
sessionListeners
Stores the session listeners.protected java.util.Map<java.lang.String,HttpSession>
sessions
Stores the sessions.protected int
sessionTimeout
Stores the session timeout (in minutes).protected java.util.Set<SessionTrackingMode>
sessionTrackingModes
Stores the session tracking modes.protected WebApplication
webApplication
Stores the web application. -
Constructor Summary
Constructors Constructor Description DefaultHttpSessionManager()
Constructor. -
Method Summary
Modifier and Type Method Description <T extends java.util.EventListener>
voidaddListener(T listener)
Add a listener.void
attributeAdded(HttpSession session, java.lang.String name, java.lang.Object value)
Attribute added.void
attributeRemoved(HttpSession session, java.lang.String name, java.lang.Object value)
Attribute removed.void
attributeReplaced(HttpSession session, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Attribute replaced.java.lang.String
changeSessionId(HttpServletRequest request)
Change the session id.HttpSession
createSession(HttpServletRequest request)
Create a session.void
destroySession(HttpSession session)
Destroy the session.java.lang.String
encodeRedirectURL(HttpServletResponse response, java.lang.String url)
Encode the redirect URL.java.lang.String
encodeURL(HttpServletResponse response, java.lang.String url)
Encode the URL.java.lang.String
getComment()
Get the comment.java.util.Set<SessionTrackingMode>
getDefaultSessionTrackingModes()
Get the default session tracking modes.java.lang.String
getDomain()
Get the domain.java.util.Set<SessionTrackingMode>
getEffectiveSessionTrackingModes()
Get the effective session tracking modes.int
getMaxAge()
Get the max age.java.lang.String
getName()
Get the name.java.lang.String
getPath()
Get the path.HttpSession
getSession(HttpServletRequest request, java.lang.String currentSessionId)
Get the session.SessionCookieConfig
getSessionCookieConfig()
Get the session cookie config.int
getSessionTimeout()
Get the session timeout (in minutes).boolean
hasSession(java.lang.String sessionId)
Has a session with the given id.boolean
isHttpOnly()
Is HTTP only?boolean
isSecure()
Is secure.void
setComment(java.lang.String comment)
Set the comment.void
setDomain(java.lang.String domain)
Set the domain.void
setHttpOnly(boolean httpOnly)
Set the HTTP-only flag.void
setMaxAge(int maxAge)
Set the max age.void
setName(java.lang.String name)
Set the name.void
setPath(java.lang.String path)
Set the path.void
setSecure(boolean secure)
Set the secure flag.void
setSessionTimeout(int sessionTimeout)
Set the session timeout.void
setSessionTrackingModes(java.util.Set<SessionTrackingMode> sessionTrackingModes)
Set the session tracking modes.void
setWebApplication(WebApplication webApplication)
Set the web application.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
attributeListeners
Stores the session listeners. -
comment
protected java.lang.String commentStores the comment. -
defaultSessionTrackingModes
Stores the default session tracking modes. -
domain
protected java.lang.String domainStores the domain. -
httpOnly
protected boolean httpOnlyStores the HTTP only flag. -
idListeners
Stores the session id listeners. -
maxAge
protected int maxAgeStores the max age. -
name
protected java.lang.String nameStores the name. -
path
protected java.lang.String pathStores the path. -
secure
protected boolean secureStores the secure flag. -
sessionListeners
Stores the session listeners. -
sessionTimeout
protected int sessionTimeoutStores the session timeout (in minutes). -
sessionTrackingModes
Stores the session tracking modes. -
sessions
Stores the sessions. -
webApplication
Stores the web application.
-
-
Constructor Details
-
DefaultHttpSessionManager
public DefaultHttpSessionManager()Constructor.
-
-
Method Details
-
createSession
Description copied from interface:HttpSessionManager
Create a session.- Specified by:
createSession
in interfaceHttpSessionManager
- Parameters:
request
- the request.- Returns:
- the session.
-
getSession
Description copied from interface:HttpSessionManager
Get the session.- Specified by:
getSession
in interfaceHttpSessionManager
- Parameters:
request
- the request.currentSessionId
- the current session id.- Returns:
- the session.
-
changeSessionId
Change the session id.- Specified by:
changeSessionId
in interfaceHttpSessionManager
- Parameters:
request
- the request.- Returns:
- the session id.
-
addListener
public <T extends java.util.EventListener> void addListener(T listener)Add a listener.- Specified by:
addListener
in interfaceHttpSessionManager
- Type Parameters:
T
- the type.- Parameters:
listener
- the listener.
-
attributeAdded
Attribute added.- Specified by:
attributeAdded
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.value
- the value.
-
attributeReplaced
public void attributeReplaced(HttpSession session, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)Attribute replaced.- Specified by:
attributeReplaced
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.oldValue
- the old value.newValue
- the new value.
-
attributeRemoved
Description copied from interface:HttpSessionManager
Attribute removed.- Specified by:
attributeRemoved
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.value
- the value.
-
destroySession
Destroy the session.- Specified by:
destroySession
in interfaceHttpSessionManager
- Parameters:
session
- the session.
-
encodeRedirectURL
Encode the redirect URL.- Specified by:
encodeRedirectURL
in interfaceHttpSessionManager
- Parameters:
response
- the response.url
- the redirect url.- Returns:
- the encoded redirect url.
-
encodeURL
Encode the URL.- Specified by:
encodeURL
in interfaceHttpSessionManager
- Parameters:
response
- the response.url
- the url.- Returns:
- the encoded url.
-
getComment
public java.lang.String getComment()Get the comment.- Specified by:
getComment
in interfaceSessionCookieConfig
- Returns:
- the comment.
-
getDefaultSessionTrackingModes
Get the default session tracking modes.- Specified by:
getDefaultSessionTrackingModes
in interfaceHttpSessionManager
- Returns:
- the default session tracking modes.
-
getDomain
public java.lang.String getDomain()Get the domain.- Specified by:
getDomain
in interfaceSessionCookieConfig
- Returns:
- the domain.
-
getEffectiveSessionTrackingModes
Get the effective session tracking modes.- Specified by:
getEffectiveSessionTrackingModes
in interfaceHttpSessionManager
- Returns:
- the effective session tracking modes.
-
getMaxAge
public int getMaxAge()Get the max age.- Specified by:
getMaxAge
in interfaceSessionCookieConfig
- Returns:
- the max age.
-
getName
public java.lang.String getName()Get the name.- Specified by:
getName
in interfaceSessionCookieConfig
- Returns:
- the name.
-
getPath
public java.lang.String getPath()Get the path.- Specified by:
getPath
in interfaceSessionCookieConfig
- Returns:
- the path.
-
getSessionCookieConfig
Get the session cookie config.- Specified by:
getSessionCookieConfig
in interfaceHttpSessionManager
- Returns:
- the session cookie config.
-
getSessionTimeout
public int getSessionTimeout()Get the session timeout (in minutes).- Specified by:
getSessionTimeout
in interfaceHttpSessionManager
- Returns:
- the session timeout.
-
hasSession
public boolean hasSession(java.lang.String sessionId)Has a session with the given id.- Specified by:
hasSession
in interfaceHttpSessionManager
- Parameters:
sessionId
- the session id.- Returns:
- true if there is one, false otherwise.
-
isHttpOnly
public boolean isHttpOnly()Is HTTP only?- Specified by:
isHttpOnly
in interfaceSessionCookieConfig
- Returns:
- true if HTTP only, false otherwise.
-
isSecure
public boolean isSecure()Is secure.- Specified by:
isSecure
in interfaceSessionCookieConfig
- Returns:
- the secure flag.
-
setComment
public void setComment(java.lang.String comment)Description copied from interface:SessionCookieConfig
Set the comment.- Specified by:
setComment
in interfaceSessionCookieConfig
- Parameters:
comment
- the comment.
-
setDomain
public void setDomain(java.lang.String domain)Description copied from interface:SessionCookieConfig
Set the domain.- Specified by:
setDomain
in interfaceSessionCookieConfig
- Parameters:
domain
- the domain.
-
setHttpOnly
public void setHttpOnly(boolean httpOnly)Description copied from interface:SessionCookieConfig
Set the HTTP-only flag.- Specified by:
setHttpOnly
in interfaceSessionCookieConfig
- Parameters:
httpOnly
- the HTTP-only flag.
-
setMaxAge
public void setMaxAge(int maxAge)Description copied from interface:SessionCookieConfig
Set the max age.- Specified by:
setMaxAge
in interfaceSessionCookieConfig
- Parameters:
maxAge
- the max age.
-
setName
public void setName(java.lang.String name)Description copied from interface:SessionCookieConfig
Set the name.- Specified by:
setName
in interfaceSessionCookieConfig
- Parameters:
name
- the name.
-
setPath
public void setPath(java.lang.String path)Description copied from interface:SessionCookieConfig
Set the path.- Specified by:
setPath
in interfaceSessionCookieConfig
- Parameters:
path
- the path.
-
setSecure
public void setSecure(boolean secure)Description copied from interface:SessionCookieConfig
Set the secure flag.- Specified by:
setSecure
in interfaceSessionCookieConfig
- Parameters:
secure
- the secure flag.
-
setSessionTimeout
public void setSessionTimeout(int sessionTimeout)Set the session timeout.- Specified by:
setSessionTimeout
in interfaceHttpSessionManager
- Parameters:
sessionTimeout
- the session timeout.
-
setSessionTrackingModes
Set the session tracking modes.- Specified by:
setSessionTrackingModes
in interfaceHttpSessionManager
- Parameters:
sessionTrackingModes
- the session tracking modes.
-
setWebApplication
Set the web application.- Specified by:
setWebApplication
in interfaceHttpSessionManager
- Parameters:
webApplication
- the web application.
-