diff --git a/lib/SimpleSAML/XML/SAML20/LogoutRequest.php b/lib/SimpleSAML/XML/SAML20/LogoutRequest.php index e3ba3310460a68a743b636a0f79b63b44bad4892..35592bd343d561c32c07923329e1ff1474b7b97a 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 95d68862ecf78c3d4ce34833b171acf5e3b665c9..7f8b8bd7d87d363b28b6ed4229adb5a2156691ed 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'))) {