Class: DotNetServices::Authentication::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/dot_net_services/authentication.rb

Overview

Authentication token.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#expiryObject (readonly)

:nodoc:



14
15
16
# File 'lib/dot_net_services/authentication.rb', line 14

def expiry
  @expiry
end

#valueObject (readonly)

:nodoc:



14
15
16
# File 'lib/dot_net_services/authentication.rb', line 14

def value
  @value
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/dot_net_services/authentication.rb', line 30

def expired?
  @expiry < Time.now
end

#to_sObject



34
35
36
# File 'lib/dot_net_services/authentication.rb', line 34

def to_s
  @value
end