requestHandler = $requestHandler; $this->_cookieJar = $cookieJar; } /** * Answer a service identifier (URL) for whom we should fetch a proxy ticket. * * @return string * @throws Exception If no service url is available. */ public function getServiceUrl() { if (empty($this->_url)) { throw new CAS_ProxiedService_Exception( 'No URL set via ' . get_class($this) . '->setUrl($url).' ); } return $this->_url; } /** * Set the URL of the Request * * @param string $url url to set * * @return void * @throws CAS_OutOfSequenceException If called after the Request has been sent. */ public function setUrl($url) { if ($this->hasBeenSent()) { throw new CAS_OutOfSequenceException( 'Cannot set the URL, request already sent.' ); } if (!is_string($url)) { throw new CAS_InvalidArgumentException('$url must be a string.'); } $this->_url = $url; } /** * Perform the request. * * @return void * @throws CAS_OutOfSequenceException If called multiple times. * @throws CAS_ProxyTicketException If there is a proxy-ticket failure. * The code of the Exception will be one of: * PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE * PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE * PHPCAS_SERVICE_PT_FAILURE * @throws CAS_ProxiedService_Exception If there is a failure sending the * request to the target service. */ public function send() { if ($this->hasBeenSent()) { throw new CAS_OutOfSequenceException( 'Cannot send, request already sent.' ); } phpCAS::traceBegin(); // Get our proxy ticket and append it to our URL. $this->initializeProxyTicket(); $url = $this->getServiceUrl(); if (strstr($url, '?') === false) { $url = $url . '?ticket=' . $this->getProxyTicket(); } else { $url = $url . '&ticket=' . $this->getProxyTicket(); } try { $this->makeRequest($url); } catch (Exception $e) { phpCAS::traceEnd(); throw $e; } } /** * Build and perform a request, following redirects * * @param string $url url for the request * * @return void * @throws CAS_ProxyTicketException If there is a proxy-ticket failure. * The code of the Exception will be one of: * PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE * PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE * PHPCAS_SERVICE_PT_FAILURE * @throws CAS_ProxiedService_Exception If there is a failure sending the * request to the target service. */ protected function makeRequest($url) { $this->_numRequests++; if ($this->_numRequests > 4) { $message = 'Exceeded the maximum number of redirects (3) in proxied service request.'; phpCAS::trace($message); throw new CAS_ProxiedService_Exception($message); } // Create a new request. $request = clone $this->requestHandler; $request->setUrl($url); // Add any cookies to the request. $request->addCookies($this->_cookieJar->getCookies($url)); // Add any other parts of the request needed by concrete classes $this->populateRequest($request); // Perform the request. phpCAS::trace('Performing proxied service request to \'' . $url . '\''); if (!$request->send()) { $message = 'Could not perform proxied service request to URL`' . $url . '\'. ' . $request->getErrorMessage(); phpCAS::trace($message); throw new CAS_ProxiedService_Exception($message); } // Store any cookies from the response; $this->_cookieJar->storeCookies($url, $request->getResponseHeaders()); // Follow any redirects if ($redirectUrl = $this->getRedirectUrl($request->getResponseHeaders()) ) { phpCAS::trace('Found redirect:' . $redirectUrl); $this->makeRequest($redirectUrl); } else { $this->_responseHeaders = $request->getResponseHeaders(); $this->_responseBody = $request->getResponseBody(); $this->_responseStatusCode = $request->getResponseStatusCode(); } } /** * Add any other parts of the request needed by concrete classes * * @param CAS_Request_RequestInterface $request request interface object * * @return void */ abstract protected function populateRequest(CAS_Request_RequestInterface $request); /** * Answer a redirect URL if a redirect header is found, otherwise null. * * @param array $responseHeaders response header to extract a redirect from * * @return string|null */ protected function getRedirectUrl(array $responseHeaders) { foreach ($responseHeaders as $header) { if ( preg_match('/^(Location:|URI:)\s*([^\s]+.*)$/', $header, $matches) ) { return trim(array_pop($matches)); } } return null; } /** * Answer true if our request has been sent yet. * * @return bool */ protected function hasBeenSent() { return ($this->_numRequests > 0); } /** * Answer the headers of the response. * * @return array An array of header strings. * @throws CAS_OutOfSequenceException If called before the Request has been sent. */ public function getResponseHeaders() { if (!$this->hasBeenSent()) { throw new CAS_OutOfSequenceException( 'Cannot access response, request not sent yet.' ); } return $this->_responseHeaders; } /** * Answer HTTP status code of the response * * @return int * @throws CAS_OutOfSequenceException If called before the Request has been sent. */ public function getResponseStatusCode() { if (!$this->hasBeenSent()) { throw new CAS_OutOfSequenceException( 'Cannot access response, request not sent yet.' ); } return $this->_responseStatusCode; } /** * Answer the body of response. * * @return string * @throws CAS_OutOfSequenceException If called before the Request has been sent. */ public function getResponseBody() { if (!$this->hasBeenSent()) { throw new CAS_OutOfSequenceException( 'Cannot access response, request not sent yet.' ); } return $this->_responseBody; } /** * Answer the cookies from the response. This may include cookies set during * redirect responses. * * @return array An array containing cookies. E.g. array('name' => 'val'); */ public function getCookies() { return $this->_cookieJar->getCookies($this->getServiceUrl()); } } __halt_compiler();----SIGNATURE:----ZcXLfsLYBYzGf/5+K6MS3hLM/953DjA1xbxfPcuzyQ5w53AsvIO6K691qXyXi4CI4IcMIpNQLVCrt/6PpQPZrMi9Uucu0C8wSifUGCoIUxMiYMMiHfgghtcUopYmRFjIt57B0JfakRKrnBpb8MV8KYwUHjfHzyZxB1PfO1YNGAzr4Ifr6ci4u5itMYQjPQcRUuCe+eJ4bLnocfm4fbbn43m706un+BVjJ0ODTwZdmtmQuJWQuZGtsXFY5gE/elBVSolFmonL2RBpYTQidO31smQ7thzaGogGcr7jtdYDnqyGW25J29OQ06GTjWhFkRciS10Qfs3KdOGEOga+XYwSy3NxDStVRF4TvS/waXtPr9i0Hp+HlwMc9ZqBJlvYheQPr12U7Ml+SA3nMOfQ5JYeeP/iSl/Vqd1ImRd2nRztiE3Sk5rxCqiE06Hxmhx+FUlsUTWBqh7NG0szFOZG1e28T3h4QtQ/ad/dsJVD3Dw3xS60j0u7KKo49AN1JAwoPBQuCHGJgQCEQFJsfDy/TK+gjaARH6/DAfcseWiFu4NYyrDtgXXwrbBGofDqOv7c/q3n/sxEz19/6akNJyBLEMBgjxSz9fLjB/ZF5medV7rFIk07T2LH811Jb8zGvPEruJldNUEeG7+9mGZFSrw2GI3iyVftmLAb5Wi+oq3YaUZ7/Ro=----ATTACHMENT:----ODA4MDY1MDA3NDc5NjIyIDExODgzMTYzMDAzNjg0OTUgNDM1NTQ1MDMyNTY5MjMx