class Cas::Client::Response

Public Class Methods

new(uri) click to toggle source
# File lib/cas/client/response.rb, line 4
def initialize(uri)
  @request_uri = uri
  @response = nil
end

Public Instance Methods

all_attributes() click to toggle source
# File lib/cas/client/response.rb, line 17
def all_attributes
  get_user.merge!(get_extra_attributes)
end
success?() click to toggle source
# File lib/cas/client/response.rb, line 13
def success?
  @response.to_s.match(/<#{xml_namespace}:authenticationSuccess>/)
end
validate_service_response() click to toggle source
# File lib/cas/client/response.rb, line 9
def validate_service_response
  @response = Net::HTTP.get(@request_uri)
end

Protected Instance Methods

get_extra_attributes() click to toggle source
# File lib/cas/client/response.rb, line 36
def get_extra_attributes
  {}.tap do |attributes|
    Cas::Client.configuration.extra_attributes.each do |ea|
      match = @response.match(/<#{xml_namespace}:#{ea}>(.*)<\/#{xml_namespace}:#{ea}>/)

      if match
        attributes[ea] = match.captures.first
      else
        attributes
      end
    end
  end
end
get_user() click to toggle source
# File lib/cas/client/response.rb, line 27
def get_user
  match = @response.match(/<#{xml_namespace}:user>(.*)<\/#{xml_namespace}:user>/)
  if match
    { user: match.captures.first }
  else # Failed login
    {}
  end
end
xml_namespace() click to toggle source
# File lib/cas/client/response.rb, line 23
def xml_namespace
  Cas::Client.configuration.cas_namespace
end