public interface SessionStore
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(SessionToken token)
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.
|
@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()
SessionToken.SID
.@Nonnull static SessionStore memory(@Nonnull Cookie cookie)
cookie
- Cookie to use.@Nonnull static SessionStore memory(@Nonnull SessionToken token)
token
- Session token.@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 © 2020. All rights reserved.