Module: CASClient::XmlResponse

Included in:
ProxyResponse, ValidationResponse
Defined in:
lib/casclient/responses.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#failure_codeObject (readonly)

Returns the value of attribute failure_code.



4
5
6
# File 'lib/casclient/responses.rb', line 4

def failure_code
  @failure_code
end

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



4
5
6
# File 'lib/casclient/responses.rb', line 4

def failure_message
  @failure_message
end

#parse_datetimeObject (readonly)

Returns the value of attribute parse_datetime.



3
4
5
# File 'lib/casclient/responses.rb', line 3

def parse_datetime
  @parse_datetime
end

#xmlObject (readonly)

Returns the value of attribute xml.



3
4
5
# File 'lib/casclient/responses.rb', line 3

def xml
  @xml
end

Instance Method Details

#check_and_parse_xml(raw_xml) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/casclient/responses.rb', line 6

def check_and_parse_xml(raw_xml)
  begin
    doc = REXML::Document.new(raw_xml, :raw => :all)
  rescue REXML::ParseException => e
    raise BadResponseException, 
      "MALFORMED CAS RESPONSE:\n#{raw_xml.inspect}\n\nEXCEPTION:\n#{e}"
  end

  unless doc.elements && doc.elements["cas:serviceResponse"]
    raise BadResponseException, 
      "This does not appear to be a valid CAS response (missing cas:serviceResponse root element)!\nXML DOC:\n#{doc.to_s}"
  end

  return doc.elements["cas:serviceResponse"].elements[1]
end

#to_sObject



22
23
24
# File 'lib/casclient/responses.rb', line 22

def to_s
  xml.to_s
end