From 7fb7174286577934b07d2059f2b2dc3c0f406ff2 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 7 Mar 2011 13:25:41 +0000
Subject: [PATCH] SAML2_LogoutRequest: Add support for NotOnOrAfter attribute.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2755 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SAML2/LogoutRequest.php | 38 +++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/lib/SAML2/LogoutRequest.php b/lib/SAML2/LogoutRequest.php
index 1fd7b8543..c2369f840 100644
--- a/lib/SAML2/LogoutRequest.php
+++ b/lib/SAML2/LogoutRequest.php
@@ -8,6 +8,13 @@
  */
 class SAML2_LogoutRequest extends SAML2_Request {
 
+	/**
+	 * The expiration time of this request.
+	 *
+	 * @var int|NULL
+	 */
+	private $notOnOrAfter;
+
 
 	/**
 	 * The encrypted NameID in the request.
@@ -49,6 +56,10 @@ class SAML2_LogoutRequest extends SAML2_Request {
 			return;
 		}
 
+		if ($xml->hasAttribute('NotOnOrAfter')) {
+			$this->notOnOrAfter = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('NotOnOrAfter'));
+		}
+
 		$nameId = SAML2_Utils::xpQuery($xml, './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData');
 		if (empty($nameId)) {
 			throw new Exception('Missing <saml:NameID> or <saml:EncryptedID> in <samlp:LogoutRequest>.');
@@ -70,6 +81,29 @@ class SAML2_LogoutRequest extends SAML2_Request {
 	}
 
 
+	/**
+	 * Retrieve the expiration time of this request.
+	 *
+	 * @return int|NULL  The expiration time of this request.
+	 */
+	public function getNotOnOrAfter() {
+
+		return $this->notOnOrAfter;
+	}
+
+
+	/**
+	 * Set the expiration time of this request.
+	 *
+	 * @param int|NULL $notOnOrAfter  The expiration time of this request.
+	 */
+	public function setNotOnOrAfter($notOnOrAfter) {
+		assert('is_int($notOnOrAfter) || is_null($notOnOrAfter)');
+
+		$this->notOnOrAfter = $notOnOrAfter;
+	}
+
+
 	/**
 	 * Check whether the NameId is encrypted.
 	 *
@@ -225,6 +259,10 @@ class SAML2_LogoutRequest extends SAML2_Request {
 
 		$root = parent::toUnsignedXML();
 
+		if ($this->notOnOrAfter !== NULL) {
+			$root->setAttribute('NotOnOrAfter', gmdate('Y-m-d\TH:i:s\Z', $this->notOnOrAfter));
+		}
+
 		if ($this->encryptedNameId === NULL) {
 			SAML2_Utils::addNameId($root, $this->nameId);
 		} else {
-- 
GitLab