private function SAML2_Assertion::parseSubject in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7
Parse subject in assertion.
Parameters
DOMElement $xml The assertion XML element.:
Throws
Exception
1 call to SAML2_Assertion::parseSubject()
- SAML2_Assertion::__construct in includes/
Assertion.php
File
- includes/
Assertion.php, line 116
Class
Code
private function parseSubject(DOMElement $xml) {
$subject = Utilities::xpQuery($xml, './saml_assertion:Subject');
if (empty($subject)) {
/* No Subject node. */
return;
}
elseif (count($subject) > 1) {
throw new Exception('More than one <saml:Subject> in <saml:Assertion>.');
}
$subject = $subject[0];
$nameId = Utilities::xpQuery($subject, './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData');
if (empty($nameId)) {
throw new Exception('Missing <saml:NameID> or <saml:EncryptedID> in <saml:Subject>.');
}
elseif (count($nameId) > 1) {
throw new Exception('More than one <saml:NameID> or <saml:EncryptedD> in <saml:Subject>.');
}
$nameId = $nameId[0];
if ($nameId->localName === 'EncryptedData') {
/* The NameID element is encrypted. */
$this->encryptedNameId = $nameId;
}
else {
$this->nameId = Utilities::parseNameId($nameId);
}
}