Class: Castronaut::Presenters::ServiceValidate

Inherits:
Object
  • Object
show all
Defined in:
lib/castronaut/presenters/service_validate.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ ServiceValidate

Returns a new instance of ServiceValidate.



13
14
15
16
17
# File 'lib/castronaut/presenters/service_validate.rb', line 13

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

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



7
8
9
# File 'lib/castronaut/presenters/service_validate.rb', line 7

def controller
  @controller
end

#login_ticketObject

Returns the value of attribute login_ticket.



8
9
10
# File 'lib/castronaut/presenters/service_validate.rb', line 8

def 
  @login_ticket
end

#messagesObject

Returns the value of attribute messages.



8
9
10
# File 'lib/castronaut/presenters/service_validate.rb', line 8

def messages
  @messages
end

#your_missionObject (readonly)

Returns the value of attribute your_mission.



7
8
9
# File 'lib/castronaut/presenters/service_validate.rb', line 7

def your_mission
  @your_mission
end

Instance Method Details

#client_hostObject



43
44
45
# File 'lib/castronaut/presenters/service_validate.rb', line 43

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

#proxy_granting_ticket_iouObject



35
36
37
# File 'lib/castronaut/presenters/service_validate.rb', line 35

def proxy_granting_ticket_iou
  @proxy_granting_ticket_result && @proxy_granting_ticket_result.iou
end

#proxy_granting_ticket_urlObject



31
32
33
# File 'lib/castronaut/presenters/service_validate.rb', line 31

def proxy_granting_ticket_url
  params['pgtUrl']
end

#renewalObject



23
24
25
# File 'lib/castronaut/presenters/service_validate.rb', line 23

def renewal
  params['renew']
end

#represent!Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/castronaut/presenters/service_validate.rb', line 51

def represent!
  @service_ticket_result = Castronaut::Models::ServiceTicket.validate_ticket(service, ticket)

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

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

  self
end

#serviceObject



19
20
21
# File 'lib/castronaut/presenters/service_validate.rb', line 19

def service
  params['service']
end

#service_ticket_resultObject



47
48
49
# File 'lib/castronaut/presenters/service_validate.rb', line 47

def service_ticket_result
  @service_ticket_result
end

#ticketObject



27
28
29
# File 'lib/castronaut/presenters/service_validate.rb', line 27

def ticket
  params['ticket']
end

#usernameObject



39
40
41
# File 'lib/castronaut/presenters/service_validate.rb', line 39

def username
  @service_ticket_result.username
end