Class: DotNetServices::Authentication::Token
- Inherits:
-
Object
- Object
- DotNetServices::Authentication::Token
- Defined in:
- lib/dot_net_services/authentication.rb
Overview
Authentication token.
Instance Attribute Summary collapse
-
#expiry ⇒ Object
readonly
:nodoc:.
-
#value ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(value, expiry = Time.now + 24 *60 * 60) ⇒ Token
constructor
Create a new authentication token; defaults to expire in one day.
- #to_s ⇒ Object
Constructor Details
#initialize(value, expiry = Time.now + 24 *60 * 60) ⇒ Token
Create a new authentication token; defaults to expire in one day.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dot_net_services/authentication.rb', line 17 def initialize(value, expiry = Time.now + 24 *60 * 60) # workaround for a known bug match = value.match(/^([^=]+==).*/) if match @value = match[1] @expiry = expiry else raise AuthenticationError, "Response from access control service doesn't seem to contain a valid authentication token:\n" + value.inspect end end |
Instance Attribute Details
#expiry ⇒ Object (readonly)
:nodoc:
14 15 16 |
# File 'lib/dot_net_services/authentication.rb', line 14 def expiry @expiry end |
#value ⇒ Object (readonly)
:nodoc:
14 15 16 |
# File 'lib/dot_net_services/authentication.rb', line 14 def value @value end |
Instance Method Details
#expired? ⇒ Boolean
30 31 32 |
# File 'lib/dot_net_services/authentication.rb', line 30 def expired? @expiry < Time.now end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/dot_net_services/authentication.rb', line 34 def to_s @value end |