public interface SessionStore
Modifier and Type | Interface and Description |
---|---|
static class |
SessionStore.InMemory
Base class for in-memory session store.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TIMEOUT
Default session timeout in minutes.
|
Modifier and Type | Method and Description |
---|---|
void |
deleteSession(Context ctx,
Session session)
Delete a session from store.
|
Session |
findSession(Context ctx)
Find an existing session by ID.
|
static SessionStore |
memory()
Creates a cookie based session and store data in memory.
|
static SessionStore |
memory(Cookie cookie)
Creates a cookie based session and store data in memory.
|
static SessionStore |
memory(Cookie cookie,
Duration timeout)
Creates a cookie based session and store data in memory.
|
static SessionStore |
memory(Duration timeout)
Creates a cookie based session and store data in memory.
|
static SessionStore |
memory(int timeout)
Creates a cookie based session and store data in memory.
|
static SessionStore |
memory(SessionToken token)
Creates a session store that save data in memory.
|
static SessionStore |
memory(SessionToken token,
Duration timeout)
Creates a session store that save data in memory.
|
Session |
newSession(Context ctx)
Creates a new session.
|
void |
renewSessionId(Context ctx,
Session session)
Renew Session ID.
|
void |
saveSession(Context ctx,
Session session)
Save a session.
|
static SessionStore |
signed(SessionToken token,
Function<String,Map<String,String>> decoder,
Function<Map<String,String>,String> encoder)
Creates a session store that save data into Cookie.
|
static SessionStore |
signed(String secret)
Creates a session store that uses (un)signed data.
|
static SessionStore |
signed(String secret,
Cookie cookie)
Creates a session store that uses (un)signed data.
|
static SessionStore |
signed(String secret,
SessionToken token)
Creates a session store that uses (un)signed data.
|
void |
touchSession(Context ctx,
Session session)
Session attributes/state has changed.
|
static final int DEFAULT_TIMEOUT
@Nonnull Session newSession(@Nonnull Context ctx)
Session.setNew(boolean)
- Optionally, set session creation time Session.setCreationTime(Instant)
- Optionally, set session last accessed time Session.setLastAccessedTime(Instant)
ctx
- Web context.@Nullable Session findSession(@Nonnull Context ctx)
Session.setLastAccessedTime(Instant)
ctx
- Web context.null
.void deleteSession(@Nonnull Context ctx, @Nonnull Session session)
Session.destroy()
.ctx
- Web context.session
- Current session.void touchSession(@Nonnull Context ctx, @Nonnull Session session)
ctx
- Web context.session
- Current session.void saveSession(@Nonnull Context ctx, @Nonnull Session session)
ctx
- Web context.session
- Current session.void renewSessionId(@Nonnull Context ctx, @Nonnull Session session)
ctx
- Web Context.session
- Session.@Nonnull static SessionStore memory(int timeout)
SessionToken.SID
.
- Session data is not keep after restart.timeout
- Timeout in seconds. Use -1
for no timeout.@Nonnull static SessionStore memory()
SessionToken.SID
.
- Session expires after 30 minutes of inactivity.
- Session data is not keep after restart.@Nonnull static SessionStore memory(@Nonnull Duration timeout)
SessionToken.SID
.timeout
- Expires session after amount of inactivity time.@Nonnull static SessionStore memory(@Nonnull Cookie cookie)
cookie
- Cookie to use.@Nonnull static SessionStore memory(@Nonnull Cookie cookie, @Nonnull Duration timeout)
cookie
- Cookie to use.timeout
- Expires session after amount of inactivity time.@Nonnull static SessionStore memory(@Nonnull SessionToken token)
token
- Session token.@Nonnull static SessionStore memory(@Nonnull SessionToken token, @Nonnull Duration timeout)
token
- Session token.timeout
- Expires session after amount of inactivity time.@Nonnull static SessionStore signed(@Nonnull String secret)
HMAC_SHA256
.
See Cookie.sign(String, String)
and Cookie.unsign(String, String)
.secret
- Secret token to signed data.@Nonnull static SessionStore signed(@Nonnull String secret, @Nonnull Cookie cookie)
HMAC_SHA256
.
See Cookie.sign(String, String)
and Cookie.unsign(String, String)
.secret
- Secret token to signed data.cookie
- Cookie to use.@Nonnull static SessionStore signed(@Nonnull String secret, @Nonnull SessionToken token)
HMAC_SHA256
.
See Cookie.sign(String, String)
and Cookie.unsign(String, String)
.secret
- Secret token to signed data.token
- Session token to use.@Nonnull static SessionStore signed(@Nonnull SessionToken token, @Nonnull Function<String,Map<String,String>> decoder, @Nonnull Function<Map<String,String>,String> encoder)
token
- Token to use.decoder
- Decoder to use.encoder
- Encoder to use.Copyright © 2023. All rights reserved.