Class: Casablanca::Client
- Inherits:
-
Object
- Object
- Casablanca::Client
- Defined in:
- lib/casablanca/client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cas_server_url ⇒ Object
Returns the value of attribute cas_server_url.
-
#service_url ⇒ Object
Returns the value of attribute service_url.
Class Method Summary collapse
Instance Method Summary collapse
-
#authenticate_ticket(ticket) ⇒ Object
Validates a Ticket to the validation url of the CAS Server and checks if the ticket is authenticated.
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #logger ⇒ Object
- #logger=(logger) ⇒ Object
-
#login_url(params = {}) ⇒ Object
The login url of the Cas server.
-
#logout_url(params = {}) ⇒ Object
The logout url of the Cas server.
-
#validate_url ⇒ Object
The proxy validation url of the Cas server.
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 |
# File 'lib/casablanca/client.rb', line 12 def initialize(config) raise ":cas_server_url is required" unless config[:cas_server_url] @cas_server_url = config[:cas_server_url] @service_url = config[:service_url] end |
Instance Attribute Details
#cas_server_url ⇒ Object
Returns the value of attribute cas_server_url.
10 11 12 |
# File 'lib/casablanca/client.rb', line 10 def cas_server_url @cas_server_url end |
#service_url ⇒ Object
Returns the value of attribute service_url.
10 11 12 |
# File 'lib/casablanca/client.rb', line 10 def service_url @service_url end |
Class Method Details
.logger ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/casablanca/client.rb', line 66 def self.logger unless @logger @logger = ::Logger.new($stderr) @logger.level = Logger::WARN end @logger end |
.logger=(logger) ⇒ Object
62 63 64 |
# File 'lib/casablanca/client.rb', line 62 def self.logger=logger @logger = logger end |
Instance Method Details
#authenticate_ticket(ticket) ⇒ Object
Validates a Ticket to the validation url of the CAS Server and checks if the ticket is authenticated
21 22 23 24 |
# File 'lib/casablanca/client.rb', line 21 def authenticate_ticket(ticket) request_validation(ticket) ticket.authenticate end |
#logger ⇒ Object
54 55 56 |
# File 'lib/casablanca/client.rb', line 54 def logger self.class.logger end |
#logger=(logger) ⇒ Object
58 59 60 |
# File 'lib/casablanca/client.rb', line 58 def logger=logger self.class.logger = logger end |
#login_url(params = {}) ⇒ Object
The login url of the Cas server. This page has the login form.
28 29 30 31 32 33 34 35 36 |
# File 'lib/casablanca/client.rb', line 28 def login_url(params={}) uri = URI.parse("#{@cas_server_url}/login") query = {:service => @service_url} # TODO Check that only one of these can be set query[:renew] = 'true' if params[:renew] query[:gateway] = 'true' if params[:gateway] uri.merge_query(query) uri.to_s end |
#logout_url(params = {}) ⇒ Object
The logout url of the Cas server
40 41 42 43 44 45 46 |
# File 'lib/casablanca/client.rb', line 40 def logout_url(params={}) uri = URI.parse("#{@cas_server_url}/logout") query = {} query[:url] = params[:url] if params[:url] uri.merge_query(query) uri.to_s end |
#validate_url ⇒ Object
The proxy validation url of the Cas server.
50 51 52 |
# File 'lib/casablanca/client.rb', line 50 def validate_url "#{@cas_server_url}/proxyValidate" end |