From ff83cbd6fb37b1bb6f7f123354e779fd5b6cae4e Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 7 Mar 2011 13:25:09 +0000
Subject: [PATCH] SAML2_AuthnRequest: Add support for
 AssertionConsumerServiceIndex.

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

diff --git a/lib/SAML2/AuthnRequest.php b/lib/SAML2/AuthnRequest.php
index 44fa85c1d..2e2134f5f 100644
--- a/lib/SAML2/AuthnRequest.php
+++ b/lib/SAML2/AuthnRequest.php
@@ -68,6 +68,14 @@ class SAML2_AuthnRequest extends SAML2_Request {
 	private $protocolBinding;
 
 
+	/**
+	 * The index of the AssertionConsumerService.
+	 *
+	 * @var int|NULL
+	 */
+	private $assertionConsumerServiceIndex;
+
+
 	/**
 	 * What authentication context was requested.
 	 *
@@ -113,6 +121,10 @@ class SAML2_AuthnRequest extends SAML2_Request {
 			$this->protocolBinding = $xml->getAttribute('ProtocolBinding');
 		}
 
+		if ($xml->hasAttribute('AssertionConsumerServiceIndex')) {
+			$this->assertionConsumerServiceIndex = (int)$xml->getAttribute('AssertionConsumerServiceIndex');
+		}
+
 		$nameIdPolicy = SAML2_Utils::xpQuery($xml, './saml_protocol:NameIDPolicy');
 
 		if (!empty($nameIdPolicy)) {
@@ -332,6 +344,28 @@ class SAML2_AuthnRequest extends SAML2_Request {
 	}
 
 
+	/**
+	 * Retrieve the value of the AssertionConsumerServiceIndex attribute.
+	 *
+	 * @return int|NULL  The AssertionConsumerServiceIndex attribute.
+	 */
+	public function getAssertionConsumerServiceIndex() {
+		return $this->assertionConsumerServiceIndex;
+	}
+
+
+	/**
+	 * Set the value of the AssertionConsumerServiceIndex attribute.
+	 *
+	 * @param string|NULL $assertionConsumerServiceIndex  The AssertionConsumerServiceIndex attribute.
+	 */
+	public function setAssertionConsumerServiceIndex($assertionConsumerServiceIndex) {
+		assert('is_int($assertionConsumerServiceIndex) || is_null($assertionConsumerServiceIndex)');
+
+		$this->assertionConsumerServiceIndex = $assertionConsumerServiceIndex;
+	}
+
+
 	/**
 	 * Retrieve the RequestedAuthnContext.
 	 *
-- 
GitLab