private function CasProxyHelper::parseProxyTicket in CAS 2.x
Same name and namespace in other branches
- 8 src/Service/CasProxyHelper.php \Drupal\cas\Service\CasProxyHelper::parseProxyTicket()
Parse proxy ticket from CAS Server response.
Parameters
string $xml: XML response from CAS Server.
Return value
mixed A proxy ticket to be used with the target service, FALSE on failure.
Throws
\Drupal\cas\Exception\CasProxyException Thrown if there was a problem parsing the proxy validation response.
1 call to CasProxyHelper::parseProxyTicket()
- CasProxyHelper::getProxyTicket in src/
Service/ CasProxyHelper.php - Get a proxy ticket using a proxy granting ticket.
File
- src/
Service/ CasProxyHelper.php, line 203
Class
- CasProxyHelper
- Default implementation of 'cas.proxy_helper' service.
Namespace
Drupal\cas\ServiceCode
private function parseProxyTicket($xml) {
$dom = new \DOMDocument();
$dom->preserveWhiteSpace = FALSE;
$dom->encoding = "utf-8";
if (@$dom
->loadXML($xml) === FALSE) {
throw new CasProxyException("CAS Server returned non-XML response.");
}
$failure_elements = $dom
->getElementsByTagName("proxyFailure");
if ($failure_elements->length > 0) {
// Something went wrong with proxy ticket validation.
throw new CasProxyException("CAS Server rejected proxy request.");
}
$success_elements = $dom
->getElementsByTagName("proxySuccess");
if ($success_elements->length === 0) {
// Malformed response from CAS Server.
throw new CasProxyException("CAS Server returned malformed response.");
}
$success_element = $success_elements
->item(0);
$proxy_ticket = $success_element
->getElementsByTagName("proxyTicket");
if ($proxy_ticket->length === 0) {
// Malformed ticket.
throw new CasProxyException("CAS Server provided invalid or malformed ticket.");
}
return $proxy_ticket
->item(0)->nodeValue;
}