Sha256: f8d4195ca4a2e5caed42c92ad050e33bd85ec27b3856e163f4c5b3e867fd94b9

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

module Cas
  module Client
    class Server
      def initialize
        @url = Cas::Client::URL.new(server_url)
      end

      def login_url(options={})
        if options.key?(:service_url)
          @url.append_path('/login').add_query("service=#{options[:service_url]}")
        else
          @url.append_path('/login')
        end
      end

      def logout_url(options={})
        if options.key?(:service_url)
          @url.append_path('/logout').add_query("service=#{options[:service_url]}")
        else
          @url.append_path('/logout')
        end
      end

      def self.logout_url(options={})
        new.logout_url(options).to_s
      end

      def validate_service(service_url, ticket)
        uri = Cas::Client::URL.new(validate_service_url(service_url, ticket)).to_uri
        res = Cas::Client::Response.new(uri)
        res.validate_service_response
        res.all_attributes
      end

      protected

      def server_url
        Cas::Client.configuration.server_url
      end

      def validate_service_url(service_url, ticket)
        protocol_path = "p3"
        server_url = @url
        URI("#{server_url}/#{protocol_path}/serviceValidate?service=#{service_url}&ticket=#{ticket}")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cas-client-0.2.1 lib/cas/client/server.rb
cas-client-0.2.0 lib/cas/client/server.rb