Class: VertxWeb::SessionHandler
- Inherits:
-
Object
- Object
- VertxWeb::SessionHandler
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb
Overview
A handler that maintains a Session 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 .
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
-
+ (::VertxWeb::SessionHandler) create(sessionStore = nil)
Create a session handler.
-
+ (Object) DEFAULT_COOKIE_HTTP_ONLY_FLAG
Default of whether the cookie has the HttpOnly flag set More info: https://www.owasp.org/index.php/HttpOnly.
-
+ (Object) DEFAULT_COOKIE_SECURE_FLAG
Default of whether the cookie has the 'secure' flag set to allow transmission over https only.
-
+ (Object) DEFAULT_LAZY_SESSION
Default of whether the session should be created lazily.
-
+ (Object) DEFAULT_NAG_HTTPS
Default of whether a nagging log warning should be written if the session handler is accessed over HTTP, not HTTPS.
-
+ (Object) DEFAULT_SESSION_COOKIE_NAME
Default name of session cookie.
-
+ (Object) DEFAULT_SESSION_COOKIE_PATH
Default path of session cookie.
-
+ (Object) DEFAULT_SESSION_TIMEOUT
Default time, in ms, that a session lasts for without being accessed before expiring.
-
+ (Object) DEFAULT_SESSIONID_MIN_LENGTH
Default min length for a session id.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (self) flush(ctx = nil) { ... }
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) handle(event = nil)
Something has happened, so handle it.
-
- (self) set_auth_provider(authProvider = nil)
Set an auth provider that will allow retrieving the User object from the session to the current routing context.
-
- (self) set_cookie_http_only_flag(httpOnly = nil)
Sets whether the 'HttpOnly' flag should be set for the session cookie.
-
- (self) set_cookie_same_site(policy = nil)
Set the session cookie SameSite policy to use.
-
- (self) set_cookie_secure_flag(secure = nil)
Sets whether the 'secure' flag should be set for the session cookie.
-
- (self) set_lazy_session(lazySession = nil)
Use a lazy session creation mechanism.
-
- (self) set_min_length(minLength = nil)
Set expected session id minimum length.
-
- (self) set_nag_https(nag = nil)
Set whether a nagging log warning should be written if the session handler is accessed over HTTP, not HTTPS.
-
- (self) set_session_cookie_name(sessionCookieName = nil)
Set the session cookie name.
-
- (self) set_session_cookie_path(sessionCookiePath = nil)
Set the session cookie path.
-
- (self) set_session_timeout(timeout = nil)
Set the session timeout.
Class Method Details
+ (Boolean) accept?(obj)
28 29 30 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 28 def @@j_api_type.accept?(obj) obj.class == SessionHandler end |
+ (::VertxWeb::SessionHandler) create(sessionStore = nil)
Create a session handler
55 56 57 58 59 60 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 55 def self.create(sessionStore=nil) if sessionStore.class.method_defined?(:j_del) && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::SessionHandler.java_method(:create, [Java::IoVertxExtWebSstore::SessionStore.java_class]).call(sessionStore.j_del),::VertxWeb::SessionHandler) end raise ArgumentError, "Invalid arguments when calling create(#{sessionStore})" end |
+ (Object) DEFAULT_COOKIE_HTTP_ONLY_FLAG
Default of whether the cookie has the HttpOnly flag set More info:
https://www.owasp.org/index.php/HttpOnly
200 201 202 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 200 def self.DEFAULT_COOKIE_HTTP_ONLY_FLAG Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_COOKIE_HTTP_ONLY_FLAG end |
+ (Object) 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
205 206 207 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 205 def self.DEFAULT_COOKIE_SECURE_FLAG Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_COOKIE_SECURE_FLAG end |
+ (Object) DEFAULT_LAZY_SESSION
Default of whether the session should be created lazily.
214 215 216 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 214 def self.DEFAULT_LAZY_SESSION Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_LAZY_SESSION end |
+ (Object) DEFAULT_NAG_HTTPS
Default of whether a nagging log warning should be written if the session
handler is accessed over HTTP, not HTTPS
195 196 197 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 195 def self.DEFAULT_NAG_HTTPS Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_NAG_HTTPS end |
+ (Object) DEFAULT_SESSION_COOKIE_NAME
Default name of session cookie
181 182 183 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 181 def self.DEFAULT_SESSION_COOKIE_NAME Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_SESSION_COOKIE_NAME end |
+ (Object) DEFAULT_SESSION_COOKIE_PATH
Default path of session cookie
185 186 187 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 185 def self.DEFAULT_SESSION_COOKIE_PATH Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_SESSION_COOKIE_PATH end |
+ (Object) DEFAULT_SESSION_TIMEOUT
Default time, in ms, that a session lasts for without being accessed before
expiring.
190 191 192 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 190 def self.DEFAULT_SESSION_TIMEOUT Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_SESSION_TIMEOUT end |
+ (Object) DEFAULT_SESSIONID_MIN_LENGTH
Default min length for a session id. More info:
https://www.owasp.org/index.php/Session_Management_Cheat_Sheet
210 211 212 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 210 def self.DEFAULT_SESSIONID_MIN_LENGTH Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_SESSIONID_MIN_LENGTH end |
+ (Object) j_api_type
37 38 39 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 37 def self.j_api_type @@j_api_type end |
+ (Object) j_class
40 41 42 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 40 def self.j_class Java::IoVertxExtWebHandler::SessionHandler.java_class end |
+ (Object) unwrap(obj)
34 35 36 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 34 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
31 32 33 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 31 def @@j_api_type.wrap(obj) SessionHandler.new(obj) end |
Instance Method Details
- (self) flush(ctx = nil) { ... }
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.
173 174 175 176 177 178 179 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 173 def flush(ctx=nil) if ctx.class.method_defined?(:j_del) && block_given? @j_del.java_method(:flush, [Java::IoVertxExtWeb::RoutingContext.java_class,Java::IoVertxCore::Handler.java_class]).call(ctx.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling flush(#{ctx})" end |
- (void) handle(event = nil)
This method returns an undefined value.
Something has happened, so handle it.
46 47 48 49 50 51 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 46 def handle(event=nil) if event.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(event.j_del) end raise ArgumentError, "Invalid arguments when calling handle(#{event})" end |
- (self) set_auth_provider(authProvider = nil)
Set an auth provider that will allow retrieving the User object from the session to the current routing context.
161 162 163 164 165 166 167 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 161 def set_auth_provider(authProvider=nil) if authProvider.class.method_defined?(:j_del) && !block_given? @j_del.java_method(:setAuthProvider, [Java::IoVertxExtAuth::AuthProvider.java_class]).call(authProvider.j_del) return self end raise ArgumentError, "Invalid arguments when calling set_auth_provider(#{authProvider})" end |
- (self) set_cookie_http_only_flag(httpOnly = nil)
Sets whether the 'HttpOnly' flag should be set for the session cookie. When
set this flag instructs browsers to prevent Javascript access to the the
cookie. Used as a line of defence against the most common XSS attacks.
100 101 102 103 104 105 106 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 100 def (httpOnly=nil) if (httpOnly.class == TrueClass || httpOnly.class == FalseClass) && !block_given? @j_del.java_method(:setCookieHttpOnlyFlag, [Java::boolean.java_class]).call(httpOnly) return self end raise ArgumentError, "Invalid arguments when calling set_cookie_http_only_flag(#{httpOnly})" end |
- (self) set_cookie_same_site(policy = nil)
Set the session cookie SameSite policy to use.
140 141 142 143 144 145 146 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 140 def (policy=nil) if policy.class == Symbol && !block_given? @j_del.java_method(:setCookieSameSite, [Java::IoVertxCoreHttp::CookieSameSite.java_class]).call(Java::IoVertxCoreHttp::CookieSameSite.valueOf(policy.to_s)) return self end raise ArgumentError, "Invalid arguments when calling set_cookie_same_site(#{policy})" end |
- (self) set_cookie_secure_flag(secure = nil)
Sets whether the 'secure' flag should be set for the session cookie. When set
this flag instructs browsers to only send the cookie over HTTPS. Note that
this will probably stop your sessions working if used without HTTPS (e.g. in
development).
88 89 90 91 92 93 94 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 88 def (secure=nil) if (secure.class == TrueClass || secure.class == FalseClass) && !block_given? @j_del.java_method(:setCookieSecureFlag, [Java::boolean.java_class]).call(secure) return self end raise ArgumentError, "Invalid arguments when calling set_cookie_secure_flag(#{secure})" end |
- (self) set_lazy_session(lazySession = nil)
Use a lazy session creation mechanism. The session will only be created when accessed from the context. Thus the
session cookie is set only if the session was accessed.
151 152 153 154 155 156 157 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 151 def set_lazy_session(lazySession=nil) if (lazySession.class == TrueClass || lazySession.class == FalseClass) && !block_given? @j_del.java_method(:setLazySession, [Java::boolean.java_class]).call(lazySession) return self end raise ArgumentError, "Invalid arguments when calling set_lazy_session(#{lazySession})" end |
- (self) set_min_length(minLength = nil)
Set expected session id minimum length.
130 131 132 133 134 135 136 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 130 def set_min_length(minLength=nil) if minLength.class == Fixnum && !block_given? @j_del.java_method(:setMinLength, [Java::int.java_class]).call(minLength) return self end raise ArgumentError, "Invalid arguments when calling set_min_length(#{minLength})" end |
- (self) set_nag_https(nag = nil)
Set whether a nagging log warning should be written if the session handler is
accessed over HTTP, not HTTPS
75 76 77 78 79 80 81 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 75 def set_nag_https(nag=nil) if (nag.class == TrueClass || nag.class == FalseClass) && !block_given? @j_del.java_method(:setNagHttps, [Java::boolean.java_class]).call(nag) return self end raise ArgumentError, "Invalid arguments when calling set_nag_https(#{nag})" end |
- (self) set_session_cookie_name(sessionCookieName = nil)
Set the session cookie name
110 111 112 113 114 115 116 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 110 def (sessionCookieName=nil) if sessionCookieName.class == String && !block_given? @j_del.java_method(:setSessionCookieName, [Java::java.lang.String.java_class]).call(sessionCookieName) return self end raise ArgumentError, "Invalid arguments when calling set_session_cookie_name(#{sessionCookieName})" end |
- (self) set_session_cookie_path(sessionCookiePath = nil)
Set the session cookie path
120 121 122 123 124 125 126 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 120 def (sessionCookiePath=nil) if sessionCookiePath.class == String && !block_given? @j_del.java_method(:setSessionCookiePath, [Java::java.lang.String.java_class]).call(sessionCookiePath) return self end raise ArgumentError, "Invalid arguments when calling set_session_cookie_path(#{sessionCookiePath})" end |
- (self) set_session_timeout(timeout = nil)
Set the session timeout
64 65 66 67 68 69 70 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 64 def set_session_timeout(timeout=nil) if timeout.class == Fixnum && !block_given? @j_del.java_method(:setSessionTimeout, [Java::long.java_class]).call(timeout) return self end raise ArgumentError, "Invalid arguments when calling set_session_timeout(#{timeout})" end |