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
159 160 161 162 163 164 165 |
# File 'lib/monorail/monorail_webd.rb', line 159 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.
154 155 156 |
# File 'lib/monorail/monorail_webd.rb', line 154 def password @password end |
#session_name ⇒ Object (readonly)
Returns the value of attribute session_name.
152 153 154 |
# File 'lib/monorail/monorail_webd.rb', line 152 def session_name @session_name end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
153 154 155 |
# File 'lib/monorail/monorail_webd.rb', line 153 def username @username end |
Instance Method Details
#authorize ⇒ Object
authorize
200 201 202 |
# File 'lib/monorail/monorail_webd.rb', line 200 def @last_authorized = Time.now end |
#authorized? ⇒ Boolean
authorized?
221 222 223 |
# File 'lib/monorail/monorail_webd.rb', line 221 def @last_authorized and ((Time.now - @last_authorized) < SessionManager::AuthorizationTimeout) end |
#first_use? ⇒ Boolean
first_use?
170 171 172 |
# File 'lib/monorail/monorail_webd.rb', line 170 def first_use? @last_retrieved == nil end |
#is_expired? ⇒ Boolean
is_expired?
177 178 179 180 |
# File 'lib/monorail/monorail_webd.rb', line 177 def is_expired? last_touch = (@last_retrieved or @created_at) (Time.now - last_touch) > SessionManager::SessionTimeout end |
#set_credential(user, psw) ⇒ Object
set_credential
192 193 194 |
# File 'lib/monorail/monorail_webd.rb', line 192 def set_credential user, psw @username,@password = user,psw end |
#touch ⇒ Object
touch
185 186 187 |
# File 'lib/monorail/monorail_webd.rb', line 185 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.
212 213 214 215 216 |
# File 'lib/monorail/monorail_webd.rb', line 212 def @last_authorized = nil @username = nil @password = nil end |