Class: Cassette::Http::TicketResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/cassette/http/ticket_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ TicketResponse



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cassette/http/ticket_response.rb', line 9

def initialize(response)
  namespaces = { "cas" => "http://www.yale.edu/tp/cas" }
  query = "//cas:serviceResponse/cas:authenticationSuccess/cas:user"

  document = REXML::Document.new(response)
  element = REXML::XPath.first(document, query, namespaces)
  @login = element.try(:text)

  if @login
    attributes_query =
      "//cas:serviceResponse/cas:authenticationSuccess/cas:attributes"
    attributes = Hash[REXML::XPath.
      first(document, attributes_query, namespaces).
      elements.
      map { |e| [e.name, e.text] }]

    @name = attributes['cn']
    @authorities = attributes['authorities']
  end
end

Instance Attribute Details

#authoritiesObject (readonly)

Returns the value of attribute authorities.



7
8
9
# File 'lib/cassette/http/ticket_response.rb', line 7

def authorities
  @authorities
end

#loginObject (readonly)

Returns the value of attribute login.



7
8
9
# File 'lib/cassette/http/ticket_response.rb', line 7

def 
  @login
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/cassette/http/ticket_response.rb', line 7

def name
  @name
end