/** * Constructor for SAML 2 logout request messages. * * @param DOMElement|NULL $xml The input message. */ public function __construct(DOMElement $xml = NULL) { parent::__construct('LogoutRequest', $xml); if ($xml === NULL) { return; } $nameId = SAML2_Utils::xpQuery($xml, './saml_assertion:NameID'); if (empty($nameId)) { throw new Exception('Missing NameID in logout request.'); } $this->nameId = SAML2_Utils::parseNameId($nameId[0]); $sessionIndex = SAML2_Utils::xpQuery($xml, './saml_protocol:SessionIndex'); if (!empty($sessionIndex)) { $this->sessionIndex = trim($sessionIndex[0]->textContent); } }
/** * Parse subject in query. * * @param DOMElement $xml The SubjectQuery XML element. * @throws Exception */ private function parseSubject(DOMElement $xml) { $subject = SAML2_Utils::xpQuery($xml, './saml_assertion:Subject'); if (empty($subject)) { /* No Subject node. */ throw new Exception('Missing subject in subject query.'); } elseif (count($subject) > 1) { throw new Exception('More than one <saml:Subject> in <saml:Assertion>.'); } $subject = $subject[0]; $nameId = SAML2_Utils::xpQuery($subject, './saml_assertion:NameID'); if (empty($nameId)) { throw new Exception('Missing <saml:NameID> in <saml:Subject>.'); } elseif (count($nameId) > 1) { throw new Exception('More than one <saml:NameID> in <saml:Subject>.'); } $nameId = $nameId[0]; $this->nameId = SAML2_Utils::parseNameId($nameId); }
/** * Decrypt the NameId of the subject in the assertion. * * @param XMLSecurityKey $key The decryption key. * @param array $blacklist Blacklisted decryption algorithms. */ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array()) { if ($this->encryptedNameId === NULL) { /* No NameID to decrypt. */ return; } $nameId = SAML2_Utils::decryptElement($this->encryptedNameId, $key, $blacklist); SimpleSAML_Utilities::debugMessage($nameId, 'decrypt'); $this->nameId = SAML2_Utils::parseNameId($nameId); $this->encryptedNameId = NULL; }
/** * Decrypt the NameID in the LogoutRequest. * * @param XMLSecurityKey $key The decryption key. */ public function decryptNameId(XMLSecurityKey $key) { if ($this->encryptedNameId === NULL) { /* No NameID to decrypt. */ return; } $nameId = SAML2_Utils::decryptElement($this->encryptedNameId, $key); $this->nameId = SAML2_Utils::parseNameId($nameId); $this->encryptedNameId = NULL; }