Class: CASino::ProxyTicketProviderProcessor

Inherits:
Processor
  • Object
show all
Includes:
CASino::ProcessorConcern::ProxyGrantingTickets, CASino::ProcessorConcern::ProxyTickets
Defined in:
app/processors/casino/proxy_ticket_provider_processor.rb

Overview

The ProxyTicketProvider processor should be used to handle GET requests to /proxy

Constant Summary

Constants included from CASino::ProcessorConcern::Tickets

CASino::ProcessorConcern::Tickets::ALLOWED_TICKET_STRING_CHARACTERS

Instance Method Summary collapse

Methods included from CASino::ProcessorConcern::ProxyTickets

#acquire_proxy_ticket, #ticket_valid_for_service?, #validate_ticket_for_service

Methods included from CASino::ProcessorConcern::Tickets

#random_ticket_string

Methods included from CASino::ProcessorConcern::ProxyGrantingTickets

#acquire_proxy_granting_ticket

Methods inherited from Processor

#initialize

Constructor Details

This class inherits a constructor from CASino::Processor

Instance Method Details

#process(params = nil) ⇒ Object

This method will call ‘#request_succeeded` or `#request_failed`. In both cases, it supplies a string as argument. The web application should present that string (and nothing else) to the requestor. The Content-Type should be set to ’text/xml; charset=utf-8’

Parameters:

  • params (Hash) (defaults to: nil)

    parameters delivered by the client



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/processors/casino/proxy_ticket_provider_processor.rb', line 13

def process(params = nil)
  if params[:pgt].nil? || params[:targetService].nil?
    @listener.request_failed build_xml false, error_code: 'INVALID_REQUEST', error_message: '"pgt" and "targetService" parameters are both required'
  else
    proxy_granting_ticket = CASino::ProxyGrantingTicket.where(ticket: params[:pgt]).first
    if proxy_granting_ticket.nil?
      @listener.request_failed build_xml false, error_code: 'BAD_PGT', error_message: 'PGT not found'
    else
      proxy_ticket = acquire_proxy_ticket(proxy_granting_ticket, params[:targetService])
      @listener.request_succeeded build_xml true, proxy_ticket: proxy_ticket
    end
  end
end