Class: CASClient::ProxyResponse

Inherits:
Object
  • Object
show all
Includes:
XmlResponse
Defined in:
lib/casclient/responses.rb

Overview

Represents a response from the CAS server to a proxy ticket request (i.e. after requesting a proxy ticket).

Instance Attribute Summary collapse

Attributes included from XmlResponse

#failure_code, #failure_message, #parse_datetime, #xml

Instance Method Summary collapse

Methods included from XmlResponse

#check_and_parse_xml, #to_s

Constructor Details

#initialize(raw_text, options = {}) ⇒ ProxyResponse

Returns a new instance of ProxyResponse.



137
138
139
# File 'lib/casclient/responses.rb', line 137

def initialize(raw_text, options={})
  parse(raw_text)
end

Instance Attribute Details

#proxy_ticketObject (readonly)

Returns the value of attribute proxy_ticket.



135
136
137
# File 'lib/casclient/responses.rb', line 135

def proxy_ticket
  @proxy_ticket
end

Instance Method Details

#is_failure?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/casclient/responses.rb', line 164

def is_failure?
  xml.name == "proxyFailure"
end

#is_success?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/casclient/responses.rb', line 160

def is_success?
  xml.name == "proxySuccess"
end

#parse(raw_text) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/casclient/responses.rb', line 141

def parse(raw_text)
  raise BadResponseException, 
    "CAS response is empty/blank." if raw_text.blank?
  @parse_datetime = Time.now

  @xml = check_and_parse_xml(raw_text)

  if is_success?
    @proxy_ticket = @xml.elements["cas:proxyTicket"].text.strip if @xml.elements["cas:proxyTicket"]
  elsif is_failure?
    @failure_code = @xml.elements['//cas:proxyFailure'].attributes['code']
    @failure_message = @xml.elements['//cas:proxyFailure'].text.strip
  else
    # this should never happen, since the response should already have been recognized as invalid
    raise BadResponseException, "BAD CAS RESPONSE:\n#{raw_text.inspect}\n\nXML DOC:\n#{doc.inspect}"
  end

end