public function CasProxyHelper::getProxyTicket in CAS 2.x
Same name and namespace in other branches
- 8 src/Service/CasProxyHelper.php \Drupal\cas\Service\CasProxyHelper::getProxyTicket()
Get a proxy ticket using a proxy granting ticket.
Parameters
string $target_service: The service to be proxied.
Return value
string The proxy ticket returned by the CAS server.
Throws
\Drupal\cas\Exception\CasProxyException Thrown if there was a problem communicating with the CAS server.
1 call to CasProxyHelper::getProxyTicket()
- CasProxyHelper::proxyAuthenticate in src/
Service/ CasProxyHelper.php - Proxy authenticates to a target service.
File
- src/
Service/ CasProxyHelper.php, line 109
Class
- CasProxyHelper
- Default implementation of 'cas.proxy_helper' service.
Namespace
Drupal\cas\ServiceCode
public function getProxyTicket($target_service) {
if (!($this->settings
->get('proxy.initialize') && $this->session
->has('cas_pgt'))) {
// We can't perform proxy authentication in this state.
throw new CasProxyException("Session state not sufficient for proxying.");
}
// Make request to CAS server to retrieve a proxy ticket for this service.
$cas_url = $this
->getServerProxyUrl($target_service);
try {
$this->casHelper
->log(LogLevel::DEBUG, "Retrieving proxy ticket from %cas_url", [
'%cas_url' => $cas_url,
]);
// @todo Consider allowing the config to be altered.
$casServerConfig = CasServerConfig::createFromModuleConfig($this->settings);
$casServerConnectionOptions = $casServerConfig
->getCasServerGuzzleConnectionOptions();
$response = $this->httpClient
->get($cas_url, $casServerConnectionOptions);
} catch (ClientException $e) {
throw new CasProxyException($e
->getMessage());
}
$proxy_ticket = $this
->parseProxyTicket($response
->getBody());
$this->casHelper
->log(LogLevel::DEBUG, "Extracted proxy ticket %ticket", [
'%ticket' => $proxy_ticket,
]);
return $proxy_ticket;
}