Class: CASClient::ProxyResponse
- Inherits:
-
Object
- Object
- CASClient::ProxyResponse
- 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
-
#proxy_ticket ⇒ Object
readonly
Returns the value of attribute proxy_ticket.
Attributes included from XmlResponse
#failure_code, #failure_message, #parse_datetime, #xml
Instance Method Summary collapse
-
#initialize(raw_text) ⇒ ProxyResponse
constructor
A new instance of ProxyResponse.
- #is_failure? ⇒ Boolean
- #is_success? ⇒ Boolean
- #parse(raw_text) ⇒ Object
Methods included from XmlResponse
Constructor Details
#initialize(raw_text) ⇒ ProxyResponse
Returns a new instance of ProxyResponse.
96 97 98 |
# File 'lib/casclient/responses.rb', line 96 def initialize(raw_text) parse(raw_text) end |
Instance Attribute Details
#proxy_ticket ⇒ Object (readonly)
Returns the value of attribute proxy_ticket.
94 95 96 |
# File 'lib/casclient/responses.rb', line 94 def proxy_ticket @proxy_ticket end |
Instance Method Details
#is_failure? ⇒ Boolean
123 124 125 |
# File 'lib/casclient/responses.rb', line 123 def is_failure? xml.name == "proxyFailure" end |
#is_success? ⇒ Boolean
119 120 121 |
# File 'lib/casclient/responses.rb', line 119 def is_success? xml.name == "proxySuccess" end |
#parse(raw_text) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/casclient/responses.rb', line 100 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 |