Class: VertxApex::Session
- Inherits:
-
Object
- Object
- VertxApex::Session
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb
Overview
Represents a browser 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.
Instance Method Summary (collapse)
-
- (void) destroy
Destroy the session.
-
- (true, false) destroyed?
@return has the session been destroyed?.
-
- (Object) get(key = nil)
Get some data from the session.
-
- (Hash{String => Object}) get_principal
Get the principal.
-
- (void) has_permission(permission = nil) { ... }
Does the logged in user have the specified permissions? Information is cached for the lifetime of the session.
-
- (void) has_permissions(permissions = nil) { ... }
Does the logged in user have the specified permissions? Information is cached for the lifetime of the session.
-
- (void) has_role(role = nil) { ... }
Does the logged in user have the specified role? Information is cached for the lifetime of the session.
-
- (void) has_roles(roles = nil) { ... }
Does the logged in user have the specified roles? Information is cached for the lifetime of the session.
-
- (String) id
@return The unique ID of the session.
-
- (Fixnum) last_accessed
@return the time the session was last accessed.
-
- (true, false) logged_in?
@return true if the user is logged in.
-
- (void) logout
Logout the user.
-
- (self) put(key = nil, obj = nil)
Put some data in a session.
-
- (Object) remove(key = nil)
Remove some data from the session.
-
- (::VertxApex::SessionStore) session_store
@return the store for the session.
-
- (void) set_accessed
Mark the session as being accessed.
-
- (void) set_auth_provider(authProvider = nil)
Set the auth provider.
-
- (void) set_principal(principal = nil)
Set the principal (the unique user id) of the user -this signifies the user is logged in.
-
- (Fixnum) timeout
@return the amount of time in ms, after which the session will expire, if not accessed.
Instance Method Details
- (void) destroy
This method returns an undefined value.
Destroy the session
73 74 75 76 77 78 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 73 def destroy if !block_given? return @j_del.java_method(:destroy, []).call() end raise ArgumentError, "Invalid arguments when calling destroy()" end |
- (true, false) destroyed?
@return has the session been destroyed?
81 82 83 84 85 86 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 81 def destroyed? if !block_given? return @j_del.java_method(:isDestroyed, []).call() end raise ArgumentError, "Invalid arguments when calling destroyed?()" end |
- (Object) get(key = nil)
Get some data from the session
48 49 50 51 52 53 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 48 def get(key=nil) if key.class == String && !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:get, [Java::java.lang.String.java_class]).call(key)) end raise ArgumentError, "Invalid arguments when calling get(key)" end |
- (Hash{String => Object}) get_principal
Get the principal
106 107 108 109 110 111 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 106 def get_principal if !block_given? return @j_del.java_method(:getPrincipal, []).call() != nil ? JSON.parse(@j_del.java_method(:getPrincipal, []).call().encode) : nil end raise ArgumentError, "Invalid arguments when calling get_principal()" end |
- (void) has_permission(permission = nil) { ... }
This method returns an undefined value.
Does the logged in user have the specified permissions? Information is cached for the lifetime of the session
126 127 128 129 130 131 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 126 def (=nil) if .class == String && block_given? return @j_del.java_method(:hasPermission, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) end raise ArgumentError, "Invalid arguments when calling has_permission(permission)" end |
- (void) has_permissions(permissions = nil) { ... }
This method returns an undefined value.
Does the logged in user have the specified permissions? Information is cached for the lifetime of the session
146 147 148 149 150 151 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 146 def (=nil) if .class == Set && block_given? return @j_del.java_method(:hasPermissions, [Java::JavaUtil::Set.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::JavaUtil::LinkedHashSet.new(.map { |element| element }),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) end raise ArgumentError, "Invalid arguments when calling has_permissions(permissions)" end |
- (void) has_role(role = nil) { ... }
This method returns an undefined value.
Does the logged in user have the specified role? Information is cached for the lifetime of the session
116 117 118 119 120 121 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 116 def has_role(role=nil) if role.class == String && block_given? return @j_del.java_method(:hasRole, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(role,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) end raise ArgumentError, "Invalid arguments when calling has_role(role)" end |
- (void) has_roles(roles = nil) { ... }
This method returns an undefined value.
Does the logged in user have the specified roles? Information is cached for the lifetime of the session
136 137 138 139 140 141 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 136 def has_roles(roles=nil) if roles.class == Set && block_given? return @j_del.java_method(:hasRoles, [Java::JavaUtil::Set.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::JavaUtil::LinkedHashSet.new(roles.map { |element| element }),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) end raise ArgumentError, "Invalid arguments when calling has_roles(roles)" end |
- (String) id
@return The unique ID of the session. This is generated using a random secure UUID.
28 29 30 31 32 33 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 28 def id if !block_given? return @j_del.java_method(:id, []).call() end raise ArgumentError, "Invalid arguments when calling id()" end |
- (Fixnum) last_accessed
@return the time the session was last accessed
65 66 67 68 69 70 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 65 def last_accessed if !block_given? return @j_del.java_method(:lastAccessed, []).call() end raise ArgumentError, "Invalid arguments when calling last_accessed()" end |
- (true, false) logged_in?
@return true if the user is logged in.
89 90 91 92 93 94 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 89 def logged_in? if !block_given? return @j_del.java_method(:isLoggedIn, []).call() end raise ArgumentError, "Invalid arguments when calling logged_in?()" end |
- (void) logout
This method returns an undefined value.
Logout the user.
154 155 156 157 158 159 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 154 def logout if !block_given? return @j_del.java_method(:logout, []).call() end raise ArgumentError, "Invalid arguments when calling logout()" end |
- (self) put(key = nil, obj = nil)
Put some data in a session
38 39 40 41 42 43 44 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 38 def put(key=nil,obj=nil) if key.class == String && (obj.class == String || obj.class == Hash || obj.class == Array || obj.class == NilClass || obj.class == TrueClass || obj.class == FalseClass || obj.class == Fixnum || obj.class == Float) && !block_given? @j_del.java_method(:put, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class]).call(key,::Vertx::Util::Utils.to_object(obj)) return self end raise ArgumentError, "Invalid arguments when calling put(key,obj)" end |
- (Object) remove(key = nil)
Remove some data from the session
57 58 59 60 61 62 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 57 def remove(key=nil) if key.class == String && !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:remove, [Java::java.lang.String.java_class]).call(key)) end raise ArgumentError, "Invalid arguments when calling remove(key)" end |
- (::VertxApex::SessionStore) session_store
@return the store for the session
170 171 172 173 174 175 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 170 def session_store if !block_given? return ::VertxApex::SessionStore.new(@j_del.java_method(:sessionStore, []).call()) end raise ArgumentError, "Invalid arguments when calling session_store()" end |
- (void) set_accessed
This method returns an undefined value.
Mark the session as being accessed.
178 179 180 181 182 183 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 178 def set_accessed if !block_given? return @j_del.java_method(:setAccessed, []).call() end raise ArgumentError, "Invalid arguments when calling set_accessed()" end |
- (void) set_auth_provider(authProvider = nil)
This method returns an undefined value.
Set the auth provider
187 188 189 190 191 192 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 187 def set_auth_provider(authProvider=nil) if authProvider.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:setAuthProvider, [Java::IoVertxExtAuth::AuthProvider.java_class]).call(authProvider.j_del) end raise ArgumentError, "Invalid arguments when calling set_auth_provider(authProvider)" end |
- (void) set_principal(principal = nil)
This method returns an undefined value.
Set the principal (the unique user id) of the user -this signifies the user is logged in
98 99 100 101 102 103 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 98 def set_principal(principal=nil) if principal.class == Hash && !block_given? return @j_del.java_method(:setPrincipal, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) end raise ArgumentError, "Invalid arguments when calling set_principal(principal)" end |
- (Fixnum) timeout
@return the amount of time in ms, after which the session will expire, if not accessed.
162 163 164 165 166 167 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/session.rb', line 162 def timeout if !block_given? return @j_del.java_method(:timeout, []).call() end raise ArgumentError, "Invalid arguments when calling timeout()" end |