Top Description Fields Methods
org.mortbay.jetty

public Interface SessionManager

extends LifeCycle
Known Direct Implementers
org.mortbay.jetty.servlet.AbstractSessionManager
Imports
java.util.EventListener, javax.servlet.http.Cookie, .HttpServletRequest, .HttpSession, org.mortbay.component.LifeCycle, org.mortbay.jetty.servlet.SessionHandler

Session Manager. The API required to manage sessions for a servlet context.
Author
Greg Wilkins

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
__MaxAgeProperty

Session Max Age.

public static final String
__SessionCookieProperty

Session cookie name.

public static final String
__SessionDomainProperty

Session Domain.

public static final String
__SessionIdPathParameterNameProperty

Session id path parameter name.

public static final String
__SessionPathProperty

Session Path.

Method Summary

Modifier and TypeMethod and Description
public Cookie

Returns:

the session cookie. If not null, this cookie should be set on the response to either migrate the session or to refresh a session cookie that may expire.
access
(HttpSession
the session object
session
,
boolean
whether the request is secure or not
secure
)

Called by the SessionHandler when a session is first accessed by a request.

public void
addEventListener(EventListener
the session event listener to add Individual SessionManagers implementations may accept arbitrary listener types, but they are expected to at least handle HttpSessionActivationListener, HttpSessionAttributeListener, HttpSessionBindingListener and HttpSessionListener.
listener
)

Adds an event listener for session-related events.

public void
clearEventListeners()

Removes all event listeners for session-related events.

public void
complete(HttpSession
the session object
session
)

Called by the SessionHandler when a session is last accessed by a request.

public String

Returns:

the unique id of the session within the cluster (without a node id extension)
getClusterId
(HttpSession
the session object
session
)

public boolean

Returns:

true if session cookies should be HTTP-only (Microsoft extension)
getHttpOnly
()

public HttpSession

Returns:

the HttpSession with the corresponding id or null if no session with the given id exists
getHttpSession
(String
the session id
id
)

Returns the HttpSession with the given session id

public SessionIdManager

Returns:

the cross context session id manager.
getIdManager
()

public int

Returns:

the max age to set on the session cookie, in seconds
getMaxCookieAge
()

public int

Returns:

the max period of inactivity, after which the session is invalidated, in seconds.
getMaxInactiveInterval
()

public SessionIdManager

Returns:

the cross context session id manager.
getMetaManager
()

Deprecated use getIdManager()
public String

Returns:

the unique id of the session within the cluster, extended with an optional node id.
getNodeId
(HttpSession
the session object
session
)

public boolean

Returns:

true if session cookies should be secure
getSecureCookies
()

public Cookie

Returns:

if this SessionManager uses cookies, then this method will return a new cookie object that should be set on the client in order to link future HTTP requests with the session. If cookies are not in use, this method returns null.
getSessionCookie
(HttpSession
the session to which the cookie should refer.
session
,
String
the context to which the cookie should be linked. The client will only send the cookie value when requesting resources under this path.
contextPath
,
boolean
whether the client is accessing the server over a secure protocol (i.e. HTTPS).
requestIsSecure
)

Gets a Cookie for a session.

public String

Returns:

the session cookie name, by default "JSESSIONID".
getSessionCookie
()

public String

Returns:

the domain to set on the session cookie
getSessionDomain
()

public String

Returns:

the URL path parameter name for session id URL rewriting, by default "jsessionid".
getSessionIdPathParameterName
()

public String

Returns:

a formatted version of getSessionIdPathParameterName(), by default ";" + sessionIdParameterName + "=", for easier lookup in URL strings.
getSessionIdPathParameterNamePrefix
()

public String

Returns:

the path to set on the session cookie
getSessionPath
()

public boolean

Returns:

whether the session management is handled via cookies.
isUsingCookies
()

public boolean

Returns:

whether the given session is valid, that is, it has not been invalidated.
isValid
(HttpSession
the session to test for validity
session
)

public HttpSession

Returns:

the new HttpSession
newHttpSession
(HttpServletRequest
the HttpServletRequest containing the requested session id
request
)

Creates a new HttpSession.

public void
removeEventListener(EventListener
the session event listener to remove
listener
)

Removes an event listener for for session-related events.

public void
setIdManager(SessionIdManager
the cross context session id manager.
idManager
)

Sets the cross context session id manager

public void
setMaxCookieAge(int
the max age to set on the session cookie, in seconds
maxCookieAge
)

Sets the max age to set on the session cookie, in seconds

public void
setMaxInactiveInterval(int
the max inactivity period, in seconds.
seconds
)

Sets the max period of inactivity, after which the session is invalidated, in seconds.

public void
setSessionCookie(String
the session cookie name
cookieName
)

Sets the session cookie name.

public void
setSessionDomain(String
the domain to set on the session cookie
domain
)

Sets the domain to set on the session cookie

public void
setSessionHandler(SessionHandler
the SessionHandler object
handler
)

Sets the SessionHandler.

public void
setSessionIdPathParameterName(String
the URL path parameter name for session id URL rewriting (null or "none" for no rewriting).
parameterName
)

Sets the session id URL path parameter name.

public void
setSessionPath(String
the path to set on the session cookie
path
)

Sets the path to set on the session cookie

Inherited from org.mortbay.component.LifeCycle:
addLifeCycleListenerisFailedisRunningisStartedisStartingisStoppedisStoppingremoveLifeCycleListenerstartstop

Field Detail

__DefaultSessionCookieback to summary
public static final String __DefaultSessionCookie
__DefaultSessionDomainback to summary
public static final String __DefaultSessionDomain
__DefaultSessionIdPathParameterNameback to summary
public static final String __DefaultSessionIdPathParameterName
__MaxAgePropertyback to summary
public static final String __MaxAgeProperty

Session Max Age. If this property is set as a ServletContext InitParam, then it is used as the max age for the session cookie. If it is not set, then a max age of -1 is used.

__SessionCookiePropertyback to summary
public static final String __SessionCookieProperty

Session cookie name. Defaults to JSESSIONID, but can be set with the org.mortbay.jetty.servlet.SessionCookie context init parameter.

__SessionDomainPropertyback to summary
public static final String __SessionDomainProperty

Session Domain. If this property is set as a ServletContext InitParam, then it is used as the domain for session cookies. If it is not set, then no domain is specified for the session cookie.

__SessionIdPathParameterNamePropertyback to summary
public static final String __SessionIdPathParameterNameProperty

Session id path parameter name. Defaults to jsessionid, but can be set with the org.mortbay.jetty.servlet.SessionIdPathParameterName context init parameter. If set to null or "none" no URL rewriting will be done.

__SessionPathPropertyback to summary
public static final String __SessionPathProperty

Session Path. If this property is set as a ServletContext InitParam, then it is used as the path for the session cookie. If it is not set, then the context path is used as the path for the cookie.

Method Detail

accessback to summary
public Cookie access(HttpSession session, boolean secure)

Called by the SessionHandler when a session is first accessed by a request.

Parameters
session:HttpSession

the session object

secure:boolean

whether the request is secure or not

Returns:Cookie

the session cookie. If not null, this cookie should be set on the response to either migrate the session or to refresh a session cookie that may expire.

See Also
complete(HttpSession)
addEventListenerback to summary
public void addEventListener(EventListener listener)

Adds an event listener for session-related events.

Parameters
listener:EventListener

the session event listener to add Individual SessionManagers implementations may accept arbitrary listener types, but they are expected to at least handle HttpSessionActivationListener, HttpSessionAttributeListener, HttpSessionBindingListener and HttpSessionListener.

See Also
removeEventListener(EventListener)
clearEventListenersback to summary
public void clearEventListeners()

Removes all event listeners for session-related events.

See Also
removeEventListener(EventListener)
completeback to summary
public void complete(HttpSession session)

Called by the SessionHandler when a session is last accessed by a request.

Parameters
session:HttpSession

the session object

See Also
access(HttpSession, boolean)
getClusterIdback to summary
public String getClusterId(HttpSession session)
Parameters
session:HttpSession

the session object

Returns:String

the unique id of the session within the cluster (without a node id extension)

See Also
getNodeId(HttpSession)
getHttpOnlyback to summary
public boolean getHttpOnly()
Returns:boolean

true if session cookies should be HTTP-only (Microsoft extension)

See Also
Cookie#isHttpOnly()
getHttpSessionback to summary
public HttpSession getHttpSession(String id)

Returns the HttpSession with the given session id

Parameters
id:String

the session id

Returns:HttpSession

the HttpSession with the corresponding id or null if no session with the given id exists

getIdManagerback to summary
public SessionIdManager getIdManager()
Returns:SessionIdManager

the cross context session id manager.

See Also
setIdManager(SessionIdManager)
getMaxCookieAgeback to summary
public int getMaxCookieAge()
Returns:int

the max age to set on the session cookie, in seconds

See Also
setMaxCookieAge(int)
getMaxInactiveIntervalback to summary
public int getMaxInactiveInterval()
Returns:int

the max period of inactivity, after which the session is invalidated, in seconds.

See Also
setMaxInactiveInterval(int)
getMetaManagerback to summary
public SessionIdManager getMetaManager()

Deprecated

use getIdManager()

Returns:SessionIdManager

the cross context session id manager.

getNodeIdback to summary
public String getNodeId(HttpSession session)
Parameters
session:HttpSession

the session object

Returns:String

the unique id of the session within the cluster, extended with an optional node id.

See Also
getClusterId(HttpSession)
getSecureCookiesback to summary
public boolean getSecureCookies()
Returns:boolean

true if session cookies should be secure

getSessionCookieback to summary
public Cookie getSessionCookie(HttpSession session, String contextPath, boolean requestIsSecure)

Gets a Cookie for a session.

Parameters
session:HttpSession

the session to which the cookie should refer.

contextPath:String

the context to which the cookie should be linked. The client will only send the cookie value when requesting resources under this path.

requestIsSecure:boolean

whether the client is accessing the server over a secure protocol (i.e. HTTPS).

Returns:Cookie

if this SessionManager uses cookies, then this method will return a new cookie object that should be set on the client in order to link future HTTP requests with the session. If cookies are not in use, this method returns null.

getSessionCookieback to summary
public String getSessionCookie()
Returns:String

the session cookie name, by default "JSESSIONID".

See Also
setSessionCookie(String)
getSessionDomainback to summary
public String getSessionDomain()
Returns:String

the domain to set on the session cookie

See Also
setSessionDomain(String)
getSessionIdPathParameterNameback to summary
public String getSessionIdPathParameterName()
Returns:String

the URL path parameter name for session id URL rewriting, by default "jsessionid".

See Also
setSessionIdPathParameterName(String)
getSessionIdPathParameterNamePrefixback to summary
public String getSessionIdPathParameterNamePrefix()
Returns:String

a formatted version of getSessionIdPathParameterName(), by default ";" + sessionIdParameterName + "=", for easier lookup in URL strings.

See Also
getSessionIdPathParameterName()
getSessionPathback to summary
public String getSessionPath()
Returns:String

the path to set on the session cookie

See Also
setSessionPath(String)
isUsingCookiesback to summary
public boolean isUsingCookies()
Returns:boolean

whether the session management is handled via cookies.

isValidback to summary
public boolean isValid(HttpSession session)
Parameters
session:HttpSession

the session to test for validity

Returns:boolean

whether the given session is valid, that is, it has not been invalidated.

newHttpSessionback to summary
public HttpSession newHttpSession(HttpServletRequest request)

Creates a new HttpSession.

Parameters
request:HttpServletRequest

the HttpServletRequest containing the requested session id

Returns:HttpSession

the new HttpSession

removeEventListenerback to summary
public void removeEventListener(EventListener listener)

Removes an event listener for for session-related events.

Parameters
listener:EventListener

the session event listener to remove

See Also
addEventListener(EventListener)
setIdManagerback to summary
public void setIdManager(SessionIdManager idManager)

Sets the cross context session id manager

Parameters
idManager:SessionIdManager

the cross context session id manager.

See Also
getIdManager()
setMaxCookieAgeback to summary
public void setMaxCookieAge(int maxCookieAge)

Sets the max age to set on the session cookie, in seconds

Parameters
maxCookieAge:int

the max age to set on the session cookie, in seconds

See Also
getMaxCookieAge()
setMaxInactiveIntervalback to summary
public void setMaxInactiveInterval(int seconds)

Sets the max period of inactivity, after which the session is invalidated, in seconds.

Parameters
seconds:int

the max inactivity period, in seconds.

See Also
getMaxInactiveInterval()
setSessionCookieback to summary
public void setSessionCookie(String cookieName)

Sets the session cookie name.

Parameters
cookieName:String

the session cookie name

See Also
getSessionCookie()
setSessionDomainback to summary
public void setSessionDomain(String domain)

Sets the domain to set on the session cookie

Parameters
domain:String

the domain to set on the session cookie

See Also
getSessionDomain()
setSessionHandlerback to summary
public void setSessionHandler(SessionHandler handler)

Sets the SessionHandler.

Parameters
handler:SessionHandler

the SessionHandler object

setSessionIdPathParameterNameback to summary
public void setSessionIdPathParameterName(String parameterName)

Sets the session id URL path parameter name.

Parameters
parameterName:String

the URL path parameter name for session id URL rewriting (null or "none" for no rewriting).

See Also
getSessionIdPathParameterName(), getSessionIdPathParameterNamePrefix()
setSessionPathback to summary
public void setSessionPath(String path)

Sets the path to set on the session cookie

Parameters
path:String

the path to set on the session cookie

See Also
getSessionPath()