From dd35c014d5fe48365ccfb7f8870c1ac02219abd3 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Tue, 13 May 2008 11:31:04 +0000 Subject: [PATCH] Added code to retrieve the ID used in a LogoutRequest and the InResponseTo attribute from a LogoutResponse. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@541 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/XML/SAML20/LogoutRequest.php | 23 ++++++++++++++++++-- lib/SimpleSAML/XML/SAML20/LogoutResponse.php | 20 +++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/SimpleSAML/XML/SAML20/LogoutRequest.php b/lib/SimpleSAML/XML/SAML20/LogoutRequest.php index e3ba33104..35592bd34 100644 --- a/lib/SimpleSAML/XML/SAML20/LogoutRequest.php +++ b/lib/SimpleSAML/XML/SAML20/LogoutRequest.php @@ -23,9 +23,19 @@ class SimpleSAML_XML_SAML20_LogoutRequest { const PROTOCOL = 'urn:oasis:names:tc:SAML:2.0'; + + /** + * This variable holds the generated request id for this request. + */ + private $id = null; + + function __construct(SimpleSAML_Configuration $configuration, SimpleSAML_Metadata_MetaDataStorageHandler $metadatastore) { $this->configuration = $configuration; $this->metadata = $metadatastore; + + /* Generate request id. */ + $this->id = SimpleSAML_Utilities::generateID(); } public function setXML($xml) { @@ -128,7 +138,6 @@ class SimpleSAML_XML_SAML20_LogoutRequest { $spnamequalifier = isset($issuermd['SPNameQualifier']) ? $issuermd['SPNameQualifier'] : $issuermd['entityid']; } - $id = SimpleSAML_Utilities::generateID(); $issueInstant = SimpleSAML_Utilities::generateTimestamp(); $destination = $receivermd['SingleLogoutService']; @@ -136,7 +145,7 @@ class SimpleSAML_XML_SAML20_LogoutRequest { $logoutRequest = '<samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" - ID="' . $id . '" Version="2.0" + ID="' . $this->id . '" Version="2.0" Destination="' . htmlspecialchars($destination) . '" IssueInstant="' . $issueInstant . '"> <saml:Issuer >' . htmlspecialchars($issuer) . '</saml:Issuer> @@ -147,6 +156,16 @@ class SimpleSAML_XML_SAML20_LogoutRequest { return $logoutRequest; } + + /** + * This function retrieves the request id we used for the generated logout request. + * + * @return The request id of the generated logout request. + */ + public function getGeneratedID() { + return $this->id; + } + } ?> \ No newline at end of file diff --git a/lib/SimpleSAML/XML/SAML20/LogoutResponse.php b/lib/SimpleSAML/XML/SAML20/LogoutResponse.php index 95d68862e..7f8b8bd7d 100644 --- a/lib/SimpleSAML/XML/SAML20/LogoutResponse.php +++ b/lib/SimpleSAML/XML/SAML20/LogoutResponse.php @@ -81,6 +81,26 @@ class SimpleSAML_XML_SAML20_LogoutResponse { return $issuer; } + + /** + * This function retrieves the InResponseTo attribute value from the logout response. + * + * @return The InResponseTo attribute value from the logout response. + */ + public function getInResponseTo() { + $dom = $this->getDOM(); + + $responseElement = $dom->getElementsByTagName('LogoutResponse')->item(0); + $inResponseTo = $responseElement->getAttribute('InResponseTo'); + + if(empty($inResponseTo)) { + throw new Exception('Empty InResponseTo attribute on SAML2 logout response.'); + } + + return $inResponseTo; + } + + // Not updated for response. from request. public function generate($issuer, $receiver, $inresponseto, $mode ) { if (!in_array($mode, array('SP', 'IdP'))) { -- GitLab