Class: Rmobio::Cas::MobioValidationResponse

Inherits:
CASClient::ValidationResponse
  • Object
show all
Defined in:
lib/rmobio/cas.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_text) ⇒ MobioValidationResponse

Parse out our custom attributes



44
45
46
47
# File 'lib/rmobio/cas.rb', line 44

def initialize(raw_text)
  parse(raw_text)
  parse_uuid(raw_text)
end

Instance Attribute Details

#uuidObject (readonly)

Returns the value of attribute uuid.



41
42
43
# File 'lib/rmobio/cas.rb', line 41

def uuid
  @uuid
end

Instance Method Details

#parse_uuid(raw_text) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rmobio/cas.rb', line 49

def parse_uuid(raw_text)
  raise BadResponseException, 
    "CAS response is empty/blank." if raw_text.blank?

  @xml = check_and_parse_xml(raw_text)
  
  if is_success?
    @uuid = @xml.elements["cas:uuid"].text.strip if @xml.elements["cas:uuid"]
    RAILS_DEFAULT_LOGGER.info 'CAS: Successfully authenticated user ' + @uuid.to_s + 
      '...' unless not defined? RAILS_DEFAULT_LOGGER
  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#{@xml.inspect}"
  end 
end