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)
-
- (Object) proxy_ticket
readonly
Returns the value of attribute proxy_ticket.
Attributes included from XmlResponse
#failure_code, #failure_message, #parse_datetime, #xml
Instance Method Summary (collapse)
-
- (ProxyResponse) initialize(raw_text, options = {})
constructor
A new instance of ProxyResponse.
- - (Boolean) is_failure?
- - (Boolean) is_success?
- - (Object) parse(raw_text)
Methods included from XmlResponse
Constructor Details
- (ProxyResponse) initialize(raw_text, options = {})
A new instance of ProxyResponse
137 138 139 |
# File 'lib/casclient/responses.rb', line 137 def initialize(raw_text, ={}) parse(raw_text) end |
Instance Attribute Details
- (Object) proxy_ticket (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
- (Boolean) is_failure?
164 165 166 |
# File 'lib/casclient/responses.rb', line 164 def is_failure? xml.name == "proxyFailure" end |
- (Boolean) is_success?
160 161 162 |
# File 'lib/casclient/responses.rb', line 160 def is_success? xml.name == "proxySuccess" end |
- (Object) parse(raw_text)
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 |