public interface SessionToken
Context
.Modifier and Type | Interface and Description |
---|---|
static class |
SessionToken.CookieID
Looks for a session ID from request cookie headers.
|
static class |
SessionToken.HeaderID
Looks for a session ID from request headers.
|
static class |
SessionToken.SignedCookie
Looks for a session token from request cookie.
|
Modifier and Type | Field and Description |
---|---|
static int |
ID_SIZE
Size of default token generator.
|
static SecureRandom |
RND
Secure random for default session token generator.
|
static Cookie |
SID
Default cookie for cookie based session stores.
|
Modifier and Type | Method and Description |
---|---|
static SessionToken |
combine(SessionToken... tokens)
Combine/compose two or more session tokens.
|
static SessionToken |
cookieId(Cookie cookie)
Create a cookie-based Session ID.
|
void |
deleteToken(Context ctx,
String token)
Delete session ID in the web context.
|
String |
findToken(Context ctx)
Find session ID.
|
static SessionToken |
header(String name)
Create a header-based Session Token.
|
default String |
newToken()
Generate a new token.
|
void |
saveToken(Context ctx,
String token)
Save session ID in the web context.
|
static SessionToken |
signedCookie(Cookie cookie)
Create a signed-cookie-based Session token.
|
static final Cookie SID
jooby.sid
as name. It never expires, use the root, only for HTTP.static final SecureRandom RND
static final int ID_SIZE
@Nonnull default String newToken()
ID_SIZE
.@Nullable String findToken(@Nonnull Context ctx)
ctx
- Web context.null
.void saveToken(@Nonnull Context ctx, @Nonnull String token)
ctx
- Web context.token
- Token/data to save.void deleteToken(@Nonnull Context ctx, @Nonnull String token)
ctx
- Web context.token
- Token/data to delete.@Nonnull static SessionToken cookieId(@Nonnull Cookie cookie)
cookie
- Cookie to use.@Nonnull static SessionToken signedCookie(@Nonnull Cookie cookie)
cookie
- Cookie to use.@Nonnull static SessionToken header(@Nonnull String name)
name
- Header name.@Nonnull static SessionToken combine(@Nonnull SessionToken... tokens)
SessionToken token = SessionToken.combine(
SessionToken.header("TOKEN"),
SessionToken.cookie(SID)
);
On new session, creates a response header and cookie.
On save token, generates a response header or cookie based on best matches.
On delete token, generates a response header or cookie based on best matches.tokens
- Tokens to use.Copyright © 2022. All rights reserved.