Sha256: a1bbb1c373cfd6786f19d66cbf2fe6130b4304d103e069c4067ac66c19b75d7f

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module Cas
  module Client
    class Server
      def initialize(server_url)
        @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 validate_service(service_url, ticket, option={})
        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(option[:extra_attributes]||[])
      end

      protected

      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

1 entries across 1 versions & 1 rubygems

Version Path
cas-client-0.1.3 lib/cas/client/server.rb