Class: VertxApex::Session

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

Instance Method Details

- (void) destroy

This method returns an undefined value.

Destroy the session

Raises:

  • (ArgumentError)


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?

Returns:

  • (true, false)

Raises:

  • (ArgumentError)


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

Parameters:

  • key (String) (defaults to: nil)
    the key of the data

Returns:

  • (Object)
    the data

Raises:

  • (ArgumentError)


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

Returns:

  • (Hash{String => Object})
    the principal or null if not logged in

Raises:

  • (ArgumentError)


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

Parameters:

  • permission (String) (defaults to: nil)
    the permission

Yields:

  • will be called with a result true/false

Raises:

  • (ArgumentError)


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 has_permission(permission=nil)
  if permission.class == String && block_given?
    return @j_del.java_method(:hasPermission, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(permission,(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

Parameters:

  • permissions (Set<String>) (defaults to: nil)
    the permissions

Yields:

  • will be called with a result true/false

Raises:

  • (ArgumentError)


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 has_permissions(permissions=nil)
  if permissions.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(permissions.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

Parameters:

  • role (String) (defaults to: nil)
    the role

Yields:

  • will be called with a result true/false

Raises:

  • (ArgumentError)


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

Parameters:

  • roles (Set<String>) (defaults to: nil)
    the roles

Yields:

  • will be called with a result true/false

Raises:

  • (ArgumentError)


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.

Returns:

  • (String)

Raises:

  • (ArgumentError)


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

Returns:

  • (Fixnum)

Raises:

  • (ArgumentError)


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.

Returns:

  • (true, false)

Raises:

  • (ArgumentError)


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.

Raises:

  • (ArgumentError)


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

Parameters:

  • key (String) (defaults to: nil)
    the key for the data
  • obj (Object) (defaults to: nil)
    the data

Returns:

  • (self)

Raises:

  • (ArgumentError)


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

Parameters:

  • key (String) (defaults to: nil)
    the key of the data

Returns:

  • (Object)
    the data that was there or null if none there

Raises:

  • (ArgumentError)


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

Returns:

Raises:

  • (ArgumentError)


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.

Raises:

  • (ArgumentError)


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

Parameters:

  • authProvider (::VertxAuth::AuthProvider) (defaults to: nil)
    the auth provider

Raises:

  • (ArgumentError)


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

Parameters:

  • principal (Hash{String => Object}) (defaults to: nil)
    the principal

Raises:

  • (ArgumentError)


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.

Returns:

  • (Fixnum)

Raises:

  • (ArgumentError)


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