Class SessionHandler
- java.lang.Object
-
- io.vertx.mutiny.ext.web.handler.SessionHandler
-
- All Implemented Interfaces:
io.vertx.core.Handler<RoutingContext>
,Consumer<RoutingContext>
public class SessionHandler extends Object implements io.vertx.core.Handler<RoutingContext>, Consumer<RoutingContext>
A handler that maintains aSession
for each browser session.It looks up the session for each request based on a session cookie which contains a session ID. It stores the session when the response is ended in the session store.
The session is available on the routing context with .
NOTE: This class has been automatically generated from theoriginal
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<SessionHandler>
__TYPE_ARG
static boolean
DEFAULT_COOKIE_HTTP_ONLY_FLAG
Default of whether the cookie has the HttpOnly flag set More info: https://www.owasp.org/index.php/HttpOnlystatic boolean
DEFAULT_COOKIE_SECURE_FLAG
Default of whether the cookie has the 'secure' flag set to allow transmission over https only.static boolean
DEFAULT_LAZY_SESSION
Default of whether the session should be created lazily.static boolean
DEFAULT_NAG_HTTPS
Default of whether a nagging log warning should be written if the session handler is accessed over HTTP, not HTTPSstatic String
DEFAULT_SESSION_COOKIE_NAME
Default name of session cookiestatic String
DEFAULT_SESSION_COOKIE_PATH
Default path of session cookiestatic long
DEFAULT_SESSION_TIMEOUT
Default time, in ms, that a session lasts for without being accessed before expiring.static int
DEFAULT_SESSIONID_MIN_LENGTH
Default min length for a session id.
-
Constructor Summary
Constructors Constructor Description SessionHandler(io.vertx.ext.web.handler.SessionHandler delegate)
SessionHandler(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(RoutingContext item)
static SessionHandler
create(SessionStore sessionStore)
boolean
equals(Object o)
io.smallrye.mutiny.Uni<Void>
flush(RoutingContext ctx)
Flush a context session earlier to the store, this will allow the end user to have full control on the event of a failure at the store level.io.smallrye.mutiny.Uni<Void>
flush(RoutingContext ctx, boolean ignoreStatus)
Flush a context session earlier to the store, this will allow the end user to have full control on the event of a failure at the store level.Void
flushAndAwait(RoutingContext ctx)
Blocking variant offlush(io.vertx.mutiny.ext.web.RoutingContext)
.Void
flushAndAwait(RoutingContext ctx, boolean ignoreStatus)
Blocking variant offlush(io.vertx.mutiny.ext.web.RoutingContext,boolean)
.SessionHandler
flushAndForget(RoutingContext ctx)
Variant offlush(io.vertx.mutiny.ext.web.RoutingContext)
that ignores the result of the operation.SessionHandler
flushAndForget(RoutingContext ctx, boolean ignoreStatus)
Variant offlush(io.vertx.mutiny.ext.web.RoutingContext,boolean)
that ignores the result of the operation.io.vertx.ext.web.handler.SessionHandler
getDelegate()
void
handle(RoutingContext arg0)
int
hashCode()
static SessionHandler
newInstance(io.vertx.ext.web.handler.SessionHandler arg)
Session
newSession(RoutingContext context)
SessionHandler
setCookieHttpOnlyFlag(boolean httpOnly)
SessionHandler
setCookieless(boolean cookieless)
SessionHandler
setCookieMaxAge(long cookieMaxAge)
SessionHandler
setCookieSameSite(io.vertx.core.http.CookieSameSite policy)
SessionHandler
setCookieSecureFlag(boolean secure)
SessionHandler
setLazySession(boolean lazySession)
SessionHandler
setMinLength(int minLength)
SessionHandler
setNagHttps(boolean nag)
SessionHandler
setSessionCookieName(String sessionCookieName)
SessionHandler
setSessionCookiePath(String sessionCookiePath)
SessionHandler
setSessionTimeout(long timeout)
io.smallrye.mutiny.Uni<Void>
setUser(RoutingContext context, User user)
Set the user for the sessionVoid
setUserAndAwait(RoutingContext context, User user)
Blocking variant ofsetUser(io.vertx.mutiny.ext.web.RoutingContext,io.vertx.mutiny.ext.auth.User)
.SessionHandler
setUserAndForget(RoutingContext context, User user)
Variant ofsetUser(io.vertx.mutiny.ext.web.RoutingContext,io.vertx.mutiny.ext.auth.User)
that ignores the result of the operation.String
toString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<SessionHandler> __TYPE_ARG
-
DEFAULT_SESSION_COOKIE_NAME
public static final String DEFAULT_SESSION_COOKIE_NAME
Default name of session cookie- See Also:
- Constant Field Values
-
DEFAULT_SESSION_COOKIE_PATH
public static final String DEFAULT_SESSION_COOKIE_PATH
Default path of session cookie- See Also:
- Constant Field Values
-
DEFAULT_SESSION_TIMEOUT
public static final long DEFAULT_SESSION_TIMEOUT
Default time, in ms, that a session lasts for without being accessed before expiring.- See Also:
- Constant Field Values
-
DEFAULT_NAG_HTTPS
public static final boolean DEFAULT_NAG_HTTPS
Default of whether a nagging log warning should be written if the session handler is accessed over HTTP, not HTTPS- See Also:
- Constant Field Values
-
DEFAULT_COOKIE_HTTP_ONLY_FLAG
public static final boolean DEFAULT_COOKIE_HTTP_ONLY_FLAG
Default of whether the cookie has the HttpOnly flag set More info: https://www.owasp.org/index.php/HttpOnly- See Also:
- Constant Field Values
-
DEFAULT_COOKIE_SECURE_FLAG
public static final boolean DEFAULT_COOKIE_SECURE_FLAG
Default of whether the cookie has the 'secure' flag set to allow transmission over https only. More info: https://www.owasp.org/index.php/SecureFlag- See Also:
- Constant Field Values
-
DEFAULT_SESSIONID_MIN_LENGTH
public static final int DEFAULT_SESSIONID_MIN_LENGTH
Default min length for a session id. More info: https://www.owasp.org/index.php/Session_Management_Cheat_Sheet- See Also:
- Constant Field Values
-
DEFAULT_LAZY_SESSION
public static final boolean DEFAULT_LAZY_SESSION
Default of whether the session should be created lazily.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SessionHandler
public SessionHandler(io.vertx.ext.web.handler.SessionHandler delegate)
-
SessionHandler
public SessionHandler(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.ext.web.handler.SessionHandler getDelegate()
-
handle
public void handle(RoutingContext arg0)
- Specified by:
handle
in interfaceio.vertx.core.Handler<RoutingContext>
-
create
public static SessionHandler create(SessionStore sessionStore)
- Parameters:
sessionStore
- the session store- Returns:
- the handler
-
setSessionTimeout
public SessionHandler setSessionTimeout(long timeout)
- Parameters:
timeout
- the timeout, in ms.- Returns:
- a reference to this, so the API can be used fluently
-
setNagHttps
public SessionHandler setNagHttps(boolean nag)
- Parameters:
nag
- true to nag- Returns:
- a reference to this, so the API can be used fluently
-
setCookieSecureFlag
public SessionHandler setCookieSecureFlag(boolean secure)
- Parameters:
secure
- true to set the secure flag on the cookie- Returns:
- a reference to this, so the API can be used fluently
-
setCookieHttpOnlyFlag
public SessionHandler setCookieHttpOnlyFlag(boolean httpOnly)
- Parameters:
httpOnly
- true to set the HttpOnly flag on the cookie- Returns:
- a reference to this, so the API can be used fluently
-
setSessionCookieName
public SessionHandler setSessionCookieName(String sessionCookieName)
- Parameters:
sessionCookieName
- the session cookie name- Returns:
- a reference to this, so the API can be used fluently
-
setSessionCookiePath
public SessionHandler setSessionCookiePath(String sessionCookiePath)
- Parameters:
sessionCookiePath
- the session cookie path- Returns:
- a reference to this, so the API can be used fluently
-
setMinLength
public SessionHandler setMinLength(int minLength)
- Parameters:
minLength
- the session id minimal length- Returns:
- a reference to this, so the API can be used fluently
-
setCookieSameSite
public SessionHandler setCookieSameSite(io.vertx.core.http.CookieSameSite policy)
- Parameters:
policy
- to use,null
for no policy.- Returns:
- a reference to this, so the API can be used fluently
-
setLazySession
public SessionHandler setLazySession(boolean lazySession)
- Parameters:
lazySession
- true to have a lazy session creation.- Returns:
- a reference to this, so the API can be used fluently
-
setCookieMaxAge
public SessionHandler setCookieMaxAge(long cookieMaxAge)
- Parameters:
cookieMaxAge
- a non negative max-age, note that 0 means expire now.- Returns:
- a reference to this, so the API can be used fluently
-
flush
public io.smallrye.mutiny.Uni<Void> flush(RoutingContext ctx)
Flush a context session earlier to the store, this will allow the end user to have full control on the event of a failure at the store level. Once a session is flushed no automatic save will be performed at end of request.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
ctx
- the current context- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
flushAndAwait
public Void flushAndAwait(RoutingContext ctx)
Blocking variant offlush(io.vertx.mutiny.ext.web.RoutingContext)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
ctx
- the current context- Returns:
- the Void instance produced by the operation.
-
flushAndForget
public SessionHandler flushAndForget(RoutingContext ctx)
Variant offlush(io.vertx.mutiny.ext.web.RoutingContext)
that ignores the result of the operation.This method subscribes on the result of
flush(io.vertx.mutiny.ext.web.RoutingContext)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromflush(io.vertx.mutiny.ext.web.RoutingContext)
but you don't need to compose it with other operations.- Parameters:
ctx
- the current context- Returns:
- the instance of SessionHandler to chain method calls.
-
flush
public io.smallrye.mutiny.Uni<Void> flush(RoutingContext ctx, boolean ignoreStatus)
Flush a context session earlier to the store, this will allow the end user to have full control on the event of a failure at the store level. Once a session is flushed no automatic save will be performed at end of request.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
ctx
- the current contextignoreStatus
- flush regardless of response status code- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
flushAndAwait
public Void flushAndAwait(RoutingContext ctx, boolean ignoreStatus)
Blocking variant offlush(io.vertx.mutiny.ext.web.RoutingContext,boolean)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
ctx
- the current contextignoreStatus
- flush regardless of response status code- Returns:
- the Void instance produced by the operation.
-
flushAndForget
public SessionHandler flushAndForget(RoutingContext ctx, boolean ignoreStatus)
Variant offlush(io.vertx.mutiny.ext.web.RoutingContext,boolean)
that ignores the result of the operation.This method subscribes on the result of
flush(io.vertx.mutiny.ext.web.RoutingContext,boolean)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromflush(io.vertx.mutiny.ext.web.RoutingContext,boolean)
but you don't need to compose it with other operations.- Parameters:
ctx
- the current contextignoreStatus
- flush regardless of response status code- Returns:
- the instance of SessionHandler to chain method calls.
-
setCookieless
public SessionHandler setCookieless(boolean cookieless)
- Parameters:
cookieless
- true if a cookieless session should be used- Returns:
- a reference to this, so the API can be used fluently
-
newSession
public Session newSession(RoutingContext context)
- Parameters:
context
- the routing context- Returns:
- the session
-
setUser
public io.smallrye.mutiny.Uni<Void> setUser(RoutingContext context, User user)
Set the user for the sessionUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
context
- the routing contextuser
- the user- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
setUserAndAwait
public Void setUserAndAwait(RoutingContext context, User user)
Blocking variant ofsetUser(io.vertx.mutiny.ext.web.RoutingContext,io.vertx.mutiny.ext.auth.User)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
context
- the routing contextuser
- the user- Returns:
- the Void instance produced by the operation.
-
setUserAndForget
public SessionHandler setUserAndForget(RoutingContext context, User user)
Variant ofsetUser(io.vertx.mutiny.ext.web.RoutingContext,io.vertx.mutiny.ext.auth.User)
that ignores the result of the operation.This method subscribes on the result of
setUser(io.vertx.mutiny.ext.web.RoutingContext,io.vertx.mutiny.ext.auth.User)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsetUser(io.vertx.mutiny.ext.web.RoutingContext,io.vertx.mutiny.ext.auth.User)
but you don't need to compose it with other operations.- Parameters:
context
- the routing contextuser
- the user- Returns:
- the instance of SessionHandler to chain method calls.
-
accept
public void accept(RoutingContext item)
- Specified by:
accept
in interfaceConsumer<RoutingContext>
-
newInstance
public static SessionHandler newInstance(io.vertx.ext.web.handler.SessionHandler arg)
-
-