Class: Monorail::Session
- Inherits:
-
Hash
- Object
- Hash
- Monorail::Session
- Defined in:
- lib/monorail/monorail_webd.rb
Overview
class Session
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#session_name ⇒ Object
readonly
Returns the value of attribute session_name.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#authorize ⇒ Object
authorize.
-
#authorized? ⇒ Boolean
authorized?.
-
#first_use? ⇒ Boolean
first_use?.
-
#initialize ⇒ Session
constructor
initialize.
-
#is_expired? ⇒ Boolean
is_expired?.
-
#set_credential(user, psw) ⇒ Object
set_credential.
-
#touch ⇒ Object
touch.
-
#unauthorize ⇒ Object
unauthorize Used to implement a logout function.
Constructor Details
#initialize ⇒ Session
initialize
182 183 184 185 186 187 188 |
# File 'lib/monorail/monorail_webd.rb', line 182 def initialize super() @session_name = SessionManager.instance.generate_key @first_use = true @created_at = Time.now @last_retrieved = nil end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
177 178 179 |
# File 'lib/monorail/monorail_webd.rb', line 177 def password @password end |
#session_name ⇒ Object (readonly)
Returns the value of attribute session_name.
175 176 177 |
# File 'lib/monorail/monorail_webd.rb', line 175 def session_name @session_name end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
176 177 178 |
# File 'lib/monorail/monorail_webd.rb', line 176 def username @username end |
Instance Method Details
#authorize ⇒ Object
authorize
223 224 225 |
# File 'lib/monorail/monorail_webd.rb', line 223 def @last_authorized = Time.now end |
#authorized? ⇒ Boolean
authorized?
244 245 246 |
# File 'lib/monorail/monorail_webd.rb', line 244 def @last_authorized and ((Time.now - @last_authorized) < SessionManager::AuthorizationTimeout) end |
#first_use? ⇒ Boolean
first_use?
193 194 195 |
# File 'lib/monorail/monorail_webd.rb', line 193 def first_use? @last_retrieved == nil end |
#is_expired? ⇒ Boolean
is_expired?
200 201 202 203 |
# File 'lib/monorail/monorail_webd.rb', line 200 def is_expired? last_touch = (@last_retrieved or @created_at) (Time.now - last_touch) > SessionManager::SessionTimeout end |
#set_credential(user, psw) ⇒ Object
set_credential
215 216 217 |
# File 'lib/monorail/monorail_webd.rb', line 215 def set_credential user, psw @username,@password = user,psw end |
#touch ⇒ Object
touch
208 209 210 |
# File 'lib/monorail/monorail_webd.rb', line 208 def touch @last_retrieved = Time.now end |
#unauthorize ⇒ Object
unauthorize Used to implement a logout function. Must null out the stored credential, otherwise the authorizer will just go back to the system function and try again. Security risk: Must make sure somehow that these session objects never get swapped out.
235 236 237 238 239 |
# File 'lib/monorail/monorail_webd.rb', line 235 def @last_authorized = nil @username = nil @password = nil end |