Class: VertxWeb::SessionHandler

Inherits:
Object
  • Object
show all
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 .

The session handler requires a CookieHandler to be on the routing chain before it.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 30

def @@j_api_type.accept?(obj)
  obj.class == SessionHandler
end

+ (::VertxWeb::SessionHandler) create(sessionStore = nil)

Create a session handler

Parameters:

Returns:

Raises:

  • (ArgumentError)


57
58
59
60
61
62
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 57

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
Default of whether the cookie has the HttpOnly flag set More info: https://www.owasp.org/index.php/HttpOnly


159
160
161
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 159

def self.DEFAULT_COOKIE_HTTP_ONLY_FLAG
  Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_COOKIE_HTTP_ONLY_FLAG
end
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


164
165
166
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 164

def self.DEFAULT_COOKIE_SECURE_FLAG
  Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_COOKIE_SECURE_FLAG
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


154
155
156
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 154

def self.DEFAULT_NAG_HTTPS
  Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_NAG_HTTPS
end
Default name of session cookie


140
141
142
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 140

def self.DEFAULT_SESSION_COOKIE_NAME
  Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_SESSION_COOKIE_NAME
end
Default path of session cookie


144
145
146
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 144

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.


149
150
151
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 149

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


169
170
171
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 169

def self.DEFAULT_SESSIONID_MIN_LENGTH
  Java::IoVertxExtWebHandler::SessionHandler.DEFAULT_SESSIONID_MIN_LENGTH
end

+ (Object) j_api_type



39
40
41
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 39

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



42
43
44
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 42

def self.j_class
  Java::IoVertxExtWebHandler::SessionHandler.java_class
end

+ (Object) unwrap(obj)



36
37
38
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 36

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



33
34
35
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 33

def @@j_api_type.wrap(obj)
  SessionHandler.new(obj)
end

Instance Method Details

- (void) handle(event = nil)

This method returns an undefined value.

Something has happened, so handle it.

Parameters:

Raises:

  • (ArgumentError)


48
49
50
51
52
53
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 48

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
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.

Parameters:

  • httpOnly (true, false) (defaults to: nil)
    true to set the HttpOnly flag on the cookie

Returns:

  • (self)

Raises:

  • (ArgumentError)


102
103
104
105
106
107
108
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 102

def set_cookie_http_only_flag(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
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).

Parameters:

  • secure (true, false) (defaults to: nil)
    true to set the secure flag on the cookie

Returns:

  • (self)

Raises:

  • (ArgumentError)


90
91
92
93
94
95
96
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 90

def set_cookie_secure_flag(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_min_length(minLength = nil)

Set expected session id minimum length.

Parameters:

  • minLength (Fixnum) (defaults to: nil)
    the session id minimal length

Returns:

  • (self)

Raises:

  • (ArgumentError)


132
133
134
135
136
137
138
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 132

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

Parameters:

  • nag (true, false) (defaults to: nil)
    true to nag

Returns:

  • (self)

Raises:

  • (ArgumentError)


77
78
79
80
81
82
83
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 77

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
Set the session cookie name

Parameters:

  • sessionCookieName (String) (defaults to: nil)
    the session cookie name

Returns:

  • (self)

Raises:

  • (ArgumentError)


112
113
114
115
116
117
118
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 112

def set_session_cookie_name(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
Set the session cookie path

Parameters:

  • sessionCookiePath (String) (defaults to: nil)
    the session cookie path

Returns:

  • (self)

Raises:

  • (ArgumentError)


122
123
124
125
126
127
128
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 122

def set_session_cookie_path(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

Parameters:

  • timeout (Fixnum) (defaults to: nil)
    the timeout, in ms.

Returns:

  • (self)

Raises:

  • (ArgumentError)


66
67
68
69
70
71
72
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session_handler.rb', line 66

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