Class: HTTP::TokenAuth::Challenge

Inherits:
Object
  • Object
show all
Defined in:
lib/http/token_auth/challenge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(realm:, supported_coverages: nil, timestamp: nil) ⇒ Challenge

Returns a new instance of Challenge.



9
10
11
12
13
14
# File 'lib/http/token_auth/challenge.rb', line 9

def initialize(realm:, supported_coverages: nil, timestamp: nil)
  @realm = realm
  @supported_coverages = supported_coverages_or_default(supported_coverages)
  @timestamp = timestamp
  validate_itself
end

Instance Attribute Details

#realmObject (readonly)

Returns the value of attribute realm.



7
8
9
# File 'lib/http/token_auth/challenge.rb', line 7

def realm
  @realm
end

#supported_coveragesObject (readonly)

Returns the value of attribute supported_coverages.



7
8
9
# File 'lib/http/token_auth/challenge.rb', line 7

def supported_coverages
  @supported_coverages
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



7
8
9
# File 'lib/http/token_auth/challenge.rb', line 7

def timestamp
  @timestamp
end

Instance Method Details

#to_headerObject



16
17
18
19
20
21
22
23
24
# File 'lib/http/token_auth/challenge.rb', line 16

def to_header
  attributes = []
  attributes << %(realm="#{@realm}")
  attributes << %(coverage="#{coverage_string}")
  unless supported_coverages.include?(:none)
    attributes << %(timestamp="#{@timestamp}")
  end
  "Token #{attributes.join(', ')}"
end