- All Known Implementing Classes:
SessionStore.InMemory
- Since:
- 2.0.0
- Author:
- edgar
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBase class for in-memory session store. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault session timeout in minutes. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteSession(Context ctx, Session session) Delete a session from store.findSession(Context ctx) Find an existing session by ID.static SessionStorememory()Creates a cookie based session and store data in memory.static SessionStorememory(int timeout) Creates a cookie based session and store data in memory.static SessionStoreCreates a cookie based session and store data in memory.static SessionStoreCreates a cookie based session and store data in memory.static SessionStorememory(SessionToken token) Creates a session store that save data in memory. - Session expires after 30 minutes of inactivity. - Session data is not keep after restart.static SessionStorememory(SessionToken token, Duration timeout) Creates a session store that save data in memory.static SessionStoreCreates a cookie based session and store data in memory.newSession(Context ctx) Creates a new session.voidrenewSessionId(Context ctx, Session session) Renew Session ID.voidsaveSession(Context ctx, Session session) Save a session.static SessionStoresigned(SessionToken token, Function<String, Map<String, String>> decoder, Function<Map<String, String>, String> encoder) Creates a session store that save data into Cookie.static SessionStoreCreates a session store that uses (un)signed data.static SessionStoreCreates a session store that uses (un)signed data.static SessionStoresigned(String secret, SessionToken token) Creates a session store that uses (un)signed data.voidtouchSession(Context ctx, Session session) Session attributes/state has changed.
-
Field Details
-
DEFAULT_TIMEOUT
static final int DEFAULT_TIMEOUTDefault session timeout in minutes.- See Also:
-
-
Method Details
-
newSession
Creates a new session. This method must:- Set session as new
Session.setNew(boolean)- Optionally, set session creation timeSession.setCreationTime(Instant)- Optionally, set session last accessed timeSession.setLastAccessedTime(Instant)- Parameters:
ctx- Web context.- Returns:
- A new session.
-
findSession
Find an existing session by ID. For existing session this method must:- Optionally, Retrieve/restore session creation time - Optionally, Set session last accessed time
Session.setLastAccessedTime(Instant)- Parameters:
ctx- Web context.- Returns:
- An existing session or
null.
-
deleteSession
Delete a session from store. This method must NOT callSession.destroy().- Parameters:
ctx- Web context.session- Current session.
-
touchSession
Session attributes/state has changed. Every time a session attribute is put or removed it, this method is executed as notification callback.- Parameters:
ctx- Web context.session- Current session.
-
saveSession
Save a session. This method must save:- Session attributes/data - Optionally set Session metadata like: creationTime, lastAccessed time, etc.
This method is call after response is send to client, so context and response shouldn't be modified.
- Parameters:
ctx- Web context.session- Current session.
-
renewSessionId
Renew Session ID. This operation might or might not be implemented by a Session Store.- Parameters:
ctx- Web Context.session- Session.
-
memory
Creates a cookie based session and store data in memory. Session data is not keep after restart.It uses the default session cookie:
SessionToken.SID.- Session data is not keep after restart.
- Parameters:
timeout- Timeout in seconds. Use-1for no timeout.- Returns:
- Session store.
-
memory
Creates a cookie based session and store data in memory. Session data is not keep after restart.It uses the default session cookie:
SessionToken.SID.- Session expires after 30 minutes of inactivity. - Session data is not keep after restart.
- Returns:
- Session store.
-
memory
Creates a cookie based session and store data in memory. Session data is not keep after restart.It uses the default session cookie:
SessionToken.SID.- Parameters:
timeout- Expires session after amount of inactivity time.- Returns:
- Session store.
-
memory
Creates a cookie based session and store data in memory.- Session expires after 30 minutes of inactivity. - Session data is not keep after restart.
- Parameters:
cookie- Cookie to use.- Returns:
- Session store.
-
memory
Creates a cookie based session and store data in memory. Session data is not keep after restart.- Parameters:
cookie- Cookie to use.timeout- Expires session after amount of inactivity time.- Returns:
- Session store.
-
memory
Creates a session store that save data in memory. - Session expires after 30 minutes of inactivity. - Session data is not keep after restart.- Parameters:
token- Session token.- Returns:
- Session store.
-
memory
Creates a session store that save data in memory. Session data is not keep after restart.- Parameters:
token- Session token.timeout- Expires session after amount of inactivity time.- Returns:
- Session store.
-
signed
Creates a session store that uses (un)signed data. Session data is signed it usingHMAC_SHA256.See
Cookie.sign(String, String)andCookie.unsign(String, String).- Parameters:
secret- Secret token to signed data.- Returns:
- A browser session store.
-
signed
Creates a session store that uses (un)signed data. Session data is signed it usingHMAC_SHA256.See
Cookie.sign(String, String)andCookie.unsign(String, String).- Parameters:
secret- Secret token to signed data.cookie- Cookie to use.- Returns:
- A browser session store.
-
signed
Creates a session store that uses (un)signed data. Session data is signed it usingHMAC_SHA256.See
Cookie.sign(String, String)andCookie.unsign(String, String).- Parameters:
secret- Secret token to signed data.token- Session token to use.- Returns:
- A browser session store.
-
signed
@NonNull static SessionStore signed(@NonNull SessionToken token, @NonNull Function<String, Map<String, String>> decoder, @NonNull Function<Map<String, String>, String> encoder) Creates a session store that save data into Cookie. Cookie data is (un)signed it using the given decoder and encoder.- Parameters:
token- Token to use.decoder- Decoder to use.encoder- Encoder to use.- Returns:
- Cookie session store.
-