Package cloud.piranha.webapp.impl
Class DefaultHttpSessionManager
- java.lang.Object
-
- cloud.piranha.webapp.impl.DefaultHttpSessionManager
-
- All Implemented Interfaces:
HttpSessionManager
,SessionCookieConfig
- Direct Known Subclasses:
HazelcastHttpSessionManager
public class DefaultHttpSessionManager extends Object implements HttpSessionManager, SessionCookieConfig
The default HttpSessionManager.- Author:
- Manfred Riem ([email protected])
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<HttpSessionAttributeListener>
attributeListeners
Stores the session listeners.protected String
comment
Stores the comment.protected Set<SessionTrackingMode>
defaultSessionTrackingModes
Stores the default session tracking modes.protected String
domain
Stores the domain.protected boolean
httpOnly
Stores the HTTP only flag.protected ArrayList<HttpSessionIdListener>
idListeners
Stores the session id listeners.protected int
maxAge
Stores the max age.protected String
name
Stores the name.protected String
path
Stores the path.protected boolean
secure
Stores the secure flag.protected ArrayList<HttpSessionListener>
sessionListeners
Stores the session listeners.protected Map<String,HttpSession>
sessions
Stores the sessions.protected int
sessionTimeout
Stores the session timeout (in minutes).protected Set<SessionTrackingMode>
sessionTrackingModes
Stores the session tracking modes.protected WebApplication
webApplication
Stores the web application.
-
Constructor Summary
Constructors Constructor Description DefaultHttpSessionManager()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends EventListener>
voidaddListener(T listener)
Add a listener.void
attributeAdded(HttpSession session, String name, Object value)
Attribute added.void
attributeRemoved(HttpSession session, String name)
Attributed removed.void
attributeReplaced(HttpSession session, String name, Object value)
Attribute removed.String
changeSessionId(HttpServletRequest request)
Change the session id.HttpSession
createSession(WebApplication webApplication, HttpServletRequest request)
Create the session.void
destroySession(HttpSession session)
Destroy the session.String
encodeRedirectURL(HttpServletResponse response, String url)
Encode the redirect URL.String
encodeURL(HttpServletResponse response, String url)
Encode the URL.String
getComment()
Get the comment.Set<SessionTrackingMode>
getDefaultSessionTrackingModes()
Get the default session tracking modes.String
getDomain()
Get the domain.Set<SessionTrackingMode>
getEffectiveSessionTrackingModes()
Get the effective session tracking modes.int
getMaxAge()
Get the max age.String
getName()
Get the name.String
getPath()
Get the path.HttpSession
getSession(WebApplication webApplication, HttpServletRequest request, String currentSessionId)
Get the session.SessionCookieConfig
getSessionCookieConfig()
Get the session cookie config.int
getSessionTimeout()
Get the session timeout (in minutes).boolean
hasSession(String sessionId)
Has a session with the given id.boolean
isHttpOnly()
Is HTTP only?boolean
isSecure()
Is secure.void
setComment(String comment)
Set the comment.void
setDomain(String domain)
Set the domain.void
setHttpOnly(boolean httpOnly)
Set the HTTP only flag.void
setMaxAge(int maxAge)
Set the max age.void
setName(String name)
Set the name.void
setPath(String path)
Set the path.void
setSecure(boolean secure)
Set the secure flag.void
setSessionTimeout(int sessionTimeout)
Set the session timeout.void
setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
Set the session tracking modes.
-
-
-
Field Detail
-
attributeListeners
protected final ArrayList<HttpSessionAttributeListener> attributeListeners
Stores the session listeners.
-
comment
protected String comment
Stores the comment.
-
defaultSessionTrackingModes
protected final Set<SessionTrackingMode> defaultSessionTrackingModes
Stores the default session tracking modes.
-
domain
protected String domain
Stores the domain.
-
httpOnly
protected boolean httpOnly
Stores the HTTP only flag.
-
idListeners
protected final ArrayList<HttpSessionIdListener> idListeners
Stores the session id listeners.
-
maxAge
protected int maxAge
Stores the max age.
-
name
protected String name
Stores the name.
-
path
protected String path
Stores the path.
-
secure
protected boolean secure
Stores the secure flag.
-
sessionListeners
protected final ArrayList<HttpSessionListener> sessionListeners
Stores the session listeners.
-
sessionTimeout
protected int sessionTimeout
Stores the session timeout (in minutes).
-
sessionTrackingModes
protected Set<SessionTrackingMode> sessionTrackingModes
Stores the session tracking modes.
-
sessions
protected Map<String,HttpSession> sessions
Stores the sessions.
-
webApplication
protected WebApplication webApplication
Stores the web application.
-
-
Method Detail
-
createSession
public HttpSession createSession(WebApplication webApplication, HttpServletRequest request)
Create the session.- Specified by:
createSession
in interfaceHttpSessionManager
- Parameters:
webApplication
- the web application.request
- the request.- Returns:
- the session.
-
getSession
public HttpSession getSession(WebApplication webApplication, HttpServletRequest request, String currentSessionId)
Get the session.- Specified by:
getSession
in interfaceHttpSessionManager
- Parameters:
webApplication
- the web application.request
- the request.currentSessionId
- the current session id.- Returns:
- the session.
-
changeSessionId
public String changeSessionId(HttpServletRequest request)
Change the session id.- Specified by:
changeSessionId
in interfaceHttpSessionManager
- Parameters:
request
- the request.- Returns:
- the session id.
-
addListener
public <T extends EventListener> void addListener(T listener)
Add a listener.- Specified by:
addListener
in interfaceHttpSessionManager
- Type Parameters:
T
- the type.- Parameters:
listener
- the listener.
-
attributeAdded
public void attributeAdded(HttpSession session, String name, Object value)
Attribute added.- Specified by:
attributeAdded
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.value
- the value.
-
attributeReplaced
public void attributeReplaced(HttpSession session, String name, Object value)
Attribute removed.- Specified by:
attributeReplaced
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.value
- the value.
-
attributeRemoved
public void attributeRemoved(HttpSession session, String name)
Attributed removed.- Specified by:
attributeRemoved
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.
-
destroySession
public void destroySession(HttpSession session)
Destroy the session.- Specified by:
destroySession
in interfaceHttpSessionManager
- Parameters:
session
- the session.
-
encodeRedirectURL
public String encodeRedirectURL(HttpServletResponse response, String url)
Encode the redirect URL.- Specified by:
encodeRedirectURL
in interfaceHttpSessionManager
- Parameters:
response
- the response.url
- the redirect url.- Returns:
- the encoded redirect url.
-
encodeURL
public String encodeURL(HttpServletResponse response, String url)
Encode the URL.- Specified by:
encodeURL
in interfaceHttpSessionManager
- Parameters:
response
- the response.url
- the url.- Returns:
- the encoded url.
-
getComment
public String getComment()
Get the comment.- Specified by:
getComment
in interfaceSessionCookieConfig
- Returns:
- the comment.
-
getDefaultSessionTrackingModes
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
Get the default session tracking modes.- Specified by:
getDefaultSessionTrackingModes
in interfaceHttpSessionManager
- Returns:
- the default session tracking modes.
-
getDomain
public String getDomain()
Get the domain.- Specified by:
getDomain
in interfaceSessionCookieConfig
- Returns:
- the domain.
-
getEffectiveSessionTrackingModes
public Set<SessionTrackingMode> 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 String getName()
Get the name.- Specified by:
getName
in interfaceSessionCookieConfig
- Returns:
- the name.
-
getPath
public String getPath()
Get the path.- Specified by:
getPath
in interfaceSessionCookieConfig
- Returns:
- the path.
-
getSessionCookieConfig
public SessionCookieConfig 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(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(String comment)
Set the comment.- Specified by:
setComment
in interfaceSessionCookieConfig
- Parameters:
comment
- the comment.
-
setDomain
public void setDomain(String domain)
Set the domain.- Specified by:
setDomain
in interfaceSessionCookieConfig
- Parameters:
domain
- the domain
-
setHttpOnly
public void setHttpOnly(boolean httpOnly)
Set the HTTP only flag.- Specified by:
setHttpOnly
in interfaceSessionCookieConfig
- Parameters:
httpOnly
- the HTTP only flag.
-
setMaxAge
public void setMaxAge(int maxAge)
Set the max age.- Specified by:
setMaxAge
in interfaceSessionCookieConfig
- Parameters:
maxAge
- the max age.
-
setName
public void setName(String name)
Set the name.- Specified by:
setName
in interfaceSessionCookieConfig
- Parameters:
name
- the name.
-
setPath
public void setPath(String path)
Set the path.- Specified by:
setPath
in interfaceSessionCookieConfig
- Parameters:
path
- the path.
-
setSecure
public void setSecure(boolean secure)
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
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
Set the session tracking modes.- Specified by:
setSessionTrackingModes
in interfaceHttpSessionManager
- Parameters:
sessionTrackingModes
- the session tracking modes.
-
-