public interface NativeSessionManager extends SessionManager
Native
session manager is one that manages sessions natively - that is, it is directly responsible
for the creation, persistence and removal of Session
instances and their
lifecycles.Modifier and Type | Method and Description |
---|---|
void |
checkValid(SessionKey key)
Returns quietly if the associated session is valid (it exists and is not stopped or expired) or throws
an
InvalidSessionException indicating that the session id is invalid. |
Object |
getAttribute(SessionKey sessionKey,
Object attributeKey)
Returns the object bound to the associated session identified by the specified attribute key.
|
Collection<Object> |
getAttributeKeys(SessionKey sessionKey)
Returns all attribute keys maintained by the target session or an empty collection if there are no attributes.
|
String |
getHost(SessionKey key)
Returns the host name or IP string of the host where the session was started, if known.
|
Date |
getLastAccessTime(SessionKey key)
Returns the time the associated
Session last interacted with the system. |
Date |
getStartTimestamp(SessionKey key)
Returns the time the associated
Session started (was created). |
long |
getTimeout(SessionKey key)
Returns the time in milliseconds that the associated session may remain idle before expiring.
|
boolean |
isValid(SessionKey key)
Returns
true if the associated session is valid (it exists and is not stopped nor expired),
false otherwise. |
Object |
removeAttribute(SessionKey sessionKey,
Object attributeKey)
Removes (unbinds) the object bound to associated
Session under the given attributeKey . |
void |
setAttribute(SessionKey sessionKey,
Object attributeKey,
Object value)
Binds the specified
value to the associated session uniquely identified by the attributeKey . |
void |
setTimeout(SessionKey key,
long maxIdleTimeInMillis)
Sets the time in milliseconds that the associated session may remain idle before expiring.
|
void |
stop(SessionKey key)
Explicitly stops the associated session, thereby releasing all of its resources.
|
void |
touch(SessionKey key)
Updates the last accessed time of the session identified by
sessionId . |
getSession, start
Date getStartTimestamp(SessionKey key)
Session
started (was created).key
- the session key to use to look up the target session.Session
started (was created).Session.getStartTimestamp()
Date getLastAccessTime(SessionKey key)
Session
last interacted with the system.key
- the session key to use to look up the target session.Session.getLastAccessTime()
,
Session.touch()
boolean isValid(SessionKey key)
true
if the associated session is valid (it exists and is not stopped nor expired),
false
otherwise.key
- the session key to use to look up the target session.true
if the session is valid (exists and is not stopped or expired), false
otherwise.void checkValid(SessionKey key) throws InvalidSessionException
InvalidSessionException
indicating that the session id is invalid. This
might be preferred to be used instead of isValid(org.apache.shiro.session.mgt.SessionKey)
since any exception thrown will definitively explain
the reason for invalidation.key
- the session key to use to look up the target session.InvalidSessionException
- if the session id is invalid (it does not exist or it is stopped or expired).long getTimeout(SessionKey key) throws InvalidSessionException
key
- the session key to use to look up the target session.InvalidSessionException
- if the session has been stopped or expired prior to calling this method.void setTimeout(SessionKey key, long maxIdleTimeInMillis) throws InvalidSessionException
key
- the session key to use to look up the target session.maxIdleTimeInMillis
- the time in milliseconds that the associated session may remain idle before expiring.InvalidSessionException
- if the session has been stopped or expired prior to calling this method.void touch(SessionKey key) throws InvalidSessionException
sessionId
. This
can be used to explicitly ensure that a session does not time out.key
- the session key to use to look up the target session.InvalidSessionException
- if the session has been stopped or expired prior to calling this method.Session.touch()
String getHost(SessionKey key)
null
key
- the session key to use to look up the target session.null
.void stop(SessionKey key) throws InvalidSessionException
key
- the session key to use to look up the target session.InvalidSessionException
- if the session has stopped or expired prior to calling this method.Session.stop()
Collection<Object> getAttributeKeys(SessionKey sessionKey)
sessionKey
- the session key to use to look up the target session.InvalidSessionException
- if the associated session has stopped or expired prior to calling this method.Session.getAttributeKeys()
Object getAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException
null
is returned.sessionKey
- session key to use to look up the target session.attributeKey
- the unique name of the object bound to the associated sessionattributeKey
or null
if there is no object bound.InvalidSessionException
- if the specified session has stopped or expired prior to calling this method.Session.getAttribute(Object key)
void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) throws InvalidSessionException
value
to the associated session uniquely identified by the attributeKey
.
If there is already a session attribute bound under the attributeKey
, that existing object will be
replaced by the new value
.
If the value
parameter is null, it has the same effect as if the
removeAttribute(SessionKey sessionKey, Object attributeKey)
method was called.sessionKey
- the session key to use to look up the target session.attributeKey
- the key under which the value
object will be bound in this sessionvalue
- the object to bind in this session.InvalidSessionException
- if the specified session has stopped or expired prior to calling this method.Session.setAttribute(Object key, Object value)
Object removeAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException
Session
under the given attributeKey
.sessionKey
- session key to use to look up the target session.attributeKey
- the key uniquely identifying the object to removenull
if there was no object bound under the specified attributeKey
.InvalidSessionException
- if the specified session has stopped or expired prior to calling this method.Session.removeAttribute(Object key)
Copyright © 2004–2016 The Apache Software Foundation. All rights reserved.