Class: Castanet::ProxyTicket
- Inherits:
-
ServiceTicket
- Object
- ServiceTicket
- Castanet::ProxyTicket
- Defined in:
- lib/castanet/proxy_ticket.rb
Instance Attribute Summary collapse
-
#proxy_response ⇒ #ticket
The
/proxy
response from the CAS server. -
#proxy_url ⇒ String
The URL of the CAS server's proxy ticket granting service.
-
#proxy_validate_url ⇒ String
The URL of the CAS server's proxy ticket validation service.
Attributes inherited from ServiceTicket
#https_required, #pgt, #proxy_callback_url, #proxy_retrieval_url, #response, #service, #service_validate_url
Instance Method Summary collapse
-
#initialize(pt, pgt, service) ⇒ ProxyTicket
constructor
Initializes an instance of ProxyTicket.
-
#reify! ⇒ Object
Requests a proxy ticket from #proxy_url and stores it in #ticket.
-
#ticket ⇒ String?
The proxy ticket wrapped by this object.
-
#to_s ⇒ String
Returns the string representation of #ticket.
Methods inherited from ServiceTicket
Methods included from QueryBuilding
Methods included from Responses
#parsed_proxy_response, #parsed_ticket_validate_response
Constructor Details
#initialize(pt, pgt, service) ⇒ ProxyTicket
Initializes an instance of ProxyTicket.
Instantiation guide
- If requesting a proxy ticket, set
pt
to nil,service
to the service URL, andpgt
to the proxy granting ticket. - If checking a proxy ticket, set
pt
to the proxy ticket,service
to the service URL, andpgt
to nil.
45 46 47 48 49 |
# File 'lib/castanet/proxy_ticket.rb', line 45 def initialize(pt, pgt, service) super(pt, service) self.pgt = pgt end |
Instance Attribute Details
#proxy_response ⇒ #ticket
The /proxy
response from the CAS server.
This is set by #reify!, but can be set manually for testing purposes.
25 26 27 |
# File 'lib/castanet/proxy_ticket.rb', line 25 def proxy_response @proxy_response end |
#proxy_url ⇒ String
The URL of the CAS server's proxy ticket granting service.
11 12 13 |
# File 'lib/castanet/proxy_ticket.rb', line 11 def proxy_url @proxy_url end |
#proxy_validate_url ⇒ String
The URL of the CAS server's proxy ticket validation service.
17 18 19 |
# File 'lib/castanet/proxy_ticket.rb', line 17 def proxy_validate_url @proxy_validate_url end |
Instance Method Details
#reify! ⇒ Object
Requests a proxy ticket from #proxy_url and stores it in #ticket.
If a proxy ticket cannot be issued for any reason, this method raises a Castanet::ProxyTicketError containing the failure code and reason returned by the CAS server.
This method should only be run once per ProxyTicket
instance. It can be
run multiple times, but each invocation will overwrite #ticket with a
new ticket.
This method is automatically called by Client#issue_proxy_ticket, and
as such should never need to be called by users of Castanet; however, in
the interest of program organization, the method is public and located
here. Also, if you're managing ProxyTicket
instances manually for some
reason, you may find this method useful.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/castanet/proxy_ticket.rb', line 95 def reify! raise ProxyTicketError, 'A PGT is not present.' unless pgt uri = URI.parse(proxy_url).tap do |u| u.query = grant_parameters end net_http(uri).start do |h| cas_response = h.get(uri.to_s) self.proxy_response = parsed_proxy_response(cas_response.body) unless issued? raise ProxyTicketError, "A proxy ticket could not be issued. Code: <#{failure_code}>, reason: <#{failure_reason}>." end end end |
#ticket ⇒ String?
60 61 62 |
# File 'lib/castanet/proxy_ticket.rb', line 60 def ticket proxy_response ? proxy_response.ticket : super end |