Sha256: 50ddc913810318e31235d6f8b5aff285af1c3172a9921154e3367fe0ef30a129

Contents?: true

Size: 1.68 KB

Versions: 24

Compression:

Stored size: 1.68 KB

Contents

require 'uri'
require 'net/https'

module Castronaut
  module Models

    class ProxyTicket < ServiceTicket

      MissingMessage = "Ticket or service parameter was missing in the request."

      belongs_to :proxy_granting_ticket

      before_validation :dispense_ticket, :if => :new_record?
      validates_presence_of :ticket, :client_hostname, :service, :username, :ticket_granting_ticket

      def self.validate_ticket(service, ticket)
        service_ticket_result = Castronaut::Models::ServiceTicket.validate_ticket(service, ticket, true)

        return service_ticket_result if service_ticket_result.invalid?

        if service_ticket_result.ticket === Castronaut::Models::ProxyTicket
          if service_ticket_result.ticket.proxy_granting_ticket.nil?
            return Castronaut::TicketResult.new(service_ticket_result.ticket, "Proxy ticket '#{service_ticket_result.ticket}' belonging to user '#{service_ticket_result.username}' is not associated with a proxy granting ticket.", "INTERNAL_ERROR")
          elsif service_ticket_result.ticket.proxy_granting_ticket.service_ticket.nil?
            return Castronaut::TicketResult.new(service_ticket_result.ticket, "Proxy granting ticket '#{service_ticket_result.ticket.proxy_granting_ticket}' (associated with proxy ticket '#{service_ticket_result.ticket}' and belonging to user '#{service_ticket_result.username}' is not associated with a service ticket.", "INTERNAL_ERROR")
          end
        end

        Castronaut::TicketResult.new(service_ticket_result.ticket, nil, "success")
      end

      def ticket_prefix
        "PT"
      end
      
      def proxies
        [proxy_granting_ticket.service_ticket.service]
      end

    end

  end
end

Version data entries

24 entries across 24 versions & 5 rubygems

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