From 7ee4677b6e9bd8e8d878a0f1705d9eb92b71a928 Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Wed, 22 Apr 2015 14:15:26 +0200
Subject: [PATCH] Move SimpleSAML_Utilities:: redirectTrustedURL() to
 SimpleSAML\Utils\HTTP:: redirectTrustedURL() and deprecate the former.

---
 lib/SimpleSAML/Auth/Default.php               |  6 ++--
 lib/SimpleSAML/Auth/ProcessingChain.php       |  2 +-
 lib/SimpleSAML/Auth/Simple.php                |  3 +-
 lib/SimpleSAML/Auth/State.php                 |  2 +-
 lib/SimpleSAML/IdP.php                        |  2 +-
 lib/SimpleSAML/IdP/LogoutIFrame.php           |  2 +-
 lib/SimpleSAML/IdP/LogoutTraditional.php      |  2 +-
 lib/SimpleSAML/Utilities.php                  | 24 ++------------
 lib/SimpleSAML/Utils/HTTP.php                 | 33 +++++++++++++++++++
 lib/SimpleSAML/XHTML/IdPDisco.php             | 19 +++++------
 modules/adfs/lib/IdP/ADFS.php                 |  2 +-
 modules/aselect/lib/Auth/Source/aselect.php   |  2 +-
 .../authYubiKey/lib/Auth/Source/YubiKey.php   |  2 +-
 .../authfacebook/lib/Auth/Source/Facebook.php |  2 +-
 .../authorize/lib/Auth/Process/Authorize.php  |  2 +-
 .../lib/Auth/Source/LiveID.php                |  2 +-
 modules/cas/lib/Auth/Source/CAS.php           |  4 +--
 modules/casserver/www/login.php               |  4 +--
 modules/cdc/lib/Server.php                    |  4 +--
 modules/consent/lib/Auth/Process/Consent.php  |  2 +-
 modules/consent/lib/Logout.php                |  2 +-
 .../lib/Auth/Process/WarnShortSSOInterval.php |  2 +-
 modules/core/lib/Auth/UserPassBase.php        |  2 +-
 modules/core/lib/Auth/UserPassOrgBase.php     |  2 +-
 modules/core/www/as_login.php                 |  2 +-
 modules/core/www/cleardiscochoices.php        |  2 +-
 modules/discopower/lib/PowerIdPDisco.php      |  6 ++--
 .../lib/Auth/Process/RedirectTest.php         |  2 +-
 .../exampleauth/lib/Auth/Source/External.php  |  2 +-
 modules/exampleauth/www/authpage.php          |  2 +-
 .../lib/Auth/Process/ExpiryDate.php           |  6 ++--
 .../multiauth/lib/Auth/Source/MultiAuth.php   |  2 +-
 modules/oauth/lib/Consumer.php                |  2 +-
 modules/oauth/www/authorize.php               |  2 +-
 .../lib/Auth/Process/Warning.php              |  2 +-
 .../Process/ExpectedAuthnContextClassRef.php  |  2 +-
 modules/saml/lib/Auth/Source/SP.php           |  4 +--
 modules/saml/www/sp/saml2-acs.php             |  2 +-
 www/authmemcookie.php                         |  2 +-
 www/errorreport.php                           |  2 +-
 www/index.php                                 |  3 +-
 41 files changed, 92 insertions(+), 82 deletions(-)

diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php
index e3687bd95..281b83f92 100644
--- a/lib/SimpleSAML/Auth/Default.php
+++ b/lib/SimpleSAML/Auth/Default.php
@@ -128,7 +128,7 @@ class SimpleSAML_Auth_Default {
 
 		if (is_string($return)) {
 			/* Redirect... */
-			SimpleSAML_Utilities::redirectTrustedURL($return);
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($return);
 		} else {
 			call_user_func($return, $state);
 			assert('FALSE');
@@ -193,7 +193,7 @@ class SimpleSAML_Auth_Default {
 		self::initLogoutReturn($returnURL, $authority);
 
 		/* Redirect... */
-		SimpleSAML_Utilities::redirectTrustedURL($returnURL);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($returnURL);
 	}
 
 
@@ -211,7 +211,7 @@ class SimpleSAML_Auth_Default {
 		$returnURL = $state['SimpleSAML_Auth_Default.ReturnURL'];
 
 		/* Redirect... */
-		SimpleSAML_Utilities::redirectTrustedURL($returnURL);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($returnURL);
 	}
 
 
diff --git a/lib/SimpleSAML/Auth/ProcessingChain.php b/lib/SimpleSAML/Auth/ProcessingChain.php
index da75fcc3f..7f31063de 100644
--- a/lib/SimpleSAML/Auth/ProcessingChain.php
+++ b/lib/SimpleSAML/Auth/ProcessingChain.php
@@ -247,7 +247,7 @@ class SimpleSAML_Auth_ProcessingChain {
 			 * in $state['ReturnURL'].
 			 */
 			$id = SimpleSAML_Auth_State::saveState($state, self::COMPLETED_STAGE);
-			SimpleSAML_Utilities::redirectTrustedURL($state['ReturnURL'], array(self::AUTHPARAM => $id));
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($state['ReturnURL'], array(self::AUTHPARAM => $id));
 		} else {
 			/* Pass the state to the function defined in $state['ReturnCall']. */
 
diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index cc61e937b..a82419f2f 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -217,8 +217,7 @@ class SimpleSAML_Auth_Simple {
 				$stateID = SimpleSAML_Auth_State::saveState($state, $state['ReturnStateStage']);
 				$params[$state['ReturnStateParam']] = $stateID;
 			}
-
-			SimpleSAML_Utilities::redirectTrustedURL($state['ReturnTo'], $params);
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($state['ReturnTo'], $params);
 		}
 	}
 
diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php
index f1461c471..aed6b822f 100644
--- a/lib/SimpleSAML/Auth/State.php
+++ b/lib/SimpleSAML/Auth/State.php
@@ -294,7 +294,7 @@ class SimpleSAML_Auth_State {
 			$id = self::saveState($state, self::EXCEPTION_STAGE);
 
 			/* Redirect to the exception handler. */
-			SimpleSAML_Utilities::redirectTrustedURL($state[self::EXCEPTION_HANDLER_URL], array(self::EXCEPTION_PARAM => $id));
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($state[self::EXCEPTION_HANDLER_URL], array(self::EXCEPTION_PARAM => $id));
 
 		} elseif (array_key_exists(self::EXCEPTION_HANDLER_FUNC, $state)) {
 			/* Call the exception handler. */
diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php
index e5566b832..7ba6193e9 100644
--- a/lib/SimpleSAML/IdP.php
+++ b/lib/SimpleSAML/IdP.php
@@ -531,7 +531,7 @@ class SimpleSAML_IdP {
 	public static function finishLogoutRedirect(SimpleSAML_IdP $idp, array $state) {
 		assert('isset($state["core:Logout:URL"])');
 
-		SimpleSAML_Utilities::redirectTrustedURL($state['core:Logout:URL']);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($state['core:Logout:URL']);
 		assert('FALSE');
 	}
 
diff --git a/lib/SimpleSAML/IdP/LogoutIFrame.php b/lib/SimpleSAML/IdP/LogoutIFrame.php
index 44c3b3d03..e7fdc6e95 100644
--- a/lib/SimpleSAML/IdP/LogoutIFrame.php
+++ b/lib/SimpleSAML/IdP/LogoutIFrame.php
@@ -48,7 +48,7 @@ class SimpleSAML_IdP_LogoutIFrame extends SimpleSAML_IdP_LogoutHandler {
 		}
 
 		$url = SimpleSAML_Module::getModuleURL('core/idp/logout-iframe.php', $params);
-		SimpleSAML_Utilities::redirectTrustedURL($url);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url);
 	}
 
 
diff --git a/lib/SimpleSAML/IdP/LogoutTraditional.php b/lib/SimpleSAML/IdP/LogoutTraditional.php
index 4cd16dd86..7632cab05 100644
--- a/lib/SimpleSAML/IdP/LogoutTraditional.php
+++ b/lib/SimpleSAML/IdP/LogoutTraditional.php
@@ -29,7 +29,7 @@ class SimpleSAML_IdP_LogoutTraditional extends SimpleSAML_IdP_LogoutHandler {
 		try {
 			$idp = SimpleSAML_IdP::getByState($association);
 			$url = call_user_func(array($association['Handler'], 'getLogoutURL'), $idp, $association, $relayState);
-			SimpleSAML_Utilities::redirectTrustedURL($url);
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($url);
 		} catch (Exception $e) {
 			SimpleSAML_Logger::warning('Unable to initialize logout to ' . var_export($id, TRUE) . '.');
 			$this->idp->terminateAssociation($id);
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index b8717e82f..586f4cda5 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -321,30 +321,10 @@ class SimpleSAML_Utilities {
 	}
 
 	/**
-	 * This function redirects to the specified URL without performing any security checks. Please, do NOT use this
-	 * function with user supplied URLs.
-	 *
-	 * This function will use the "HTTP 303 See Other" redirection if the current request used the POST method and the
-	 * HTTP version is 1.1. Otherwise, a "HTTP 302 Found" redirection will be used.
-	 *
-	 * The function will also generate a simple web page with a clickable  link to the target URL.
-	 *
-	 * @param string $url The URL we should redirect to. This URL may include query parameters. If this URL is a
-	 * relative URL (starting with '/'), then it will be turned into an absolute URL by prefixing it with the absolute
-	 * URL to the root of the website.
-	 * @param string[] $parameters An array with extra query string parameters which should be appended to the URL. The
-	 * name of the parameter is the array index. The value of the parameter is the value stored in the index. Both the
-	 * name and the value will be urlencoded. If the value is NULL, then the parameter will be encoded as just the
-	 * name, without a value.
-	 *
-	 * @return void This function never returns.
+	 * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::redirectTrustedURL() instead.
 	 */
 	public static function redirectTrustedURL($url, $parameters = array()) {
-		assert('is_string($url)');
-		assert('is_array($parameters)');
-
-		$url = self::normalizeURL($url);
-		self::_doRedirect($url, $parameters);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, $parameters);
 	}
 
 	/**
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index bffe910a0..81e2d451a 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -682,6 +682,39 @@ class HTTP
     }
 
 
+    /**
+     * This function redirects to the specified URL without performing any security checks. Please, do NOT use this
+     * function with user supplied URLs.
+     *
+     * This function will use the "HTTP 303 See Other" redirection if the current request used the POST method and the
+     * HTTP version is 1.1. Otherwise, a "HTTP 302 Found" redirection will be used.
+     *
+     * The function will also generate a simple web page with a clickable  link to the target URL.
+     *
+     * @param string   $url The URL we should redirect to. This URL may include query parameters. If this URL is a
+     * relative URL (starting with '/'), then it will be turned into an absolute URL by prefixing it with the absolute
+     * URL to the root of the website.
+     * @param string[] $parameters An array with extra query string parameters which should be appended to the URL. The
+     * name of the parameter is the array index. The value of the parameter is the value stored in the index. Both the
+     * name and the value will be urlencoded. If the value is NULL, then the parameter will be encoded as just the
+     * name, without a value.
+     *
+     * @return void This function never returns.
+     * @throws \SimpleSAML_Error_Exception If $url is not a string or $parameters is not an array.
+     *
+     * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
+     */
+    public static function redirectTrustedURL($url, $parameters = array())
+    {
+        if (!is_string($url) || !is_array($parameters)) {
+            throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
+        }
+
+        $url = self::normalizeURL($url);
+        self::redirect($url, $parameters);
+    }
+
+
     /**
      * Resolve a (possibly) relative path from the given base path.
      *
diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php
index f64dac92b..75ae16d40 100644
--- a/lib/SimpleSAML/XHTML/IdPDisco.php
+++ b/lib/SimpleSAML/XHTML/IdPDisco.php
@@ -462,8 +462,7 @@ class SimpleSAML_XHTML_IdPDisco {
 			$extDiscoveryStorage = $this->config->getString('idpdisco.extDiscoveryStorage', NULL);
 			if ($extDiscoveryStorage !== NULL) {
 				$this->log('Choice made [' . $idp . '] (Forwarding to external discovery storage)');
-				SimpleSAML_Utilities::redirectTrustedURL($extDiscoveryStorage, array(
-//					$this->returnIdParam => $idp,
+				\SimpleSAML\Utils\HTTP::redirectTrustedURL($extDiscoveryStorage, array(
 					'entityID' => $this->spEntityId,
 					'IdPentityID' => $idp,
 					'returnIDParam' => $this->returnIdParam,
@@ -473,7 +472,7 @@ class SimpleSAML_XHTML_IdPDisco {
 				
 			} else {
 				$this->log('Choice made [' . $idp . '] (Redirecting the user back. returnIDParam=' . $this->returnIdParam . ')');
-				SimpleSAML_Utilities::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idp));
+				\SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idp));
 			}
 			
 			return;
@@ -481,7 +480,7 @@ class SimpleSAML_XHTML_IdPDisco {
 		
 		if ($this->isPassive) {
 			$this->log('Choice not made. (Redirecting the user back without answer)');
-			SimpleSAML_Utilities::redirectTrustedURL($this->returnURL);
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL);
 			return;
 		}
 
@@ -495,12 +494,12 @@ class SimpleSAML_XHTML_IdPDisco {
 			$idpList = array_intersect_key($idpList, array_fill_keys($idpintersection, NULL));
 		}
 
-        $idpintersection = array_values($idpintersection); 
-        
-        if(sizeof($idpintersection)  == 1) {
-            $this->log('Choice made [' . $idpintersection[0] . '] (Redirecting the user back. returnIDParam=' . $this->returnIdParam . ')');
-            SimpleSAML_Utilities::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idpintersection[0]));
-        }
+		$idpintersection = array_values($idpintersection);
+
+		if(sizeof($idpintersection)  == 1) {
+			$this->log('Choice made [' . $idpintersection[0] . '] (Redirecting the user back. returnIDParam=' . $this->returnIdParam . ')');
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idpintersection[0]));
+		}
 
 		/*
 		 * Make use of an XHTML template to present the select IdP choice to the user.
diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php
index 610f84baf..62fd9200a 100644
--- a/modules/adfs/lib/IdP/ADFS.php
+++ b/modules/adfs/lib/IdP/ADFS.php
@@ -168,7 +168,7 @@ class sspmod_adfs_IdP_ADFS {
 		// NB:: we don't know from which SP the logout request came from
 		$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 		$idpMetadata = $idp->getConfig();
-		SimpleSAML_Utilities::redirectTrustedURL($idpMetadata->getValue('redirect-after-logout', \SimpleSAML\Utils\HTTP::getBaseURL()));
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($idpMetadata->getValue('redirect-after-logout', \SimpleSAML\Utils\HTTP::getBaseURL()));
 	}
 	
 	public static function receiveLogoutMessage(SimpleSAML_IdP $idp) {
diff --git a/modules/aselect/lib/Auth/Source/aselect.php b/modules/aselect/lib/Auth/Source/aselect.php
index fca989693..f4fd0f601 100644
--- a/modules/aselect/lib/Auth/Source/aselect.php
+++ b/modules/aselect/lib/Auth/Source/aselect.php
@@ -52,7 +52,7 @@ class sspmod_aselect_Auth_Source_aselect extends SimpleSAML_Auth_Source {
 			$app_url = SimpleSAML_Module::getModuleURL('aselect/credentials.php', array('ssp_state' => $id));
 			$as_url = $this->request_authentication($app_url);
 
-			SimpleSAML_Utilities::redirectTrustedURL($as_url);
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($as_url);
 		} catch(Exception $e) {
 			// attach the exception to the state
 			SimpleSAML_Auth_State::throwException($state, $e);
diff --git a/modules/authYubiKey/lib/Auth/Source/YubiKey.php b/modules/authYubiKey/lib/Auth/Source/YubiKey.php
index 48c3047ac..865ceef84 100644
--- a/modules/authYubiKey/lib/Auth/Source/YubiKey.php
+++ b/modules/authYubiKey/lib/Auth/Source/YubiKey.php
@@ -103,7 +103,7 @@ class sspmod_authYubiKey_Auth_Source_YubiKey extends SimpleSAML_Auth_Source {
 		$id = SimpleSAML_Auth_State::saveState($state, self::STAGEID);
 
 		$url = SimpleSAML_Module::getModuleURL('authYubiKey/yubikeylogin.php');
-		SimpleSAML_Utilities::redirectTrustedURL($url, array('AuthState' => $id));
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('AuthState' => $id));
 	}
 	
 	
diff --git a/modules/authfacebook/lib/Auth/Source/Facebook.php b/modules/authfacebook/lib/Auth/Source/Facebook.php
index 7e6b9525e..c211ebc72 100644
--- a/modules/authfacebook/lib/Auth/Source/Facebook.php
+++ b/modules/authfacebook/lib/Auth/Source/Facebook.php
@@ -79,7 +79,7 @@ class sspmod_authfacebook_Auth_Source_Facebook extends SimpleSAML_Auth_Source {
 		$url = $facebook->getLoginUrl(array('redirect_uri' => $linkback, 'scope' => $this->req_perms));
 		SimpleSAML_Auth_State::saveState($state, self::STAGE_INIT);
 
-		SimpleSAML_Utilities::redirectTrustedURL($url);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url);
 	}
 		
 
diff --git a/modules/authorize/lib/Auth/Process/Authorize.php b/modules/authorize/lib/Auth/Process/Authorize.php
index 2fe62922c..d57f21c56 100644
--- a/modules/authorize/lib/Auth/Process/Authorize.php
+++ b/modules/authorize/lib/Auth/Process/Authorize.php
@@ -128,6 +128,6 @@ class sspmod_authorize_Auth_Process_Authorize extends SimpleSAML_Auth_Processing
 			'authorize:Authorize');
 		$url = SimpleSAML_Module::getModuleURL(
 			'authorize/authorize_403.php');
-		SimpleSAML_Utilities::redirectTrustedURL($url, array('StateId' => $id));
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
 	}
 }
diff --git a/modules/authwindowslive/lib/Auth/Source/LiveID.php b/modules/authwindowslive/lib/Auth/Source/LiveID.php
index 47b41ba19..27886940c 100644
--- a/modules/authwindowslive/lib/Auth/Source/LiveID.php
+++ b/modules/authwindowslive/lib/Auth/Source/LiveID.php
@@ -71,7 +71,7 @@ class sspmod_authwindowslive_Auth_Source_LiveID extends SimpleSAML_Auth_Source {
 				. '&wrap_scope=WL_Profiles.View,Messenger.SignIn'
 		;
 
-                SimpleSAML_Utilities::redirectTrustedURL($authorizeURL);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($authorizeURL);
 	}
 
 
diff --git a/modules/cas/lib/Auth/Source/CAS.php b/modules/cas/lib/Auth/Source/CAS.php
index 073eba615..301cb76ac 100644
--- a/modules/cas/lib/Auth/Source/CAS.php
+++ b/modules/cas/lib/Auth/Source/CAS.php
@@ -205,7 +205,7 @@ class sspmod_cas_Auth_Source_CAS  extends SimpleSAML_Auth_Source  {
 
 		$serviceUrl = SimpleSAML_Module::getModuleURL('cas/linkback.php', array('stateID' => $stateID));
 
-		SimpleSAML_Utilities::redirectTrustedURL($this->_loginMethod, array(
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($this->_loginMethod, array(
 			'service' => $serviceUrl));
 	}
 
@@ -229,7 +229,7 @@ class sspmod_cas_Auth_Source_CAS  extends SimpleSAML_Auth_Source  {
 
 		SimpleSAML_Auth_State::deleteState($state);
 		// we want cas to log us out
-		SimpleSAML_Utilities::redirectTrustedURL($logoutUrl);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($logoutUrl);
 	}
 
 }
diff --git a/modules/casserver/www/login.php b/modules/casserver/www/login.php
index f660a98c9..008018b92 100644
--- a/modules/casserver/www/login.php
+++ b/modules/casserver/www/login.php
@@ -48,8 +48,8 @@ storeTicket($ticket, $path, array('service' => $service,
 	'proxies' => array(),
 	'validbefore' => time() + 5));
 
-SimpleSAML_Utilities::redirectTrustedURL(
-    \SimpleSAML\Utils\HTTP::addURLParameters($service,
+\SimpleSAML\Utils\HTTP::redirectTrustedURL(
+	\SimpleSAML\Utils\HTTP::addURLParameters($service,
 		array('ticket' => $ticket)
 	)
 );
\ No newline at end of file
diff --git a/modules/cdc/lib/Server.php b/modules/cdc/lib/Server.php
index 890e4376e..b27f50ed2 100644
--- a/modules/cdc/lib/Server.php
+++ b/modules/cdc/lib/Server.php
@@ -326,9 +326,9 @@ class sspmod_cdc_Server {
 
 		$url = \SimpleSAML\Utils\HTTP::addURLParameters($to, $params);
 		if (strlen($url) < 2048) {
-			SimpleSAML_Utilities::redirectTrustedURL($url);
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($url);
 		} else {
-            \SimpleSAML\Utils\HTTP::submitPOSTData($to, $params);
+			\SimpleSAML\Utils\HTTP::submitPOSTData($to, $params);
 		}
 	}
 
diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php
index 051459aed..bbd585d7c 100644
--- a/modules/consent/lib/Auth/Process/Consent.php
+++ b/modules/consent/lib/Auth/Process/Consent.php
@@ -277,7 +277,7 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt
         // Save state and redirect
         $id  = SimpleSAML_Auth_State::saveState($state, 'consent:request');
         $url = SimpleSAML_Module::getModuleURL('consent/getconsent.php');
-        SimpleSAML_Utilities::redirectTrustedURL($url, array('StateId' => $id));
+        \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
     }
 
     /**
diff --git a/modules/consent/lib/Logout.php b/modules/consent/lib/Logout.php
index 89fc8d4c7..a927eac42 100644
--- a/modules/consent/lib/Logout.php
+++ b/modules/consent/lib/Logout.php
@@ -9,7 +9,7 @@ class sspmod_consent_Logout {
 
 	public static function postLogout(SimpleSAML_IdP $idp, array $state) {
 		$url = SimpleSAML_Module::getModuleURL('consent/logout_completed.php');
-		SimpleSAML_Utilities::redirectTrustedURL($url);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url);
 	}
 
 }
diff --git a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php
index 1a731e3e6..e28bfd4de 100644
--- a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php
+++ b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php
@@ -46,7 +46,7 @@ class sspmod_core_Auth_Process_WarnShortSSOInterval extends SimpleSAML_Auth_Proc
 		/* Save state and redirect. */
 		$id = SimpleSAML_Auth_State::saveState($state, 'core:short_sso_interval');
 		$url = SimpleSAML_Module::getModuleURL('core/short_sso_interval.php');
-		SimpleSAML_Utilities::redirectTrustedURL($url, array('StateId' => $id));
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
 	}
 
 }
diff --git a/modules/core/lib/Auth/UserPassBase.php b/modules/core/lib/Auth/UserPassBase.php
index a97fba73a..7c6b5dd09 100644
--- a/modules/core/lib/Auth/UserPassBase.php
+++ b/modules/core/lib/Auth/UserPassBase.php
@@ -194,7 +194,7 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source {
 		 */
 		$url = SimpleSAML_Module::getModuleURL('core/loginuserpass.php');
 		$params = array('AuthState' => $id);
-		SimpleSAML_Utilities::redirectTrustedURL($url, $params);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, $params);
 
 		/* The previous function never returns, so this code is never executed. */
 		assert('FALSE');
diff --git a/modules/core/lib/Auth/UserPassOrgBase.php b/modules/core/lib/Auth/UserPassOrgBase.php
index 7bbddf24f..5058537f0 100644
--- a/modules/core/lib/Auth/UserPassOrgBase.php
+++ b/modules/core/lib/Auth/UserPassOrgBase.php
@@ -156,7 +156,7 @@ abstract class sspmod_core_Auth_UserPassOrgBase extends SimpleSAML_Auth_Source {
 
 		$url = SimpleSAML_Module::getModuleURL('core/loginuserpassorg.php');
 		$params = array('AuthState' => $id);
-		SimpleSAML_Utilities::redirectTrustedURL($url, $params);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, $params);
 	}
 
 
diff --git a/modules/core/www/as_login.php b/modules/core/www/as_login.php
index 27c16fa63..c4c7b7e7c 100644
--- a/modules/core/www/as_login.php
+++ b/modules/core/www/as_login.php
@@ -32,4 +32,4 @@ if (!empty($_REQUEST['saml:idp'])) {
 $as = new SimpleSAML_Auth_Simple($_REQUEST['AuthId']);
 $as->requireAuth($options);
 
-SimpleSAML_Utilities::redirectTrustedURL($options['ReturnTo']);
+\SimpleSAML\Utils\HTTP::redirectTrustedURL($options['ReturnTo']);
diff --git a/modules/core/www/cleardiscochoices.php b/modules/core/www/cleardiscochoices.php
index 6a1b07291..fe0901bfe 100644
--- a/modules/core/www/cleardiscochoices.php
+++ b/modules/core/www/cleardiscochoices.php
@@ -33,5 +33,5 @@ if(array_key_exists('ReturnTo', $_REQUEST)) {
 }
 
 /* Redirect to destination. */
-SimpleSAML_Utilities::redirectTrustedURL($returnTo);
+\SimpleSAML\Utils\HTTP::redirectTrustedURL($returnTo);
 
diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php
index cf673c4c9..44f481352 100644
--- a/modules/discopower/lib/PowerIdPDisco.php
+++ b/modules/discopower/lib/PowerIdPDisco.php
@@ -191,7 +191,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco {
 			$extDiscoveryStorage = $this->config->getString('idpdisco.extDiscoveryStorage',NULL);
 			if ($extDiscoveryStorage !== NULL) {
 				$this->log('Choice made [' . $idp . '] (Forwarding to external discovery storage)');
-				SimpleSAML_Utilities::redirectTrustedURL($extDiscoveryStorage, array(
+				\SimpleSAML\Utils\HTTP::redirectTrustedURL($extDiscoveryStorage, array(
 					'entityID' => $this->spEntityId,
 					'IdPentityID' => $idp,
 					'returnIDParam' => $this->returnIdParam,
@@ -201,7 +201,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco {
 				
 			} else {
 				$this->log('Choice made [' . $idp . '] (Redirecting the user back. returnIDParam=' . $this->returnIdParam . ')');
-				SimpleSAML_Utilities::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idp));
+				\SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idp));
 			}
 			
 			return;
@@ -209,7 +209,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco {
 		
 		if ($this->isPassive) {
 			$this->log('Choice not made. (Redirecting the user back without answer)');
-			SimpleSAML_Utilities::redirectTrustedURL($this->returnURL);
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL);
 			return;
 		}
 
diff --git a/modules/exampleauth/lib/Auth/Process/RedirectTest.php b/modules/exampleauth/lib/Auth/Process/RedirectTest.php
index 79e5293e0..28751cd20 100644
--- a/modules/exampleauth/lib/Auth/Process/RedirectTest.php
+++ b/modules/exampleauth/lib/Auth/Process/RedirectTest.php
@@ -22,7 +22,7 @@ class sspmod_exampleauth_Auth_Process_RedirectTest extends SimpleSAML_Auth_Proce
 		/* Save state and redirect. */
 		$id = SimpleSAML_Auth_State::saveState($state, 'exampleauth:redirectfilter-test');
 		$url = SimpleSAML_Module::getModuleURL('exampleauth/redirecttest.php');
-		SimpleSAML_Utilities::redirectTrustedURL($url, array('StateId' => $id));
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
 	}
 
 }
diff --git a/modules/exampleauth/lib/Auth/Source/External.php b/modules/exampleauth/lib/Auth/Source/External.php
index 37038527b..22cc4e2d6 100644
--- a/modules/exampleauth/lib/Auth/Source/External.php
+++ b/modules/exampleauth/lib/Auth/Source/External.php
@@ -155,7 +155,7 @@ class sspmod_exampleauth_Auth_Source_External extends SimpleSAML_Auth_Source {
 		 * Note the 'ReturnTo' parameter. This must most likely be replaced with
 		 * the real name of the parameter for the login page.
 		 */
-		SimpleSAML_Utilities::redirectTrustedURL($authPage, array(
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($authPage, array(
 			'ReturnTo' => $returnTo,
 		));
 
diff --git a/modules/exampleauth/www/authpage.php b/modules/exampleauth/www/authpage.php
index 7b3dca267..cf4c96cba 100644
--- a/modules/exampleauth/www/authpage.php
+++ b/modules/exampleauth/www/authpage.php
@@ -85,7 +85,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
 		$_SESSION['mail'] = $user['mail'];
 		$_SESSION['type'] = $user['type'];
 
-		SimpleSAML_Utilities::redirectTrustedURL($returnTo);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($returnTo);
 	}
 }
 
diff --git a/modules/expirycheck/lib/Auth/Process/ExpiryDate.php b/modules/expirycheck/lib/Auth/Process/ExpiryDate.php
index 1436f169e..9d04d763b 100644
--- a/modules/expirycheck/lib/Auth/Process/ExpiryDate.php
+++ b/modules/expirycheck/lib/Auth/Process/ExpiryDate.php
@@ -134,12 +134,12 @@ class sspmod_expirycheck_Auth_Process_ExpiryDate extends SimpleSAML_Auth_Process
 			$state['netId'] = $netId;
 			$id = SimpleSAML_Auth_State::saveState($state, 'expirywarning:about2expire');
 			$url = SimpleSAML_Module::getModuleURL('expirycheck/about2expire.php');
-			SimpleSAML_Utilities::redirectTrustedURL($url, array('StateId' => $id));
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
 		}
 
 		if (!self::checkDate($expireOnDate)) {
 			SimpleSAML_Logger::error('expirycheck: NetID ' . $netId .
-			                         ' has expired [' . date($this->date_format, $expireOnDate) . ']. Access denied!');
+				' has expired [' . date($this->date_format, $expireOnDate) . ']. Access denied!');
 			$globalConfig = SimpleSAML_Configuration::getInstance();
 
 			/* Save state and redirect. */
@@ -147,7 +147,7 @@ class sspmod_expirycheck_Auth_Process_ExpiryDate extends SimpleSAML_Auth_Process
 			$state['netId'] = $netId;
 			$id = SimpleSAML_Auth_State::saveState($state, 'expirywarning:expired');
 			$url = SimpleSAML_Module::getModuleURL('expirycheck/expired.php');
-			SimpleSAML_Utilities::redirectTrustedURL($url, array('StateId' => $id));
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
 
 		}
 	}
diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php
index 3e5b853a7..0235cdade 100644
--- a/modules/multiauth/lib/Auth/Source/MultiAuth.php
+++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php
@@ -120,7 +120,7 @@ class sspmod_multiauth_Auth_Source_MultiAuth extends SimpleSAML_Auth_Source {
 			$params['source'] = $_GET['source'];
 		}
 
-		SimpleSAML_Utilities::redirectTrustedURL($url, $params);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, $params);
 
 		/* The previous function never returns, so this code is never
 		executed */
diff --git a/modules/oauth/lib/Consumer.php b/modules/oauth/lib/Consumer.php
index 265b1cab9..f17640cec 100644
--- a/modules/oauth/lib/Consumer.php
+++ b/modules/oauth/lib/Consumer.php
@@ -93,7 +93,7 @@ class sspmod_oauth_Consumer {
 		}
 		$authorizeURL = \SimpleSAML\Utils\HTTP::addURLParameters($url, $params);
 		if ($redirect) {
-			SimpleSAML_Utilities::redirectTrustedURL($authorizeURL);
+			\SimpleSAML\Utils\HTTP::redirectTrustedURL($authorizeURL);
 			exit;
 		}	
 		return $authorizeURL;
diff --git a/modules/oauth/www/authorize.php b/modules/oauth/www/authorize.php
index 9ff13dc3d..d3ef8fabd 100644
--- a/modules/oauth/www/authorize.php
+++ b/modules/oauth/www/authorize.php
@@ -56,7 +56,7 @@ try {
 
 	if ($url) {
 		// If authorize() returns a URL, take user there (oauth1.0a)
-		SimpleSAML_Utilities::redirectTrustedURL($url);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url);
 	} 
 	else if (isset($_REQUEST['oauth_callback'])) {
 		// If callback was provided in the request (oauth1.0)
diff --git a/modules/preprodwarning/lib/Auth/Process/Warning.php b/modules/preprodwarning/lib/Auth/Process/Warning.php
index 1c734091e..acb740c2b 100644
--- a/modules/preprodwarning/lib/Auth/Process/Warning.php
+++ b/modules/preprodwarning/lib/Auth/Process/Warning.php
@@ -28,7 +28,7 @@ class sspmod_preprodwarning_Auth_Process_Warning extends SimpleSAML_Auth_Process
 		/* Save state and redirect. */
 		$id = SimpleSAML_Auth_State::saveState($state, 'warning:request');
 		$url = SimpleSAML_Module::getModuleURL('preprodwarning/showwarning.php');
-		SimpleSAML_Utilities::redirectTrustedURL($url, array('StateId' => $id));
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
 	}
 	
 
diff --git a/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php b/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php
index 13daccd8f..c012a85e1 100644
--- a/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php
+++ b/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php
@@ -79,6 +79,6 @@ class sspmod_saml_Auth_Process_ExpectedAuthnContextClassRef extends SimpleSAML_A
 		$id = SimpleSAML_Auth_State::saveState($request, 'saml:ExpectedAuthnContextClassRef:unauthorized');
 		$url = SimpleSAML_Module::getModuleURL(
 			'saml/sp/wrong_authncontextclassref.php');
-		SimpleSAML_Utilities::redirectTrustedURL($url, array('StateId' => $id));
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
 	}
 }
diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php
index 0823d5bbe..e5140681e 100644
--- a/modules/saml/lib/Auth/Source/SP.php
+++ b/modules/saml/lib/Auth/Source/SP.php
@@ -168,7 +168,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 
 		SimpleSAML_Logger::debug('Starting SAML 1 SSO to ' . var_export($idpEntityId, TRUE) .
 			' from ' . var_export($this->entityId, TRUE) . '.');
-		SimpleSAML_Utilities::redirectTrustedURL($url);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($url);
 	}
 
 
@@ -355,7 +355,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 			$params['isPassive'] = 'true';
 		}
 
-		SimpleSAML_Utilities::redirectTrustedURL($discoURL, $params);
+		\SimpleSAML\Utils\HTTP::redirectTrustedURL($discoURL, $params);
 	}
 
 
diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php
index 21bdce256..7ab671ed9 100644
--- a/modules/saml/www/sp/saml2-acs.php
+++ b/modules/saml/www/sp/saml2-acs.php
@@ -60,7 +60,7 @@ if ($prevAuth !== NULL && $prevAuth['id'] === $response->getId() && $prevAuth['i
 	 * instead of displaying a confusing error message.
 	 */
 	SimpleSAML_Logger::info('Duplicate SAML 2 response detected - ignoring the response and redirecting the user to the correct page.');
-	SimpleSAML_Utilities::redirectTrustedURL($prevAuth['redirect']);
+	\SimpleSAML\Utils\HTTP::redirectTrustedURL($prevAuth['redirect']);
 }
 
 $idpMetadata = array();
diff --git a/www/authmemcookie.php b/www/authmemcookie.php
index 96e318ca4..b6a1f92b2 100644
--- a/www/authmemcookie.php
+++ b/www/authmemcookie.php
@@ -93,7 +93,7 @@ try {
 	$session->registerLogoutHandler($sourceId, 'SimpleSAML_AuthMemCookie', 'logoutHandler');
 
 	/* Redirect the user back to this page to signal that the login is completed. */
-	SimpleSAML_Utilities::redirectTrustedURL(\SimpleSAML\Utils\HTTP::getSelfURL());
+	\SimpleSAML\Utils\HTTP::redirectTrustedURL(\SimpleSAML\Utils\HTTP::getSelfURL());
 } catch(Exception $e) {
 	throw new SimpleSAML_Error_Error('CONFIG', $e);
 }
diff --git a/www/errorreport.php b/www/errorreport.php
index 3e92b1804..042f9a613 100644
--- a/www/errorreport.php
+++ b/www/errorreport.php
@@ -99,4 +99,4 @@ if ($config->getBoolean('errorreporting', TRUE) && $toAddress !== 'na@example.or
 }
 
 /* Redirect the user back to this page to clear the POST request. */
-SimpleSAML_Utilities::redirectTrustedURL(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery());
+\SimpleSAML\Utils\HTTP::redirectTrustedURL(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery());
diff --git a/www/index.php b/www/index.php
index 4ca3a3baa..5d3134049 100644
--- a/www/index.php
+++ b/www/index.php
@@ -2,5 +2,4 @@
 
 require_once('_include.php');
 
-
-SimpleSAML_Utilities::redirectTrustedURL(SimpleSAML_Module::getModuleURL('core/frontpage_welcome.php'));
+\SimpleSAML\Utils\HTTP::redirectTrustedURL(SimpleSAML_Module::getModuleURL('core/frontpage_welcome.php'));
-- 
GitLab