Sha256: deb2a1f5505acef74574a6a750e18694e7aa80acd16612e3acc70947f3e4b793

Contents?: true

Size: 1.6 KB

Versions: 23

Compression:

Stored size: 1.6 KB

Contents

module Castronaut
  module Presenters

    class ProxyValidate
      MissingCredentialsMessage = "Please supply a username and password to login."

      attr_reader :controller, :your_mission, :proxy_ticket_result, :proxies
      attr_accessor :messages, :login_ticket

      delegate :params, :request, :to => :controller
      delegate :cookies, :env, :to => :request

      def initialize(controller)
        @controller = controller
        @messages = []
        @your_mission = nil
      end

      def service
        params['service']
      end

      def renewal
        params['renew']
      end

      def ticket
        params['ticket']
      end

      def proxy_granting_ticket_url
        params['pgtUrl']
      end

      def proxy_granting_ticket_iou
        @proxy_granting_ticket_result && @proxy_granting_ticket_result.iou
      end

      def username
        @proxy_ticket_result.username
      end

      def client_host
        env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_HOST'] || env['REMOTE_ADDR']
      end

      def represent!
        @proxy_ticket_result = Castronaut::Models::ProxyTicket.validate_ticket(service, ticket)

        if @proxy_ticket_result.valid?
          @proxies = @proxy_ticket_result.proxies

          if proxy_granting_ticket_url
            @proxy_granting_ticket_result = Castronaut::Models::ProxyGrantingTicket.generate_ticket(proxy_granting_ticket_url, client_host, @proxy_ticket_result.ticket)
          end
        end

        @your_mission = lambda { controller.erb :proxy_validate, :layout => false, :locals => { :presenter => self } }

        self
      end

    end

  end
end

Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
masover-castronaut-0.4.4.4 lib/castronaut/presenters/proxy_validate.rb
p8-castronaut-0.6.1.1 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.2.0 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.2.5 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.3.0 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.3.5 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.3.6 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.4.1 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.4.2 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.4.3 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.4.4 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.4.5 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.4.6 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.5.0 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.5.1 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.5.2 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.5.3 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.5.4 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.6.0 lib/castronaut/presenters/proxy_validate.rb
relevance-castronaut-0.6.1 lib/castronaut/presenters/proxy_validate.rb