class CASClient::LoginResponse
Represents a response from the CAS
server to a login request (i.e. after submitting a username/password).
Attributes
failure_message[R]
service_redirect_url[R]
tgt[R]
ticket[R]
Public Class Methods
new(http_response = nil, options={})
click to toggle source
# File lib/casclient/responses.rb, line 175 def initialize(http_response = nil, options={}) parse_http_response(http_response) if http_response end
Public Instance Methods
is_failure?()
click to toggle source
# File lib/casclient/responses.rb, line 213 def is_failure? @failure == true end
is_success?()
click to toggle source
# File lib/casclient/responses.rb, line 209 def is_success? !@failure && !ticket.blank? end
parse_http_response(http_response)
click to toggle source
# File lib/casclient/responses.rb, line 179 def parse_http_response(http_response) header = http_response.to_hash # FIXME: this regexp might be incorrect... if header['set-cookie'] && header['set-cookie'].first && header['set-cookie'].first =~ /tgt=([^&]+);/ @tgt = $~[1] end location = header['location'].first if header['location'] && header['location'].first if location =~ /ticket=([^&]+)/ @ticket = $~[1] end if not ((http_response.kind_of?(Net::HTTPSuccess) || http_response.kind_of?(Net::HTTPFound)) && @ticket.present?) @failure = true # Try to extract the error message -- this only works with RubyCAS-Server. # For other servers we just return the entire response body (i.e. the whole error page). body = http_response.body if body =~ /<div class="messagebox mistake">(.*?)<\/div>/m @failure_message = $~[1].strip else @failure_message = body end end @service_redirect_url = location end