lib/casclient/client.rb
# Fetches a CAS response of the given type from the given URI.
# Type should be either ValidationResponse or ProxyResponse.
Fetches a CAS response of the given type from the given URI.
Type should be either ValidationResponse or ProxyResponse.
Fetches a CAS response of the given type from the given URI . Type should be either ValidationResponse or ProxyResponse .
def request_cas_response(uri, type)
      log.debug "Requesting CAS response for URI #{uri}"
      uri = URI.parse(uri) unless uri.kind_of? URI
      https = Net::HTTP.new(uri.host, uri.port)
      https.use_ssl = (uri.scheme == 'https')
      https.verify_mode = (@force_ssl_verification ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE)
      begin
        raw_res = https.start do |conn|
          conn.get("#{uri.path}?#{uri.query}")
        end
      rescue Errno::ECONNREFUSED => e
        log.error "CAS server did not respond! (#{e.inspect})"
        raise "The CAS authentication server at #{uri} is not responding!"
      end
      if raw_res.kind_of?(Net::HTTPSuccess) || raw_res.code.to_i == 422
        log.debug "CAS server responded with #{raw_res.inspect}:\n#{raw_res.body}"
      else
        log.error "CAS server responded with an error! (#{raw_res.inspect})"
        raise "The CAS authentication server at #{uri} responded with an error (#{raw_res.inspect})!"
      end
      type.new(raw_res.body)
    end
def request_cas_response ( uri , type ) log . debug "Requesting CAS response for URI #{uri}" uri = URI . parse ( uri ) unless uri . kind_of? URI https = Net :: HTTP . new ( uri . host , uri . port ) https . use_ssl = ( uri . scheme == 'https' ) https . verify_mode = ( @force_ssl_verification ? OpenSSL :: SSL :: VERIFY_PEER : OpenSSL :: SSL :: VERIFY_NONE ) begin raw_res = https . start do | conn | conn . get ( "#{uri.path}?#{uri.query}" ) end rescue Errno :: ECONNREFUSED => e log . error "CAS server did not respond! (#{e.inspect})" raise "The CAS authentication server at #{uri} is not responding!" end if raw_res . kind_of? ( Net :: HTTPSuccess ) || raw_res . code . to_i == 422 log . debug "CAS server responded with #{raw_res.inspect}:\n#{raw_res.body}" else log . error "CAS server responded with an error! (#{raw_res.inspect})" raise "The CAS authentication server at #{uri} responded with an error (#{raw_res.inspect})!" end type . new ( raw_res . body ) end
Fetches a CAS response of the given type from the given URI.
Fetches a CAS response of the given type from the given URI .
# We accept responses of type 422 since RubyCAS-Server generates these # in response to requests from the client that are processable but contain # invalid CAS data (for example an invalid service ticket).
uri
type