NativeSessionManager

A {@code Native} session manager is one that manages sessions natively - that is, it is directly responsible for the creation, persistence and removal of {@link hunt.shiro.session.Session Session} instances and their lifecycles.

Members

Functions

checkValid
void checkValid(SessionKey key)

Returns quietly if the associated session is valid (it exists and is not stopped or expired) or throws an {@link hunt.shiro.session.InvalidSessionException} indicating that the session id is invalid. This might be preferred to be used instead of {@link #isValid} since any exception thrown will definitively explain the reason for invalidation.

getAttribute
Object getAttribute(SessionKey sessionKey, Object attributeKey)

Returns the object bound to the associated session identified by the specified attribute key. If there is no object bound under the attribute key for the given session, {@code null} is returned.

getAttributeKeys
Object[] getAttributeKeys(SessionKey sessionKey)

Returns all attribute keys maintained by the target session or an empty collection if there are no attributes.

getHost
string getHost(SessionKey key)

Returns the host name or IP string of the host where the session was started, if known. If no host name or IP was specified when starting the session, this method returns {@code null}

getLastAccessTime
Date getLastAccessTime(SessionKey key)

Returns the time the associated {@code Session} last interacted with the system.

getStartTimestamp
Date getStartTimestamp(SessionKey key)

Returns the time the associated {@code Session} started (was created).

getTimeout
long getTimeout(SessionKey key)

Returns the time in milliseconds that the associated session may remain idle before expiring. <ul> <li>A negative return value means the session will never expire.</li> <li>A non-negative return value (0 or greater) means the session expiration will occur if idle for that length of time.</li> </ul>

isValid
bool isValid(SessionKey key)

Returns {@code true} if the associated session is valid (it exists and is not stopped nor expired), {@code false} otherwise.

removeAttribute
Object removeAttribute(SessionKey sessionKey, Object attributeKey)

Removes (unbinds) the object bound to associated {@code Session} under the given {@code attributeKey}.

setAttribute
void setAttribute(SessionKey sessionKey, Object attributeKey, Object value)

Binds the specified {@code value} to the associated session uniquely identified by the {@code attributeKey}. If there is already a session attribute bound under the {@code attributeKey}, that existing object will be replaced by the new {@code value}. <p/> If the {@code value} parameter is null, it has the same effect as if the {@link #removeAttribute(SessionKey sessionKey, Object attributeKey)} method was called.

setTimeout
void setTimeout(SessionKey key, long maxIdleTimeInMillis)

Sets the time in milliseconds that the associated session may remain idle before expiring. <ul> <li>A negative return value means the session will never expire.</li> <li>A non-negative return value (0 or greater) means the session expiration will occur if idle for that length of time.</li> </ul>

stop
void stop(SessionKey key)

Explicitly stops the associated session, thereby releasing all of its resources.

touch
void touch(SessionKey key)

Updates the last accessed time of the session identified by <code>sessionId</code>. This can be used to explicitly ensure that a session does not time out.

Inherited Members

From SessionManager

start
Session start(SessionContext context)

Starts a new session based on the specified contextual initialization data, which can be used by the underlying implementation to determine how exactly to create the internal Session instance. <p/> This method is mainly used in framework development, as the implementation will often relay the argument to an underlying {@link SessionFactory} which could use the context to construct the internal Session instance in a specific manner. This allows pluggable {@link hunt.shiro.session.Session Session} creation logic by simply injecting a {@code SessionFactory} into the {@code SessionManager} instance.

getSession
Session getSession(SessionKey key)

Retrieves the session corresponding to the specified contextual data (such as a session ID if applicable), or {@code null} if no Session could be found. If a session is found but invalid (stopped or expired), a {@link SessionException} will be thrown.

Meta