public interface Session
Sessions persist between HTTP requests for a single browser session. They are deleted when the browser is closed, or they time-out. Session cookies are used to maintain sessions using a secure UUID.
Sessions can be used to maintain data for a browser session, e.g. a shopping basket.
The context must have first been routed to a SessionHandler
for sessions to be available.
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
data() |
void |
destroy()
Destroy the session
|
<T> T |
get(String key)
Get some data from the session
|
JsonObject |
getPrincipal()
Get the principal
|
void |
hasPermission(String permission,
Handler<AsyncResult<Boolean>> resultHandler)
Does the logged in user have the specified permissions? Information is cached for the lifetime of the session
|
void |
hasPermissions(Set<String> permissions,
Handler<AsyncResult<Boolean>> resultHandler)
Does the logged in user have the specified permissions? Information is cached for the lifetime of the session
|
void |
hasRole(String role,
Handler<AsyncResult<Boolean>> resultHandler)
Does the logged in user have the specified role? Information is cached for the lifetime of the session
|
void |
hasRoles(Set<String> roles,
Handler<AsyncResult<Boolean>> resultHandler)
Does the logged in user have the specified roles? Information is cached for the lifetime of the session
|
String |
id() |
boolean |
isDestroyed() |
boolean |
isLoggedIn() |
long |
lastAccessed() |
void |
logout()
Logout the user.
|
Session |
put(String key,
Object obj)
Put some data in a session
|
<T> T |
remove(String key)
Remove some data from the session
|
SessionStore |
sessionStore() |
void |
setAccessed()
Mark the session as being accessed.
|
void |
setAuthProvider(AuthProvider authProvider)
Set the auth provider
|
void |
setPrincipal(JsonObject principal)
Set the principal (the unique user id) of the user -this signifies the user is logged in
|
long |
timeout() |
String id()
Session put(String key, Object obj)
key
- the key for the dataobj
- the data<T> T get(String key)
key
- the key of the data<T> T remove(String key)
key
- the key of the datalong lastAccessed()
void destroy()
boolean isDestroyed()
boolean isLoggedIn()
void setPrincipal(JsonObject principal)
principal
- the principalJsonObject getPrincipal()
void hasRole(String role, Handler<AsyncResult<Boolean>> resultHandler)
role
- the roleresultHandler
- will be called with a result true/falsevoid hasPermission(String permission, Handler<AsyncResult<Boolean>> resultHandler)
permission
- the permissionresultHandler
- will be called with a result true/falsevoid hasRoles(Set<String> roles, Handler<AsyncResult<Boolean>> resultHandler)
roles
- the rolesresultHandler
- will be called with a result true/falsevoid hasPermissions(Set<String> permissions, Handler<AsyncResult<Boolean>> resultHandler)
permissions
- the permissionsresultHandler
- will be called with a result true/falsevoid logout()
long timeout()
SessionStore sessionStore()
void setAccessed()
void setAuthProvider(AuthProvider authProvider)
authProvider
- the auth providerCopyright © 2015. All Rights Reserved.