From 193d7224e22d03ac2769f0593210b7cd557f3b09 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Thu, 12 Nov 2009 14:42:52 +0000
Subject: [PATCH] SAML2_AuthnRequest: Move Scoping-element to after
 NameIDPolicy as per spec.

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

diff --git a/lib/SAML2/AuthnRequest.php b/lib/SAML2/AuthnRequest.php
index 475afb877..a442dd640 100644
--- a/lib/SAML2/AuthnRequest.php
+++ b/lib/SAML2/AuthnRequest.php
@@ -271,18 +271,6 @@ class SAML2_AuthnRequest extends SAML2_Request {
 			$root->setAttribute('ProtocolBinding', $this->protocolBinding);
 		}
 
-		if (count($this->IDPList) > 0) {
-			$scoping = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'Scoping');
-			$idplist = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'IDPList');
-			foreach ($this->IDPList as $provider) {
-				$idpEntry = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'IDPEntry');
-				$idpEntry->setAttribute('ProviderID', $provider);
-				$idplist->appendChild($idpEntry);
-			}
-			$scoping->appendChild($idplist);
-			$root->appendChild($scoping);
-		}
-
 		if (!empty($this->nameIdPolicy)) {
 			$nameIdPolicy = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'NameIDPolicy');
 			if (array_key_exists('Format', $this->nameIdPolicy)) {
@@ -297,6 +285,18 @@ class SAML2_AuthnRequest extends SAML2_Request {
 			$root->appendChild($nameIdPolicy);
 		}
 
+		if (count($this->IDPList) > 0) {
+			$scoping = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'Scoping');
+			$idplist = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'IDPList');
+			foreach ($this->IDPList as $provider) {
+				$idpEntry = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'IDPEntry');
+				$idpEntry->setAttribute('ProviderID', $provider);
+				$idplist->appendChild($idpEntry);
+			}
+			$scoping->appendChild($idplist);
+			$root->appendChild($scoping);
+		}
+
 		return $root;
 	}
 
-- 
GitLab