Class: Casablanca::Cas_2_0_ResponseParser

Inherits:
CasResponseParser show all
Defined in:
lib/casablanca/response_parsers.rb

Instance Method Summary collapse

Methods inherited from CasResponseParser

parse, #protocol

Constructor Details

#initialize(xml) ⇒ Cas_2_0_ResponseParser

Returns a new instance of Cas_2_0_ResponseParser.



21
22
23
24
# File 'lib/casablanca/response_parsers.rb', line 21

def initialize(xml)
  doc = REXML::Document.new(xml)
  @xml = doc.elements['cas:serviceResponse'].elements[1]
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/casablanca/response_parsers.rb', line 30

def authenticated?
  @xml.name == 'authenticationSuccess'
end

#failure_codeObject



34
35
36
# File 'lib/casablanca/response_parsers.rb', line 34

def failure_code
  @xml.elements['//cas:authenticationFailure'].attributes['code']
end

#failure_messageObject



38
39
40
# File 'lib/casablanca/response_parsers.rb', line 38

def failure_message
  strip_text(@xml.elements['//cas:authenticationFailure'])
end

#userObject



26
27
28
# File 'lib/casablanca/response_parsers.rb', line 26

def user
  strip_text(@xml.elements['cas:user'])
end