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) ⇒ ProxyResponse

Returns a new instance of ProxyResponse.



106
107
108
# File 'lib/casclient/responses.rb', line 106

def initialize(raw_text)
  parse(raw_text)
end

Instance Attribute Details

#proxy_ticketObject (readonly)

Returns the value of attribute proxy_ticket.



104
105
106
# File 'lib/casclient/responses.rb', line 104

def proxy_ticket
  @proxy_ticket
end

Instance Method Details

#is_failure?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/casclient/responses.rb', line 133

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

#is_success?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/casclient/responses.rb', line 129

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

#parse(raw_text) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/casclient/responses.rb', line 110

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