From 2389e0fd047d6fcbf120f5102c79ed359392c3ed Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 17 Dec 2007 14:55:03 +0000 Subject: [PATCH] SAML2:AuthnResponse - Added getInResponseTo() method to get the InResponseTo attribute of the response-element. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@116 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/XML/SAML20/AuthnResponse.php | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/SimpleSAML/XML/SAML20/AuthnResponse.php b/lib/SimpleSAML/XML/SAML20/AuthnResponse.php index d8c2c74f9..986fbc5a1 100644 --- a/lib/SimpleSAML/XML/SAML20/AuthnResponse.php +++ b/lib/SimpleSAML/XML/SAML20/AuthnResponse.php @@ -337,7 +337,35 @@ class SimpleSAML_XML_SAML20_AuthnResponse extends SimpleSAML_XML_AuthnResponse { //echo '<pre>'; print_r($nameID); echo '</pre>'; return $nameID; } - + + + /* This function retrieves the ID of the request this response is a + * response to. This ID is stored in the InResponseTo attribute of the + * top level DOM element. + * + * Returns: + * The ID of the request this response is a response to, or NULL if + * we don't know. + */ + public function getInResponseTo() { + $dom = $this->getDOM(); + if($dom === NULL) { + return NULL; + } + + assert('$dom instanceof DOMDocument'); + + $xPath = new DOMXpath($dom); + $xPath->registerNamespace('samlp', 'urn:oasis:names:tc:SAML:2.0:protocol'); + + $result = $xPath->query('/samlp:Response/@InResponseTo'); + if($result->length === 0) { + return NULL; + } + + return $result->item(0)->value; + } + // Not updated for response. from request. public function generate($idpentityid, $spentityid, $inresponseto, $nameid, $attributes) { -- GitLab