From 086881f74d97ff93bccf14cf039e55d640c3caf1 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Wed, 30 May 2018 14:46:11 +0200
Subject: [PATCH] Replace SimpleSAML_XHTML_* with namespaced version

---
 docs/simplesamlphp-modules.md                 |  4 +--
 lib/SimpleSAML/Error/Error.php                |  2 +-
 lib/SimpleSAML/Utils/HTTP.php                 |  3 +-
 lib/SimpleSAML/XHTML/EMail.php                | 15 +++++----
 lib/SimpleSAML/XHTML/IdPDisco.php             |  7 ++--
 lib/SimpleSAML/XHTML/Template.php             | 33 ++++++++++---------
 modules/adfs/www/idp/metadata.php             |  2 +-
 .../authX509/lib/Auth/Source/X509userCert.php |  6 ++--
 modules/authX509/www/expirywarning.php        | 14 ++++----
 modules/authYubiKey/www/yubikeylogin.php      | 12 +++----
 modules/authorize/www/authorize_403.php       |  8 ++---
 modules/consent/templates/consentform.php     |  6 ++--
 modules/consent/www/getconsent.php            | 12 +++----
 modules/consent/www/logout.php                |  6 ++--
 modules/consent/www/logout_completed.php      |  2 +-
 modules/consent/www/noconsent.php             | 14 ++++----
 modules/consentAdmin/www/consentAdmin.php     |  6 ++--
 modules/core/www/as_login.php                 |  4 +--
 modules/core/www/as_logout.php                |  4 +--
 modules/core/www/authenticate.php             | 16 ++++-----
 modules/core/www/cardinality_error.php        |  2 +-
 modules/core/www/cleardiscochoices.php        |  1 -
 modules/core/www/frontpage_auth.php           | 12 +++----
 modules/core/www/frontpage_config.php         | 14 ++++----
 modules/core/www/frontpage_federation.php     | 24 +++++++-------
 modules/core/www/frontpage_welcome.php        |  8 ++---
 modules/core/www/idp/logout-iframe.php        | 20 +++++------
 modules/core/www/login-admin.php              |  4 +--
 modules/core/www/loginuserpass.php            |  2 +-
 modules/core/www/loginuserpassorg.php         | 14 ++++----
 modules/core/www/no_cookie.php                |  2 +-
 modules/core/www/postredirect.php             | 10 +++---
 modules/core/www/short_sso_interval.php       | 10 +++---
 modules/core/www/show_metadata.php            |  8 ++---
 modules/cron/www/cron.php                     | 13 +++-----
 modules/cron/www/croninfo.php                 | 12 +++----
 modules/discopower/lib/PowerIdPDisco.php      |  8 ++---
 modules/expirycheck/www/about2expire.php      | 12 +++----
 modules/expirycheck/www/expired.php           |  8 ++---
 modules/memcacheMonitor/www/memcachestat.php  | 12 ++-----
 modules/metarefresh/www/fetch.php             | 18 ++++------
 modules/multiauth/www/selectsource.php        | 14 ++++----
 modules/negotiate/www/disable.php             |  4 +--
 modules/negotiate/www/enable.php              |  4 +--
 modules/oauth/www/registry.edit.php           | 18 +++++-----
 modules/oauth/www/registry.php                |  6 ++--
 modules/preprodwarning/www/showwarning.php    | 12 +++----
 .../saml/templates/proxy/invalid_session.php  |  2 +-
 modules/saml/www/disco.php                    |  2 +-
 modules/saml/www/proxy/invalid_session.php    | 20 +++++------
 modules/saml/www/sp/metadata.php              | 30 ++++++++---------
 .../www/sp/wrong_authncontextclassref.php     |  2 +-
 modules/sanitycheck/www/index.php             |  4 +--
 modules/statistics/lib/StatDataset.php        | 19 ++++++-----
 modules/statistics/www/showstats.php          | 14 ++++----
 modules/statistics/www/statmeta.php           |  4 +--
 templates/includes/attributes.php             |  6 ++--
 www/admin/hostnames.php                       |  4 +--
 www/admin/index.php                           |  4 +--
 www/admin/metadata-converter.php              |  8 ++---
 www/admin/sandbox.php                         |  2 +-
 www/errorreport.php                           |  8 ++---
 www/logout.php                                |  2 +-
 www/saml2/idp/metadata.php                    | 12 +++----
 www/shib13/idp/metadata.php                   | 22 ++++++-------
 65 files changed, 299 insertions(+), 314 deletions(-)

diff --git a/docs/simplesamlphp-modules.md b/docs/simplesamlphp-modules.md
index ccbb851c8..92482287a 100644
--- a/docs/simplesamlphp-modules.md
+++ b/docs/simplesamlphp-modules.md
@@ -66,7 +66,7 @@ dictionaries
 
 :   It is also possible to specify
     `<module name>:<dictionary name>` as the default
-    dictionary when instantiating the `SimpleSAML_XHTML_Template`
+    dictionary when instantiating the `\SimpleSAML\XHTML\Template`
     class.
 
 hooks
@@ -90,7 +90,7 @@ templates
 :   These are module-specific templates. To use one of these
     templates, specify `<module name>:<template file>.php`
     as the template file in the constructor of
-    `SimpleSAML_XHTML_Template`. For example, `example:login-form.php`
+    `\SimpleSAML\XHTML\Template`. For example, `example:login-form.php`
     is translated to the file
     `modules/example/templates/default/login-form.php`. Note that
     `default` in the previous example is defined by the `theme.use`
diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index aceac89f9..f02b4be1c 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -284,7 +284,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception
             call_user_func($show_function, $config, $data);
             assert(false);
         } else {
-            $t = new SimpleSAML_XHTML_Template($config, 'error.php', 'errors');
+            $t = new \SimpleSAML\XHTML\Template($config, 'error.php', 'errors');
             $t->data = array_merge($t->data, $data);
             $t->data['dictTitleTranslated'] = $t->getTranslator()->t($t->data['dictTitle']);
             $t->data['dictDescrTranslated'] = $t->getTranslator()->t($t->data['dictDescr'], $t->data['parameters']);
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index a6641ac6b..c1bb1bbdf 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -13,7 +13,6 @@ use SimpleSAML\Session;
  */
 class HTTP
 {
-
     /**
      * Obtain a URL where we can redirect to securely post a form with the given data to a specific destination.
      *
@@ -1215,7 +1214,7 @@ class HTTP
             self::redirect(self::getSecurePOSTRedirectURL($destination, $data));
         }
 
-        $p = new \SimpleSAML_XHTML_Template($config, 'post.php');
+        $p = new \SimpleSAML\XHTML\Template($config, 'post.php');
         $p->data['destination'] = $destination;
         $p->data['post'] = $data;
         $p->show();
diff --git a/lib/SimpleSAML/XHTML/EMail.php b/lib/SimpleSAML/XHTML/EMail.php
index 5796ec1c0..c09b17e2f 100644
--- a/lib/SimpleSAML/XHTML/EMail.php
+++ b/lib/SimpleSAML/XHTML/EMail.php
@@ -1,12 +1,15 @@
 <?php
 
+namespace SimpleSAML\XHTML;
+
 /**
  * A minimalistic Emailer class. Creates and sends HTML emails.
  *
  * @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
  * @package SimpleSAMLphp
  */
-class SimpleSAML_XHTML_EMail
+
+class EMail
 {
     private $to = null;
     private $cc = null;
@@ -78,11 +81,11 @@ pre {
     public function send()
     {
         if ($this->to === null) {
-            throw new Exception('EMail field [to] is required and not set.');
+            throw new \Exception('EMail field [to] is required and not set.');
         } elseif ($this->subject === null) {
-            throw new Exception('EMail field [subject] is required and not set.');
+            throw new \Exception('EMail field [subject] is required and not set.');
         } elseif ($this->body === null) {
-            throw new Exception('EMail field [body] is required and not set.');
+            throw new \Exception('EMail field [body] is required and not set.');
         }
 
         $random_hash = bin2hex(openssl_random_pseudo_bytes(16));
@@ -114,9 +117,9 @@ Content-Transfer-Encoding: 8bit
         $headers = implode("\n", $this->headers);
 
         $mail_sent = @mail($this->to, $this->subject, $message, $headers);
-        SimpleSAML\Logger::debug('Email: Sending e-mail to [' . $this->to . '] : ' . ($mail_sent ? 'OK' : 'Failed'));
+        \SimpleSAML\Logger::debug('Email: Sending e-mail to [' . $this->to . '] : ' . ($mail_sent ? 'OK' : 'Failed'));
         if (!$mail_sent) {
-            throw new Exception('Error when sending e-mail');
+            throw new \Exception('Error when sending e-mail');
         }
     }
 }
diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php
index 57a95b99b..e362ff711 100644
--- a/lib/SimpleSAML/XHTML/IdPDisco.php
+++ b/lib/SimpleSAML/XHTML/IdPDisco.php
@@ -1,5 +1,6 @@
 <?php
 
+namespace SimpleSAML\XHTML;
 
 /**
  * This class implements a generic IdP discovery service, for use in various IdP
@@ -13,9 +14,9 @@
  * @author Andreas Ă…kre Solberg <andreas@uninett.no>, UNINETT AS.
  * @package SimpleSAMLphp
  */
-class SimpleSAML_XHTML_IdPDisco
-{
 
+class IdPDisco
+{
     /**
      * An instance of the configuration class.
      *
@@ -585,7 +586,7 @@ class SimpleSAML_XHTML_IdPDisco
                 throw new Exception('Invalid value for the \'idpdisco.layout\' option.');
         }
 
-        $t = new SimpleSAML_XHTML_Template($this->config, $templateFile, 'disco');
+        $t = new Template($this->config, $templateFile, 'disco');
         $t->data['idplist'] = $idpList;
         $t->data['preferredidp'] = $preferredIdP;
         $t->data['return'] = $this->returnURL;
diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index beadfa6ca..5d29eaf2d 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -1,5 +1,6 @@
 <?php
 
+namespace SimpleSAML\XHTML;
 
 /**
  * A minimalistic XHTML PHP based template system implemented for SimpleSAMLphp.
@@ -11,7 +12,7 @@
 use JaimePerez\TwigConfigurableI18n\Twig\Environment as Twig_Environment;
 use JaimePerez\TwigConfigurableI18n\Twig\Extensions\Extension\I18n as Twig_Extensions_Extension_I18n;
 
-class SimpleSAML_XHTML_Template
+class Template
 {
     /**
      * The data associated with this template, accessible within the template itself.
@@ -72,9 +73,9 @@ class SimpleSAML_XHTML_Template
      *
      * Used to intercept certain parts of the template handling, while keeping away unwanted/unexpected hooks. Set
      * the 'theme.controller' configuration option to a class that implements the
-     * SimpleSAML\XHTML\TemplateControllerInterface interface to use it.
+     * \SimpleSAML\XHTML\TemplateControllerInterface interface to use it.
      *
-     * @var SimpleSAML\XHTML\TemplateControllerInterface
+     * @var \SimpleSAML\XHTML\TemplateControllerInterface
      */
     private $controller;
 
@@ -113,7 +114,7 @@ class SimpleSAML_XHTML_Template
         );
 
         // initialize internationalization system
-        $this->translator = new SimpleSAML\Locale\Translate($configuration, $defaultDictionary);
+        $this->translator = new \SimpleSAML\Locale\Translate($configuration, $defaultDictionary);
         $this->localization = new \SimpleSAML\Locale\Localization($configuration);
 
         // check if we need to attach a theme controller
@@ -154,8 +155,8 @@ class SimpleSAML_XHTML_Template
     /**
      * Set up the places where twig can look for templates.
      *
-     * @return Twig_Loader_Filesystem The twig template loader or false if the template does not exist.
-     * @throws Twig_Error_Loader In case a failure occurs.
+     * @return \Twig_Loader_Filesystem The twig template loader or false if the template does not exist.
+     * @throws \Twig_Error_Loader In case a failure occurs.
      */
     private function setupTwigTemplatepaths()
     {
@@ -226,8 +227,8 @@ class SimpleSAML_XHTML_Template
             );
         } // TODO: add a branch for the old SimpleSAMLphp backend
 
-        $twig = new Twig_Environment($loader, $options);
-        $twig->addExtension(new Twig_Extensions_Extension_I18n());
+        $twig = new \Twig_Environment($loader, $options);
+        $twig->addExtension(new \Twig_Extensions_Extension_I18n());
 
         // initialize some basic context
         $langParam = $this->configuration->getString('language.parameter.name', 'language');
@@ -301,18 +302,18 @@ class SimpleSAML_XHTML_Template
      *
      * @return string The templates directory of a module.
      *
-     * @throws InvalidArgumentException If the module is not enabled or it has no templates directory.
+     * @throws \InvalidArgumentException If the module is not enabled or it has no templates directory.
      */
     private function getModuleTemplateDir($module)
     {
         if (!\SimpleSAML\Module::isModuleEnabled($module)) {
-            throw new InvalidArgumentException('The module \''.$module.'\' is not enabled.');
+            throw new \InvalidArgumentException('The module \''.$module.'\' is not enabled.');
         }
         $moduledir = \SimpleSAML\Module::getModuleDir($module);
         // check if module has a /templates dir, if so, append
         $templatedir = $moduledir.'/templates';
         if (!is_dir($templatedir)) {
-            throw new InvalidArgumentException('The module \''.$module.'\' has no templates directory.');
+            throw new \InvalidArgumentException('The module \''.$module.'\' has no templates directory.');
         }
         return $templatedir;
     }
@@ -325,12 +326,12 @@ class SimpleSAML_XHTML_Template
      *
      * @param string $module The module where we need to search for templates.
      *
-     * @throws InvalidArgumentException If the module is not enabled or it has no templates directory.
+     * @throws \InvalidArgumentException If the module is not enabled or it has no templates directory.
      */
     public function addTemplatesFromModule($module)
     {
         $dir = $this->getModuleTemplateDir($module);
-        /** @var Twig_Loader_Filesystem $loader */
+        /** @var \Twig_Loader_Filesystem $loader */
         $loader = $this->twig->getLoader();
         $loader->addPath($dir, $module);
     }
@@ -444,7 +445,7 @@ class SimpleSAML_XHTML_Template
      *
      * @return string The absolute path to the template file.
      *
-     * @throws Exception If the template file couldn't be found.
+     * @throws \Exception If the template file couldn't be found.
      */
     private function findTemplatePath($template, $throw_exception = true)
     {
@@ -496,7 +497,7 @@ class SimpleSAML_XHTML_Template
             $error = 'Template: Could not find template file ['.$template.'] at ['.$filename.']';
             \SimpleSAML\Logger::critical($_SERVER['PHP_SELF'].' - '.$error);
 
-            throw new Exception($error);
+            throw new \Exception($error);
         } else {
             // missing template expected, return NULL
             return null;
@@ -518,7 +519,7 @@ class SimpleSAML_XHTML_Template
     /**
      * Get the current instance of Twig in use.
      *
-     * @return false|Twig_Environment The Twig instance in use, or false if Twig is not used.
+     * @return false|\Twig_Environment The Twig instance in use, or false if Twig is not used.
      */
     public function getTwig()
     {
diff --git a/modules/adfs/www/idp/metadata.php b/modules/adfs/www/idp/metadata.php
index 20a745aee..22f0a7b38 100644
--- a/modules/adfs/www/idp/metadata.php
+++ b/modules/adfs/www/idp/metadata.php
@@ -144,7 +144,7 @@ try {
     if ($output_xhtml) {
         $defaultidp = $config->getString('default-adfs-idp', null);
 
-        $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin');
+        $t = new \SimpleSAML\XHTML\Template($config, 'metadata.php', 'admin');
 
         $t->data['clipboard.js'] = true;
         $t->data['available_certs'] = $availableCerts;
diff --git a/modules/authX509/lib/Auth/Source/X509userCert.php b/modules/authX509/lib/Auth/Source/X509userCert.php
index a03b96c1d..49860c2c6 100644
--- a/modules/authX509/lib/Auth/Source/X509userCert.php
+++ b/modules/authX509/lib/Auth/Source/X509userCert.php
@@ -6,9 +6,9 @@
  * @author Emmanuel Dreyfus <manu@netbsd.org>
  * @package SimpleSAMLphp
  */
+
 class sspmod_authX509_Auth_Source_X509userCert extends SimpleSAML_Auth_Source
 {
-
     /**
      * x509 attributes to use from the certificate for searching the user in the LDAP directory.
      */
@@ -70,9 +70,9 @@ class sspmod_authX509_Auth_Source_X509userCert extends SimpleSAML_Auth_Source
     {
         $config = \SimpleSAML\Configuration::getInstance();
 
-        $t = new SimpleSAML_XHTML_Template($config, 'authX509:X509error.php');
+        $t = new \SimpleSAML\XHTML\Template($config, 'authX509:X509error.php');
         $t->data['errorcode'] = $state['authX509.error'];
-        $t->data['errorcodes'] = SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
+        $t->data['errorcodes'] = \SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
 
         $t->show();
         exit();
diff --git a/modules/authX509/www/expirywarning.php b/modules/authX509/www/expirywarning.php
index 7b1671317..73b3f8658 100644
--- a/modules/authX509/www/expirywarning.php
+++ b/modules/authX509/www/expirywarning.php
@@ -6,26 +6,26 @@
  * @package SimpleSAMLphp
  */
 
-SimpleSAML\Logger::info('AuthX509 - Showing expiry warning to user');
+\SimpleSAML\Logger::info('AuthX509 - Showing expiry warning to user');
 
 if (!array_key_exists('StateId', $_REQUEST)) {
-    throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
+    throw new \SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
 }
 $id = $_REQUEST['StateId'];
-$state = SimpleSAML_Auth_State::loadState($id, 'warning:expire');
+$state = \SimpleSAML_Auth_State::loadState($id, 'warning:expire');
 
 
 if (array_key_exists('proceed', $_REQUEST)) {
     // The user has pressed the proceed-button
-    SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
+    \SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
 }
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
 
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'authX509:X509warning.php');
-$t->data['target'] = SimpleSAML\Module::getModuleURL('authX509/expirywarning.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'authX509:X509warning.php');
+$t->data['target'] = \SimpleSAML\Module::getModuleURL('authX509/expirywarning.php');
 $t->data['data'] = array('StateId' => $id);
 $t->data['daysleft'] = $state['daysleft'];
 $t->data['renewurl'] = $state['renewurl'];
-$t->data['errorcodes'] = SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
+$t->data['errorcodes'] = \SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
 $t->show();
diff --git a/modules/authYubiKey/www/yubikeylogin.php b/modules/authYubiKey/www/yubikeylogin.php
index 5fa9ee701..7b6c94f2f 100644
--- a/modules/authYubiKey/www/yubikeylogin.php
+++ b/modules/authYubiKey/www/yubikeylogin.php
@@ -10,7 +10,7 @@
  */
 
 if (!array_key_exists('AuthState', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
 }
 $authStateId = $_REQUEST['AuthState'];
 
@@ -22,17 +22,17 @@ if (array_key_exists('otp', $_REQUEST)) {
 
 if (!empty($otp)) {
 	// attempt to log in
-	$errorCode = sspmod_authYubiKey_Auth_Source_YubiKey::handleLogin($authStateId, $otp);
+	$errorCode = \sspmod_authYubiKey_Auth_Source_YubiKey::handleLogin($authStateId, $otp);
 } else {
 	$errorCode = NULL;
 }
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'authYubiKey:yubikeylogin.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'authYubiKey:yubikeylogin.php');
 $t->data['stateparams'] = array('AuthState' => $authStateId);
 $t->data['errorcode'] = $errorCode;
-$t->data['errorcodes'] = SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
-$t->data['logo_url'] = SimpleSAML\Module::getModuleURL('authYubiKey/resources/logo.jpg');
-$t->data['devicepic_url'] = SimpleSAML\Module::getModuleURL('authYubiKey/resources/yubikey.jpg');
+$t->data['errorcodes'] = \SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
+$t->data['logo_url'] = \SimpleSAML\Module::getModuleURL('authYubiKey/resources/logo.jpg');
+$t->data['devicepic_url'] = \SimpleSAML\Module::getModuleURL('authYubiKey/resources/yubikey.jpg');
 $t->show();
 exit();
diff --git a/modules/authorize/www/authorize_403.php b/modules/authorize/www/authorize_403.php
index fec588740..a9ebc8362 100644
--- a/modules/authorize/www/authorize_403.php
+++ b/modules/authorize/www/authorize_403.php
@@ -6,14 +6,14 @@
  */
 
 if (!array_key_exists('StateId', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
 }
-$state = SimpleSAML_Auth_State::loadState($_REQUEST['StateId'], 'authorize:Authorize');
+$state = \SimpleSAML_Auth_State::loadState($_REQUEST['StateId'], 'authorize:Authorize');
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'authorize:authorize_403.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'authorize:authorize_403.php');
 if (isset($state['Source']['auth'])) {
-    $t->data['LogoutURL'] = SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $state['Source']['auth']))."&logout";
+    $t->data['LogoutURL'] = \SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $state['Source']['auth']))."&logout";
 }
 header('HTTP/1.0 403 Forbidden');
 $t->show();
diff --git a/modules/consent/templates/consentform.php b/modules/consent/templates/consentform.php
index d9be45d32..338434d19 100644
--- a/modules/consent/templates/consentform.php
+++ b/modules/consent/templates/consentform.php
@@ -131,9 +131,9 @@ if ($this->data['sppp'] !== false) {
 /**
  * Recursive attribute array listing function
  *
- * @param SimpleSAML_XHTML_Template $t          Template object
- * @param array                     $attributes Attributes to be presented
- * @param string                    $nameParent Name of parent element
+ * @param \SimpleSAML\XHTML\Template $t          Template object
+ * @param array                      $attributes Attributes to be presented
+ * @param string                     $nameParent Name of parent element
  *
  * @return string HTML representation of the attributes 
  */
diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php
index 1e936d435..652df202a 100644
--- a/modules/consent/www/getconsent.php
+++ b/modules/consent/www/getconsent.php
@@ -55,7 +55,7 @@ if (array_key_exists('yes', $_REQUEST)) {
     if (isset($state['Destination']['entityid'])) {
         $statsInfo['spEntityID'] = $state['Destination']['entityid'];
     }
-    SimpleSAML_Stats::log('consent:accept', $statsInfo);
+    \SimpleSAML_Stats::log('consent:accept', $statsInfo);
 
     if (   array_key_exists('consent:store', $state) 
         && array_key_exists('saveconsent', $_REQUEST)
@@ -67,7 +67,7 @@ if (array_key_exists('yes', $_REQUEST)) {
         $targetedId = $state['consent:store.destination'];
         $attributeSet = $state['consent:store.attributeSet'];
 
-        SimpleSAML\Logger::debug(
+        \SimpleSAML\Logger::debug(
             'Consent - saveConsent() : [' . $userId . '|' .
             $targetedId . '|' .  $attributeSet . ']'
         );	
@@ -78,7 +78,7 @@ if (array_key_exists('yes', $_REQUEST)) {
         }
     }
 
-    SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
+    \SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
 }
 
 // Prepare attributes for presentation
@@ -99,12 +99,12 @@ $para = array(
 SimpleSAML\Module::callHooks('attributepresentation', $para);
 
 // Make, populate and layout consent form
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'consent:consentform.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'consent:consentform.php');
 $t->data['srcMetadata'] = $state['Source'];
 $t->data['dstMetadata'] = $state['Destination'];
-$t->data['yesTarget'] = SimpleSAML\Module::getModuleURL('consent/getconsent.php');
+$t->data['yesTarget'] = \SimpleSAML\Module::getModuleURL('consent/getconsent.php');
 $t->data['yesData'] = array('StateId' => $id);
-$t->data['noTarget'] = SimpleSAML\Module::getModuleURL('consent/noconsent.php');
+$t->data['noTarget'] = \SimpleSAML\Module::getModuleURL('consent/noconsent.php');
 $t->data['noData'] = array('StateId' => $id);
 $t->data['attributes'] = $attributes;
 $t->data['checked'] = $state['consent:checked'];
diff --git a/modules/consent/www/logout.php b/modules/consent/www/logout.php
index 2d46540df..84eca697c 100644
--- a/modules/consent/www/logout.php
+++ b/modules/consent/www/logout.php
@@ -6,12 +6,12 @@
  */
 
 if (!array_key_exists('StateId', $_GET)) {
-    throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
+    throw new \SimpleSAML\Error\BadRequest('Missing required StateId query parameter.');
 }
-$state = SimpleSAML_Auth_State::loadState($_GET['StateId'], 'consent:request');
+$state = \SimpleSAML_Auth_State::loadState($_GET['StateId'], 'consent:request');
 
 $state['Responder'] = array('sspmod_consent_Logout', 'postLogout');
 
-$idp = SimpleSAML_IdP::getByState($state);
+$idp = \SimpleSAML_IdP::getByState($state);
 $idp->handleLogoutRequest($state, null);
 assert(false);
diff --git a/modules/consent/www/logout_completed.php b/modules/consent/www/logout_completed.php
index e0d2a077a..a5124704f 100644
--- a/modules/consent/www/logout_completed.php
+++ b/modules/consent/www/logout_completed.php
@@ -6,5 +6,5 @@
  */
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'consent:logout_completed.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'consent:logout_completed.php');
 $t->show();
diff --git a/modules/consent/www/noconsent.php b/modules/consent/www/noconsent.php
index 9a73b0b71..f6ae87528 100644
--- a/modules/consent/www/noconsent.php
+++ b/modules/consent/www/noconsent.php
@@ -1,24 +1,26 @@
 <?php
+
 /**
  * This is the page the user lands on when choosing "no" in the consent form.
  *
  * @package SimpleSAMLphp
  */
+
 if (!array_key_exists('StateId', $_REQUEST)) {
-    throw new SimpleSAML_Error_BadRequest(
+    throw new \SimpleSAML_Error_BadRequest(
         'Missing required StateId query parameter.'
     );
 }
 
 $id = $_REQUEST['StateId'];
-$state = SimpleSAML_Auth_State::loadState($id, 'consent:request');
+$state = \SimpleSAML_Auth_State::loadState($id, 'consent:request');
 
-$resumeFrom = SimpleSAML\Module::getModuleURL(
+$resumeFrom = \SimpleSAML\Module::getModuleURL(
     'consent/getconsent.php',
     array('StateId' => $id)
 );
 
-$logoutLink = SimpleSAML\Module::getModuleURL(
+$logoutLink = \SimpleSAML\Module::getModuleURL(
     'consent/logout.php',
     array('StateId' => $id)
 );
@@ -35,11 +37,11 @@ $statsInfo = array();
 if (isset($state['Destination']['entityid'])) {
     $statsInfo['spEntityID'] = $state['Destination']['entityid'];
 }
-SimpleSAML_Stats::log('consent:reject', $statsInfo);
+\SimpleSAML_Stats::log('consent:reject', $statsInfo);
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
 
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'consent:noconsent.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'consent:noconsent.php');
 $t->data['dstMetadata'] = $state['Destination'];
 $t->data['resumeFrom'] = $resumeFrom;
 $t->data['aboutService'] = $aboutService;
diff --git a/modules/consentAdmin/www/consentAdmin.php b/modules/consentAdmin/www/consentAdmin.php
index eee9cf44b..5e8dc0cc1 100644
--- a/modules/consentAdmin/www/consentAdmin.php
+++ b/modules/consentAdmin/www/consentAdmin.php
@@ -192,12 +192,12 @@ if ($action !== null && $sp_entityid !== null) {
             }
             // Unknown action (should not happen)
         } else {
-            SimpleSAML\Logger::info('consentAdmin: unknown action');
+            \SimpleSAML\Logger::info('consentAdmin: unknown action');
             $res = "unknown";
         }
     }
     // init template to enable translation of status messages
-    $template = new SimpleSAML_XHTML_Template($config, 'consentAdmin:consentadminajax.php', 'consentAdmin:consentadmin');
+    $template = new \SimpleSAML\XHTML\Template($config, 'consentAdmin:consentadminajax.php', 'consentAdmin:consentadmin');
     $template->data['res'] = $res;
     $template->show();
     exit;
@@ -215,7 +215,7 @@ foreach ($user_consent_list as $c) {
 $template_sp_content = array();
 
 // Init template
-$template = new SimpleSAML_XHTML_Template($config, 'consentAdmin:consentadmin.php', 'consentAdmin:consentadmin');
+$template = new \SimpleSAML\XHTML\Template($config, 'consentAdmin:consentadmin.php', 'consentAdmin:consentadmin');
 $translator = $template->getTranslator();
 $translator->includeLanguageFile('attributes.php'); // attribute listings translated by this dictionary
 $sp_empty_name = $translator->getTag('sp_empty_name');
diff --git a/modules/core/www/as_login.php b/modules/core/www/as_login.php
index e43a77898..d8dd4382c 100644
--- a/modules/core/www/as_login.php
+++ b/modules/core/www/as_login.php
@@ -7,11 +7,11 @@
  */
 
 if (!isset($_REQUEST['ReturnTo'])) {
-	throw new SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
 }
 
 if (!isset($_REQUEST['AuthId'])) {
-	throw new SimpleSAML_Error_BadRequest('Missing AuthId parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing AuthId parameter.');
 }
 
 /*
diff --git a/modules/core/www/as_logout.php b/modules/core/www/as_logout.php
index bfd923415..bac8b042d 100644
--- a/modules/core/www/as_logout.php
+++ b/modules/core/www/as_logout.php
@@ -7,11 +7,11 @@
  */
 
 if (!isset($_REQUEST['ReturnTo']) || !is_string($_REQUEST['ReturnTo'])) {
-	throw new SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
 }
 
 if (!isset($_REQUEST['AuthId']) || !is_string($_REQUEST['AuthId'])) {
-	throw new SimpleSAML_Error_BadRequest('Missing AuthId parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing AuthId parameter.');
 }
 
 $as = new \SimpleSAML\Auth\Simple($_REQUEST['AuthId']);
diff --git a/modules/core/www/authenticate.php b/modules/core/www/authenticate.php
index ed56c6a06..47a922044 100644
--- a/modules/core/www/authenticate.php
+++ b/modules/core/www/authenticate.php
@@ -3,9 +3,9 @@
 $config = \SimpleSAML\Configuration::getInstance();
 
 if (!array_key_exists('as', $_REQUEST)) {
-    $t = new SimpleSAML_XHTML_Template($config, 'core:authsource_list.tpl.php');
+    $t = new \SimpleSAML\XHTML\Template($config, 'core:authsource_list.tpl.php');
 
-    $t->data['sources'] = SimpleSAML_Auth_Source::getSources();
+    $t->data['sources'] = \SimpleSAML_Auth_Source::getSources();
     $t->show();
     exit();
 }
@@ -17,18 +17,18 @@ if (array_key_exists('logout', $_REQUEST)) {
     $as->logout($config->getBasePath().'logout.php');
 }
 
-if (array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) {
+if (array_key_exists(\SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) {
     // This is just a simple example of an error
 
-    $state = SimpleSAML_Auth_State::loadExceptionState();
-    assert(array_key_exists(SimpleSAML_Auth_State::EXCEPTION_DATA, $state));
-    $e = $state[SimpleSAML_Auth_State::EXCEPTION_DATA];
+    $state = \SimpleSAML_Auth_State::loadExceptionState();
+    assert(array_key_exists(\SimpleSAML_Auth_State::EXCEPTION_DATA, $state));
+    $e = $state[\SimpleSAML_Auth_State::EXCEPTION_DATA];
 
     throw $e;
 }
 
 if (!$as->isAuthenticated()) {
-    $url = SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $asId));
+    $url = \SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $asId));
     $params = array(
         'ErrorURL' => $url,
         'ReturnTo' => $url,
@@ -39,7 +39,7 @@ if (!$as->isAuthenticated()) {
 $attributes = $as->getAttributes();
 $authData = $as->getAuthDataArray();
 
-$t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes');
+$t = new \SimpleSAML\XHTML\Template($config, 'status.php', 'attributes');
 
 $t->data['header'] = '{status:header_saml20_sp}';
 $t->data['attributes'] = $attributes;
diff --git a/modules/core/www/cardinality_error.php b/modules/core/www/cardinality_error.php
index 2eb19e354..5d364aaa3 100644
--- a/modules/core/www/cardinality_error.php
+++ b/modules/core/www/cardinality_error.php
@@ -16,7 +16,7 @@ $session = \SimpleSAML\Session::getSessionFromRequest();
     ' '.implode(',', array_keys($state['core:cardinality:errorAttributes'])));
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new \SimpleSAML_XHTML_Template($globalConfig, 'core:cardinality_error.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:cardinality_error.tpl.php');
 $t->data['cardinalityErrorAttributes'] = $state['core:cardinality:errorAttributes'];
 if (isset($state['Source']['auth'])) {
     $t->data['LogoutURL'] = \SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $state['Source']['auth']))."&logout";
diff --git a/modules/core/www/cleardiscochoices.php b/modules/core/www/cleardiscochoices.php
index 88a83be82..96c19d841 100644
--- a/modules/core/www/cleardiscochoices.php
+++ b/modules/core/www/cleardiscochoices.php
@@ -23,7 +23,6 @@ foreach($_COOKIE as $cookieName => $value) {
     \SimpleSAML\Utils\HTTP::setCookie($cookieName, NULL, array('path' => $cookiePath, 'httponly' => FALSE), FALSE);
 }
 
-
 /* Find where we should go now. */
 if(array_key_exists('ReturnTo', $_REQUEST)) {
 	$returnTo = \SimpleSAML\Utils\HTTP::checkURLAllowed($_REQUEST['ReturnTo']);
diff --git a/modules/core/www/frontpage_auth.php b/modules/core/www/frontpage_auth.php
index 243221342..7e3efb979 100644
--- a/modules/core/www/frontpage_auth.php
+++ b/modules/core/www/frontpage_auth.php
@@ -1,15 +1,15 @@
 <?php
 
-// Load SimpleSAMLphp, configuration
+// Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists
 if ($config->getBoolean('admin.protectindexpage', false)) {
-    SimpleSAML\Utils\Auth::requireAdmin();
+    \SimpleSAML\Utils\Auth::requireAdmin();
 }
-$loginurl = SimpleSAML\Utils\Auth::getAdminLoginURL();
-$isadmin = SimpleSAML\Utils\Auth::isAdmin();
+$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL();
+$isadmin = \SimpleSAML\Utils\Auth::isAdmin();
 
 $links = array();
 $links_welcome = array();
@@ -29,9 +29,9 @@ $allLinks = array(
 	'auth'       => &$links_auth,
 	'federation' => &$links_federation,
 );
-SimpleSAML\Module::callHooks('frontpage', $allLinks);
+\SimpleSAML\Module::callHooks('frontpage', $allLinks);
 
-$t = new SimpleSAML_XHTML_Template($config, 'core:frontpage_auth.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_auth.tpl.php');
 $t->data['pageid'] = 'frontpage_auth';
 $t->data['isadmin'] = $isadmin;
 $t->data['loginurl'] = $loginurl;
diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php
index b26829738..dd6cac397 100644
--- a/modules/core/www/frontpage_config.php
+++ b/modules/core/www/frontpage_config.php
@@ -6,10 +6,10 @@ $session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists.
 if ($config->getBoolean('admin.protectindexpage', false)) {
-    SimpleSAML\Utils\Auth::requireAdmin();
+    \SimpleSAML\Utils\Auth::requireAdmin();
 }
-$loginurl = SimpleSAML\Utils\Auth::getAdminLoginURL();
-$isadmin = SimpleSAML\Utils\Auth::isAdmin();
+$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL();
+$isadmin = \SimpleSAML\Utils\Auth::isAdmin();
 
 
 $warnings = array();
@@ -52,7 +52,7 @@ $allLinks = array(
     'auth'       => &$links_auth,
    'federation' => &$links_federation,
 );
-SimpleSAML\Module::callHooks('frontpage', $allLinks);
+\SimpleSAML\Module::callHooks('frontpage', $allLinks);
 
 // Check for updates. Store the remote result in the session so we
 // don't need to fetch it on every access to this page.
@@ -106,10 +106,10 @@ $functionchecks = array(
     'session_start'  => array('optional', 'Session Extension (required if PHP sessions are used)'),
     'pdo_drivers'    => array('optional', 'PDO Extension (required if a database backend is used)'),
 );
-if (SimpleSAML\Module::isModuleEnabled('ldap')) {
+if (\SimpleSAML\Module::isModuleEnabled('ldap')) {
     $functionchecks['ldap_bind'] = array('optional', 'LDAP Extension (required if an LDAP backend is used)');
 }
-if (SimpleSAML\Module::isModuleEnabled('radius')) {
+if (\SimpleSAML\Module::isModuleEnabled('radius')) {
     $functionchecks['radius_auth_open'] = array('optional', 'Radius Extension (required if a Radius backend is used)');
 }
 
@@ -158,7 +158,7 @@ $funcmatrix[] = array(
     'enabled' => $password_ok
 );
 
-$t = new SimpleSAML_XHTML_Template($config, 'core:frontpage_config.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_config.tpl.php');
 $t->data['pageid'] = 'frontpage_config';
 $t->data['isadmin'] = $isadmin;
 $t->data['loginurl'] = $loginurl;
diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php
index 713aab5ac..2e109c340 100644
--- a/modules/core/www/frontpage_federation.php
+++ b/modules/core/www/frontpage_federation.php
@@ -1,15 +1,15 @@
 <?php
 
-// Load SimpleSAMLphp, configuration
+// Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists.
 if ($config->getBoolean('admin.protectindexpage', false)) {
-    SimpleSAML\Utils\Auth::requireAdmin();
+    \SimpleSAML\Utils\Auth::requireAdmin();
 }
-$loginurl = SimpleSAML\Utils\Auth::getAdminLoginURL();
-$isadmin = SimpleSAML\Utils\Auth::isAdmin();
+$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL();
+$isadmin = \SimpleSAML\Utils\Auth::isAdmin();
 
 $links = array();
 $links_welcome = array();
@@ -37,14 +37,14 @@ $allLinks = array(
 	'auth'       => &$links_auth,
 	'federation' => &$links_federation,
 );
-SimpleSAML\Module::callHooks('frontpage', $allLinks);
+\SimpleSAML\Module::callHooks('frontpage', $allLinks);
 
 
 $metadataHosted = array();
-SimpleSAML\Module::callHooks('metadata_hosted', $metadataHosted);
+\SimpleSAML\Module::callHooks('metadata_hosted', $metadataHosted);
 
 
-$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
+$metadata = \SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 $metaentries = array('hosted' => $metadataHosted, 'remote' => array() );
 
@@ -62,7 +62,7 @@ if ($config->getBoolean('enable.saml20-idp', FALSE) === true) {
 		if ($isadmin)
 			$metaentries['remote']['saml20-sp-remote'] = $metadata->getList('saml20-sp-remote');
 	} catch(Exception $e) {
-        SimpleSAML\Logger::error('Federation: Error loading saml20-idp: ' . $e->getMessage());
+        \SimpleSAML\Logger::error('Federation: Error loading saml20-idp: ' . $e->getMessage());
     }
 }
 if ($config->getBoolean('enable.shib13-idp', FALSE) === true) {
@@ -73,18 +73,18 @@ if ($config->getBoolean('enable.shib13-idp', FALSE) === true) {
 		if ($isadmin)
 			$metaentries['remote']['shib13-sp-remote'] = $metadata->getList('shib13-sp-remote');
 	} catch(Exception $e) {
-        SimpleSAML\Logger::error('Federation: Error loading shib13-idp: ' . $e->getMessage());
+        \SimpleSAML\Logger::error('Federation: Error loading shib13-idp: ' . $e->getMessage());
     }
 }
 if ($config->getBoolean('enable.adfs-idp', FALSE) === true) {
     try {
         $metaentries['hosted']['adfs-idp'] = $metadata->getMetaDataCurrent('adfs-idp-hosted');
-        $metaentries['hosted']['adfs-idp']['metadata-url'] = SimpleSAML\Module::getModuleURL('adfs/idp/metadata.php',
+        $metaentries['hosted']['adfs-idp']['metadata-url'] = \SimpleSAML\Module::getModuleURL('adfs/idp/metadata.php',
                                                                                              array('output' => 'xhtml'));
         if ($isadmin)
             $metaentries['remote']['adfs-sp-remote'] = $metadata->getList('adfs-sp-remote');
     } catch(Exception $e) {
-        SimpleSAML\Logger::error('Federation: Error loading adfs-idp: ' . $e->getMessage());
+        \SimpleSAML\Logger::error('Federation: Error loading adfs-idp: ' . $e->getMessage());
     }
 }
 
@@ -94,7 +94,7 @@ foreach ($metaentries['remote'] as $key => $value) {
 	}
 }
 
-$t = new SimpleSAML_XHTML_Template($config, 'core:frontpage_federation.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_federation.tpl.php');
 
 # look up translated string
 $mtype = array(
diff --git a/modules/core/www/frontpage_welcome.php b/modules/core/www/frontpage_welcome.php
index 8ebb5e6f9..a9020fbe0 100644
--- a/modules/core/www/frontpage_welcome.php
+++ b/modules/core/www/frontpage_welcome.php
@@ -9,8 +9,8 @@ $session = \SimpleSAML\Session::getSessionFromRequest();
 if ($config->getBoolean('admin.protectindexpage', false)) {
     SimpleSAML\Utils\Auth::requireAdmin();
 }
-$loginurl = SimpleSAML\Utils\Auth::getAdminLoginURL();
-$isadmin = SimpleSAML\Utils\Auth::isAdmin();
+$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL();
+$isadmin = \SimpleSAML\Utils\Auth::isAdmin();
 
 $links = array();
 $links_welcome = array();
@@ -31,9 +31,9 @@ $links_welcome[] = array(
 	'text' => '{core:frontpage:doc_header}',
 );
 
-SimpleSAML\Module::callHooks('frontpage', $allLinks);
+\SimpleSAML\Module::callHooks('frontpage', $allLinks);
 
-$t = new SimpleSAML_XHTML_Template($config, 'core:frontpage_welcome.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_welcome.tpl.php');
 $t->data['pageid'] = 'frontpage_welcome';
 $t->data['isadmin'] = $isadmin;
 $t->data['loginurl'] = $loginurl;
diff --git a/modules/core/www/idp/logout-iframe.php b/modules/core/www/idp/logout-iframe.php
index 71b908760..2463b50be 100644
--- a/modules/core/www/idp/logout-iframe.php
+++ b/modules/core/www/idp/logout-iframe.php
@@ -1,26 +1,26 @@
 <?php
 
 if (!isset($_REQUEST['id'])) {
-    throw new SimpleSAML_Error_BadRequest('Missing required parameter: id');
+    throw new \SimpleSAML_Error_BadRequest('Missing required parameter: id');
 }
 
 if (isset($_REQUEST['type'])) {
     $type = (string) $_REQUEST['type'];
     if (!in_array($type, array('init', 'js', 'nojs', 'embed'), true)) {
-        throw new SimpleSAML_Error_BadRequest('Invalid value for type.');
+        throw new \SimpleSAML_Error_BadRequest('Invalid value for type.');
     }
 } else {
     $type = 'init';
 }
 
 if ($type !== 'embed') {
-    SimpleSAML\Logger::stats('slo-iframe '.$type);
-    SimpleSAML_Stats::log('core:idp:logout-iframe:page', array('type' => $type));
+    \SimpleSAML\Logger::stats('slo-iframe '.$type);
+    \SimpleSAML_Stats::log('core:idp:logout-iframe:page', array('type' => $type));
 }
 
-$state = SimpleSAML_Auth_State::loadState($_REQUEST['id'], 'core:Logout-IFrame');
-$idp = SimpleSAML_IdP::getByState($state);
-$mdh = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
+$state = \SimpleSAML_Auth_State::loadState($_REQUEST['id'], 'core:Logout-IFrame');
+$idp = \SimpleSAML_IdP::getByState($state);
+$mdh = \SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 if ($type !== 'init') { // update association state
     foreach ($state['core:Logout-IFrame:Associations'] as $assocId => &$sp) {
@@ -74,7 +74,7 @@ foreach ($state['core:Logout-IFrame:Associations'] as $assocId => &$sp) {
         $assocIdP = SimpleSAML_IdP::getByState($sp);
         $url = call_user_func(array($sp['Handler'], 'getLogoutURL'), $assocIdP, $sp, null);
         $sp['core:Logout-IFrame:URL'] = $url;
-    } catch (Exception $e) {
+    } catch (\Exception $e) {
         $sp['core:Logout-IFrame:State'] = 'failed';
     }
 }
@@ -112,7 +112,7 @@ foreach ($state['core:Logout-IFrame:Associations'] as $association) {
     }
 }
 
-$id = SimpleSAML_Auth_State::saveState($state, 'core:Logout-IFrame');
+$id = \SimpleSAML_Auth_State::saveState($state, 'core:Logout-IFrame');
 $globalConfig = \SimpleSAML\Configuration::getInstance();
 
 $template_id = 'core:logout-iframe.php';
@@ -120,7 +120,7 @@ if ($type === 'nojs') {
     $template_id = 'core:logout-iframe-wrapper.php';
 }
 
-$t = new SimpleSAML_XHTML_Template($globalConfig, $template_id);
+$t = new \SimpleSAML\XHTML\Template($globalConfig, $template_id);
 $t->data['auth_state'] = $id;
 /**
  * @deprecated The "id" variable will be removed. Please use "auth_state" instead.
diff --git a/modules/core/www/login-admin.php b/modules/core/www/login-admin.php
index 22bc7854a..4d8e6c851 100644
--- a/modules/core/www/login-admin.php
+++ b/modules/core/www/login-admin.php
@@ -4,10 +4,10 @@
  */
 
 if (!array_key_exists('ReturnTo', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
 }
 
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 \SimpleSAML\Utils\HTTP::redirectUntrustedURL($_REQUEST['ReturnTo']);
 
diff --git a/modules/core/www/loginuserpass.php b/modules/core/www/loginuserpass.php
index 2469c2220..70dd0d150 100644
--- a/modules/core/www/loginuserpass.php
+++ b/modules/core/www/loginuserpass.php
@@ -73,7 +73,7 @@ if (!empty($_REQUEST['username']) || !empty($password)) {
 }
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:loginuserpass.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:loginuserpass.php');
 $t->data['stateparams'] = array('AuthState' => $authStateId);
 if (array_key_exists('forcedUsername', $state)) {
 	$t->data['username'] = $state['forcedUsername'];
diff --git a/modules/core/www/loginuserpassorg.php b/modules/core/www/loginuserpassorg.php
index 07a89859c..90f6e46af 100644
--- a/modules/core/www/loginuserpassorg.php
+++ b/modules/core/www/loginuserpassorg.php
@@ -11,17 +11,17 @@
 
 // Retrieve the authentication state
 if (!array_key_exists('AuthState', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
 }
 $authStateId = $_REQUEST['AuthState'];
-$state = SimpleSAML_Auth_State::loadState($authStateId, sspmod_core_Auth_UserPassOrgBase::STAGEID);
+$state = \SimpleSAML_Auth_State::loadState($authStateId, sspmod_core_Auth_UserPassOrgBase::STAGEID);
 
-$source = SimpleSAML_Auth_Source::getById($state[sspmod_core_Auth_UserPassOrgBase::AUTHID]);
+$source = \SimpleSAML_Auth_Source::getById($state[sspmod_core_Auth_UserPassOrgBase::AUTHID]);
 if ($source === NULL) {
 	throw new Exception('Could not find authentication source with id ' . $state[sspmod_core_Auth_UserPassOrgBase::AUTHID]);
 }
 
-$organizations = sspmod_core_Auth_UserPassOrgBase::listOrganizations($authStateId);
+$organizations = \sspmod_core_Auth_UserPassOrgBase::listOrganizations($authStateId);
 
 if (array_key_exists('username', $_REQUEST)) {
 	$username = $_REQUEST['username'];
@@ -61,7 +61,7 @@ if ($organizations === NULL || !empty($organization)) {
 		}
 
 		try {
-			sspmod_core_Auth_UserPassOrgBase::handleLogin($authStateId, $username, $password, $organization);
+			\sspmod_core_Auth_UserPassOrgBase::handleLogin($authStateId, $username, $password, $organization);
 		} catch (SimpleSAML_Error_Error $e) {
 			// Login failed. Extract error code and parameters, to display the error
 			$errorCode = $e->getErrorCode();
@@ -71,7 +71,7 @@ if ($organizations === NULL || !empty($organization)) {
 }
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:loginuserpass.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:loginuserpass.php');
 $t->data['stateparams'] = array('AuthState' => $authStateId);
 $t->data['username'] = $username;
 $t->data['forceUsername'] = FALSE;
@@ -81,7 +81,7 @@ $t->data['rememberMeEnabled'] = false;
 $t->data['rememberMeChecked'] = false;
 if (isset($_COOKIE[$source->getAuthId() . '-username'])) $t->data['rememberUsernameChecked'] = TRUE;
 $t->data['errorcode'] = $errorCode;
-$t->data['errorcodes'] = SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
+$t->data['errorcodes'] = \SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
 $t->data['errorparams'] = $errorParams;
 
 if ($organizations !== NULL) {
diff --git a/modules/core/www/no_cookie.php b/modules/core/www/no_cookie.php
index 76ddd662d..8ad2e3c83 100644
--- a/modules/core/www/no_cookie.php
+++ b/modules/core/www/no_cookie.php
@@ -8,6 +8,6 @@ if (isset($_REQUEST['retryURL'])) {
 }
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_cookie.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:no_cookie.tpl.php');
 $t->data['retryURL'] = $retryURL;
 $t->show();
diff --git a/modules/core/www/postredirect.php b/modules/core/www/postredirect.php
index 06d52ce4b..00cb8a088 100644
--- a/modules/core/www/postredirect.php
+++ b/modules/core/www/postredirect.php
@@ -13,18 +13,18 @@ if (array_key_exists('RedirId', $_REQUEST)) {
 	$encData = base64_decode($_REQUEST['RedirInfo']);
 
 	if (empty($encData)) {
-		throw new SimpleSAML_Error_BadRequest('Invalid RedirInfo data.');
+		throw new \SimpleSAML_Error_BadRequest('Invalid RedirInfo data.');
 	}
 
-	list($sessionId, $postId) = explode(':', SimpleSAML\Utils\Crypto::aesDecrypt($encData));
+	list($sessionId, $postId) = explode(':', \SimpleSAML\Utils\Crypto::aesDecrypt($encData));
 
 	if (empty($sessionId) || empty($postId)) {
-		throw new SimpleSAML_Error_BadRequest('Invalid session info data.');
+		throw new \SimpleSAML_Error_BadRequest('Invalid session info data.');
 	}
 
 	$session = \SimpleSAML\Session::getSession($sessionId);
 } else {
-	throw new SimpleSAML_Error_BadRequest('Missing redirection info parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing redirection info parameter.');
 }
 
 if ($session === NULL) {
@@ -45,7 +45,7 @@ assert(array_key_exists('url', $postData));
 assert(array_key_exists('post', $postData));
 
 $config = \SimpleSAML\Configuration::getInstance();
-$template = new SimpleSAML_XHTML_Template($config, 'post.php');
+$template = new \SimpleSAML\XHTML\Template($config, 'post.php');
 $template->data['destination'] = $postData['url'];
 $template->data['post'] = $postData['post'];
 $template->show();
diff --git a/modules/core/www/short_sso_interval.php b/modules/core/www/short_sso_interval.php
index ce61bdfe6..983a4d930 100644
--- a/modules/core/www/short_sso_interval.php
+++ b/modules/core/www/short_sso_interval.php
@@ -7,20 +7,20 @@
  */
 
 if (!array_key_exists('StateId', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
 }
 $id = $_REQUEST['StateId'];
-$state = SimpleSAML_Auth_State::loadState($id, 'core:short_sso_interval');
+$state = \SimpleSAML_Auth_State::loadState($id, 'core:short_sso_interval');
 $session = \SimpleSAML\Session::getSessionFromRequest();
 
 if (array_key_exists('continue', $_REQUEST)) {
 	// The user has pressed the continue/retry-button
-	SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
+	\SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
 }
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:short_sso_interval.php');
-$t->data['target'] = SimpleSAML\Module::getModuleURL('core/short_sso_interval.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:short_sso_interval.php');
+$t->data['target'] = \SimpleSAML\Module::getModuleURL('core/short_sso_interval.php');
 $t->data['params'] = array('StateId' => $id);
 $t->data['trackId'] = $session->getTrackID();
 $t->show();
diff --git a/modules/core/www/show_metadata.php b/modules/core/www/show_metadata.php
index d1a65b1ae..d91af1d41 100644
--- a/modules/core/www/show_metadata.php
+++ b/modules/core/www/show_metadata.php
@@ -4,7 +4,7 @@
 $config = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 if (!array_key_exists('entityid', $_REQUEST)) {
     throw new Exception('required parameter [entityid] missing');
@@ -20,15 +20,15 @@ if (!in_array(
     throw new Exception('Invalid set');
 }
 
-$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
+$metadata = \SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 $m = $metadata->getMetadata($_REQUEST['entityid'], $_REQUEST['set']);
 
-$t = new SimpleSAML_XHTML_Template($config, 'core:show_metadata.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'core:show_metadata.tpl.php');
 $t->data['clipboard.js'] = true;
 $t->data['pageid'] = 'show_metadata';
 $t->data['header'] = 'SimpleSAMLphp Show Metadata';
-$t->data['backlink'] = SimpleSAML\Module::getModuleURL('core/frontpage_federation.php');
+$t->data['backlink'] = \SimpleSAML\Module::getModuleURL('core/frontpage_federation.php');
 $t->data['m'] = $m;
 
 $t->show();
diff --git a/modules/cron/www/cron.php b/modules/cron/www/cron.php
index d8463d745..69329b977 100644
--- a/modules/cron/www/cron.php
+++ b/modules/cron/www/cron.php
@@ -5,18 +5,17 @@ $cronconfig = \SimpleSAML\Configuration::getConfig('module_cron.php');
 
 if (!is_null($cronconfig->getValue('key'))) {
 	if ($_REQUEST['key'] !== $cronconfig->getValue('key')) {
-		SimpleSAML\Logger::error('Cron - Wrong key provided. Cron will not run.');
+		\SimpleSAML\Logger::error('Cron - Wrong key provided. Cron will not run.');
 		exit;
 	}
 }
 
-$cron = new SimpleSAML\Module\cron\Cron();
+$cron = new \SimpleSAML\Module\cron\Cron();
 if (!$cron->isValidTag($_REQUEST['tag'])) {
     SimpleSAML\Logger::error('Cron - Illegal tag [' . $_REQUEST['tag'] . '].');
     exit;
 }
 
-
 $url = \SimpleSAML\Utils\HTTP::getSelfURL();
 $time = date(DATE_RFC822);
 
@@ -24,7 +23,6 @@ $croninfo = $cron->runTag($_REQUEST['tag']);
 $summary = $croninfo['summary'];
 
 if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) {
-
 	$message = '<h1>Cron report</h1><p>Cron ran at ' . $time . '</p>' .
 		'<p>URL: <tt>' . $url . '</tt></p>' .
 		'<p>Tag: ' . $croninfo['tag'] . "</p>\n\n" .
@@ -32,18 +30,17 @@ if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) {
 
 	$toaddress = $config->getString('technicalcontact_email', 'na@example.org');
 	if($toaddress == 'na@example.org') {
-		SimpleSAML\Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.');
+		\SimpleSAML\Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.');
 	} else {
 		// Use $toaddress for both TO and FROM
-		$email = new SimpleSAML_XHTML_EMail($toaddress, 'SimpleSAMLphp cron report', $toaddress);
+		$email = new \SimpleSAML\XHTML\EMail($toaddress, 'SimpleSAMLphp cron report', $toaddress);
 		$email->setBody($message);
 		$email->send();
 	}
-	
 }
 
 if (isset($_REQUEST['output']) && $_REQUEST['output'] == "xhtml") {
-	$t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-result.php','cron:cron');
+	$t = new \SimpleSAML\XHTML\Template($config, 'cron:croninfo-result.php','cron:cron');
 	$t->data['tag'] = $croninfo['tag'];
 	$t->data['time'] = $time;
 	$t->data['url'] = $url;
diff --git a/modules/cron/www/croninfo.php b/modules/cron/www/croninfo.php
index 643d24502..3e646cc6c 100644
--- a/modules/cron/www/croninfo.php
+++ b/modules/cron/www/croninfo.php
@@ -4,14 +4,14 @@
  * The _include script registers a autoloader for the SimpleSAMLphp libraries. It also
  * initializes the SimpleSAMLphp config class with the correct path.
  */
-require_once('_include.php');
 
+require_once('_include.php');
 
-// Load SimpleSAMLphp, configuration and metadata
+// Load SimpleSAMLphp configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 $cronconfig = \SimpleSAML\Configuration::getConfig('module_cron.php');
 
@@ -28,14 +28,12 @@ $def = array(
 $urls = array();
 foreach ($tags AS $tag) {
 	$urls[] = array(
-		'href' => SimpleSAML\Module::getModuleURL('cron/cron.php', array('key' => $key, 'tag' => $tag)),
+		'href' => \SimpleSAML\Module::getModuleURL('cron/cron.php', array('key' => $key, 'tag' => $tag)),
 		'tag' => $tag,
 		'int' => (array_key_exists($tag, $def) ? $def[$tag] : $def['default']),
 	);
 }
 
-
-
-$t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo.tpl.php', 'cron:cron');
+$t = new \SimpleSAML\XHTML\Template($config, 'cron:croninfo.tpl.php', 'cron:cron');
 $t->data['urls'] = $urls;
 $t->show();
diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php
index be41e6f34..31452d482 100644
--- a/modules/discopower/lib/PowerIdPDisco.php
+++ b/modules/discopower/lib/PowerIdPDisco.php
@@ -1,6 +1,5 @@
 <?php
 
-
 /**
  * This class implements a generic IdP discovery service, for use in various IdP discovery service pages. This should
  * reduce code duplication.
@@ -10,10 +9,9 @@
  * @author Andreas Ă…kre Solberg <andreas@uninett.no>, UNINETT AS.
  * @package SimpleSAMLphp
  */
-class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco
-{
-
 
+class sspmod_discopower_PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco
+{
     /**
      * The configuration for this instance.
      *
@@ -253,7 +251,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco
             }
         }
 
-        $t = new SimpleSAML_XHTML_Template($this->config, 'discopower:disco.tpl.php', 'disco');
+        $t = new \SimpleSAML\XHTML\Template($this->config, 'discopower:disco.tpl.php', 'disco');
         $discoPowerTabs = array(
             'denmark' => $t->noop('{discopower:tabs:denmark}'),
             'edugain' => $t->noop('{discopower:tabs:edugain}'),
diff --git a/modules/expirycheck/www/about2expire.php b/modules/expirycheck/www/about2expire.php
index f85a09d9a..ada7043c7 100644
--- a/modules/expirycheck/www/about2expire.php
+++ b/modules/expirycheck/www/about2expire.php
@@ -6,23 +6,23 @@
  * @package SimpleSAMLphp
  */
 
-SimpleSAML\Logger::info('expirycheck - User has been warned that NetID is near to expirational date.');
+\SimpleSAML\Logger::info('expirycheck - User has been warned that NetID is near to expirational date.');
 
 if (!array_key_exists('StateId', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
 }
 $id = $_REQUEST['StateId'];
-$state = SimpleSAML_Auth_State::loadState($id, 'expirywarning:about2expire');
+$state = \SimpleSAML_Auth_State::loadState($id, 'expirywarning:about2expire');
 
 if (array_key_exists('yes', $_REQUEST)) {
 	// The user has pressed the yes-button
-	SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
+	\SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
 }
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
 
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'expirycheck:about2expire.php');
-$t->data['yesTarget'] = SimpleSAML\Module::getModuleURL('expirycheck/about2expire.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'expirycheck:about2expire.php');
+$t->data['yesTarget'] = \SimpleSAML\Module::getModuleURL('expirycheck/about2expire.php');
 $t->data['yesData'] = array('StateId' => $id);
 $t->data['daysleft'] = $state['daysleft'];
 $t->data['expireOnDate'] = $state['expireOnDate'];
diff --git a/modules/expirycheck/www/expired.php b/modules/expirycheck/www/expired.php
index 225406910..33fe530c4 100644
--- a/modules/expirycheck/www/expired.php
+++ b/modules/expirycheck/www/expired.php
@@ -6,16 +6,16 @@
  * @package SimpleSAMLphp
  */
 
-SimpleSAML\Logger::info('expirycheck - User has been warned that NetID is near to expirational date.');
+\SimpleSAML\Logger::info('expirycheck - User has been warned that NetID is near to expirational date.');
 
 if (!array_key_exists('StateId', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
 }
-$state = SimpleSAML_Auth_State::loadState($_REQUEST['StateId'], 'expirywarning:expired');
+$state = \SimpleSAML_Auth_State::loadState($_REQUEST['StateId'], 'expirywarning:expired');
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
 
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'expirycheck:expired.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'expirycheck:expired.php');
 $t->data['expireOnDate'] = $state['expireOnDate'];
 $t->data['netId'] = $state['netId'];
 $t->show();
diff --git a/modules/memcacheMonitor/www/memcachestat.php b/modules/memcacheMonitor/www/memcachestat.php
index 5e9caa8f4..452a6fd6a 100644
--- a/modules/memcacheMonitor/www/memcachestat.php
+++ b/modules/memcacheMonitor/www/memcachestat.php
@@ -12,9 +12,7 @@ function hours($input) {
 	
 }
 
-
 function humanreadable($input) {
-	 
 	$output = "";
 	$input = abs($input);
 	
@@ -69,14 +67,10 @@ function humanreadable($input) {
 	return $output;
 }
 
-
-
-
 $config = \SimpleSAML\Configuration::getInstance();
 
 // Make sure that the user has admin access rights
-SimpleSAML\Utils\Auth::requireAdmin();
-
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 $formats = array(
 	'bytes' => 'humanreadable',
@@ -87,7 +81,7 @@ $formats = array(
 	'uptime' => 'hours',
 );
 
-$statsraw = SimpleSAML_Memcache::getStats();
+$statsraw = \SimpleSAML_Memcache::getStats();
 
 $stats = $statsraw;
 
@@ -101,7 +95,7 @@ foreach($stats AS $key => &$entry) {
 
 }
 
-$t = new SimpleSAML_XHTML_Template($config, 'memcacheMonitor:memcachestat.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'memcacheMonitor:memcachestat.tpl.php');
 $rowTitles = array(
     'accepting_conns' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:accepting_conns}'),
     'auth_cmds' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:auth_cmds}'),
diff --git a/modules/metarefresh/www/fetch.php b/modules/metarefresh/www/fetch.php
index 44d9b110e..ee7b85c87 100644
--- a/modules/metarefresh/www/fetch.php
+++ b/modules/metarefresh/www/fetch.php
@@ -3,20 +3,18 @@
 $config = \SimpleSAML\Configuration::getInstance();
 $mconfig = \SimpleSAML\Configuration::getOptionalConfig('config-metarefresh.php');
 
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
-SimpleSAML\Logger::setCaptureLog(TRUE);
+\SimpleSAML\Logger::setCaptureLog(TRUE);
 
 
 $sets = $mconfig->getConfigList('sets', array());
 
 foreach ($sets AS $setkey => $set) {
 
-	SimpleSAML\Logger::info('[metarefresh]: Executing set [' . $setkey . ']');
+	\SimpleSAML\Logger::info('[metarefresh]: Executing set [' . $setkey . ']');
 
 	try {
-		
-
 		$expireAfter = $set->getInteger('expireAfter', NULL);
 		if ($expireAfter !== NULL) {
 			$expire = time() + $expireAfter;
@@ -63,7 +61,7 @@ foreach ($sets AS $setkey => $set) {
 				$source['whitelist'] = $whitelist;
 			}
 
-			SimpleSAML\Logger::debug('[metarefresh]: In set [' . $setkey . '] loading source ['  . $source['src'] . ']');
+			\SimpleSAML\Logger::debug('[metarefresh]: In set [' . $setkey . '] loading source ['  . $source['src'] . ']');
 			$metaloader->loadSource($source);
 		}
 
@@ -79,16 +77,14 @@ foreach ($sets AS $setkey => $set) {
 				$metaloader->writeMetadataSerialize($outputDir);
 				break;
 		}
-	} catch (Exception $e) {
+	} catch (\Exception $e) {
 		$e = SimpleSAML_Error_Exception::fromException($e);
 		$e->logWarning();
 	}
-	
-
 }
 
-$logentries = SimpleSAML\Logger::getCapturedLog();
+$logentries = \SimpleSAML\Logger::getCapturedLog();
 
-$t = new SimpleSAML_XHTML_Template($config, 'metarefresh:fetch.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'metarefresh:fetch.tpl.php');
 $t->data['logentries'] = $logentries;
 $t->show();
diff --git a/modules/multiauth/www/selectsource.php b/modules/multiauth/www/selectsource.php
index 791db0227..ff743d488 100644
--- a/modules/multiauth/www/selectsource.php
+++ b/modules/multiauth/www/selectsource.php
@@ -12,14 +12,14 @@
 
 // Retrieve the authentication state
 if (!array_key_exists('AuthState', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
 }
 $authStateId = $_REQUEST['AuthState'];
-$state = SimpleSAML_Auth_State::loadState($authStateId, sspmod_multiauth_Auth_Source_MultiAuth::STAGEID);
+$state = \SimpleSAML_Auth_State::loadState($authStateId, sspmod_multiauth_Auth_Source_MultiAuth::STAGEID);
 
 if (array_key_exists("SimpleSAML_Auth_Source.id", $state)) {
 	$authId = $state["SimpleSAML_Auth_Source.id"];
-	$as = SimpleSAML_Auth_Source::getById($authId);
+	$as = \SimpleSAML_Auth_Source::getById($authId);
 } else {
 	$as = NULL;
 }
@@ -39,18 +39,18 @@ if ($source !== NULL) {
 	if ($as !== NULL) {
 		$as->setPreviousSource($source);
 	}
-	sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication($source, $state);
+	\sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication($source, $state);
 }
 
 if (array_key_exists('multiauth:preselect', $state)) {
 	$source = $state['multiauth:preselect'];
-	sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication($source, $state);
+	\sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication($source, $state);
 }
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'multiauth:selectsource.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'multiauth:selectsource.php');
 $t->data['authstate'] = $authStateId;
-$t->data['sources'] = $state[sspmod_multiauth_Auth_Source_MultiAuth::SOURCESID];
+$t->data['sources'] = $state[\sspmod_multiauth_Auth_Source_MultiAuth::SOURCESID];
 if ($as !== NULL) {
 	$t->data['preferred'] = $as->getPreviousSource();
 } else {
diff --git a/modules/negotiate/www/disable.php b/modules/negotiate/www/disable.php
index ba5d7834a..fafe79a06 100644
--- a/modules/negotiate/www/disable.php
+++ b/modules/negotiate/www/disable.php
@@ -18,6 +18,6 @@ $params = array(
 $globalConfig = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 $session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'negotiate:disable.php');
-$t->data['url'] = SimpleSAML\Module::getModuleURL('negotiate/enable.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'negotiate:disable.php');
+$t->data['url'] = \SimpleSAML\Module::getModuleURL('negotiate/enable.php');
 $t->show();
diff --git a/modules/negotiate/www/enable.php b/modules/negotiate/www/enable.php
index 926bb3186..293b7b97c 100644
--- a/modules/negotiate/www/enable.php
+++ b/modules/negotiate/www/enable.php
@@ -17,6 +17,6 @@ $params = array(
 $globalConfig = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 $session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'negotiate:enable.php');
-$t->data['url'] = SimpleSAML\Module::getModuleURL('negotiate/disable.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'negotiate:enable.php');
+$t->data['url'] = \SimpleSAML\Module::getModuleURL('negotiate/disable.php');
 $t->show();
diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php
index 32cf7bb11..1e750d2ed 100644
--- a/modules/oauth/www/registry.edit.php
+++ b/modules/oauth/www/registry.edit.php
@@ -5,7 +5,7 @@ $config = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 $oauthconfig = \SimpleSAML\Configuration::getOptionalConfig('module_oauth.php');
 
-$store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
+$store = new \sspmod_core_Storage_SQLPermanentStorage('oauth');
 
 $authsource = "admin";	// force admin to authenticate as registry maintainer
 $useridattr = $oauthconfig->getValue('useridattr', 'user');
@@ -17,15 +17,15 @@ if ($session->isValid($authsource)) {
 		throw new Exception('User ID is missing');
 	$userid = $attributes[$useridattr][0];
 } else {
-	$as = SimpleSAML_Auth_Source::getById($authsource);
+	$as = \SimpleSAML_Auth_Source::getById($authsource);
 	$as->initLogin(\SimpleSAML\Utils\HTTP::getSelfURL());
 }
 
 function requireOwnership($entry, $userid) {
 	if (!isset($entry['owner']))
-		throw new Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.');
+		throw new \Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.');
 	if ($entry['owner'] !== $userid) 
-		throw new Exception('OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.');
+		throw new \Exception('OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.');
 }
 
 if (array_key_exists('editkey', $_REQUEST)) {
@@ -36,15 +36,13 @@ if (array_key_exists('editkey', $_REQUEST)) {
 } else {
 	$entry = array(
 		'owner' => $userid,
-		'key' => SimpleSAML\Utils\Random::generateID(),
-		'secret' => SimpleSAML\Utils\Random::generateID(),
+		'key' => \SimpleSAML\Utils\Random::generateID(),
+		'secret' => \SimpleSAML\Utils\Random::generateID(),
 	);
 }
 
-
 $editor = new sspmod_oauth_Registry();
 
-
 if (isset($_POST['submit'])) {
 	$editor->checkForm($_POST);
 
@@ -54,7 +52,7 @@ if (isset($_POST['submit'])) {
 
 	$store->set('consumers', $entry['key'], '', $entry);
 	
-	$template = new SimpleSAML_XHTML_Template($config, 'oauth:registry.saved.php');
+	$template = new \SimpleSAML\XHTML\Template($config, 'oauth:registry.saved.php');
 	$template->data['entry'] = $entry;
 	$template->show();
 	exit;
@@ -62,7 +60,7 @@ if (isset($_POST['submit'])) {
 
 $form = $editor->metaToForm($entry);
 
-$template = new SimpleSAML_XHTML_Template($config, 'oauth:registry.edit.tpl.php');
+$template = new \SimpleSAML\XHTML\Template($config, 'oauth:registry.edit.tpl.php');
 $template->data['form'] = $form;
 $template->show();
 
diff --git a/modules/oauth/www/registry.php b/modules/oauth/www/registry.php
index 62b7e3ee8..c13ce18a4 100644
--- a/modules/oauth/www/registry.php
+++ b/modules/oauth/www/registry.php
@@ -5,7 +5,7 @@ $config = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 $oauthconfig = \SimpleSAML\Configuration::getOptionalConfig('module_oauth.php');
 
-$store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
+$store = new \sspmod_core_Storage_SQLPermanentStorage('oauth');
 
 $authsource = "admin";	// force admin to authenticate as registry maintainer
 $useridattr = $oauthconfig->getValue('useridattr', 'user');
@@ -17,7 +17,7 @@ if ($session->isValid($authsource)) {
 		throw new Exception('User ID is missing');
 	$userid = $attributes[$useridattr][0];
 } else {
-	$as = SimpleSAML_Auth_Source::getById($authsource);
+	$as = \SimpleSAML_Auth_Source::getById($authsource);
 	$as->initLogin(\SimpleSAML\Utils\HTTP::getSelfURL());
 }
 
@@ -51,7 +51,7 @@ foreach($list AS $listitem) {
 	$slist['others'][] = $listitem;
 }
 
-$template = new SimpleSAML_XHTML_Template($config, 'oauth:registry.list.php');
+$template = new \SimpleSAML\XHTML\Template($config, 'oauth:registry.list.php');
 $template->data['entries'] = $slist;
 $template->data['userid'] = $userid;
 $template->show();
diff --git a/modules/preprodwarning/www/showwarning.php b/modules/preprodwarning/www/showwarning.php
index 4d5fcf375..77c5e98bc 100644
--- a/modules/preprodwarning/www/showwarning.php
+++ b/modules/preprodwarning/www/showwarning.php
@@ -7,26 +7,26 @@
  * @package SimpleSAMLphp
  */
 
-SimpleSAML\Logger::info('PreProdWarning - Showing warning to user');
+\SimpleSAML\Logger::info('PreProdWarning - Showing warning to user');
 
 if (!array_key_exists('StateId', $_REQUEST)) {
-	throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
+	throw new \SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
 }
 $id = $_REQUEST['StateId'];
-$state = SimpleSAML_Auth_State::loadState($id, 'warning:request');
+$state = \SimpleSAML_Auth_State::loadState($id, 'warning:request');
 
 
 if (array_key_exists('yes', $_REQUEST)) {
 	// The user has pressed the yes-button
 
-	SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
+	\SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
 }
 
 
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
 
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'preprodwarning:warning.php');
-$t->data['yesTarget'] = SimpleSAML\Module::getModuleURL('preprodwarning/showwarning.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'preprodwarning:warning.php');
+$t->data['yesTarget'] = \SimpleSAML\Module::getModuleURL('preprodwarning/showwarning.php');
 $t->data['yesData'] = array('StateId' => $id);
 $t->show();
diff --git a/modules/saml/templates/proxy/invalid_session.php b/modules/saml/templates/proxy/invalid_session.php
index 113137998..94d63f9cd 100644
--- a/modules/saml/templates/proxy/invalid_session.php
+++ b/modules/saml/templates/proxy/invalid_session.php
@@ -2,7 +2,7 @@
 /**
  * Template to ask a user whether to logout because of a reauthentication or not.
  *
- * @var SimpleSAML_XHTML_Template $this
+ * @var \SimpleSAML\XHTML\Template $this
  *
  * @author Jaime PĂ©rez Crespo, UNINETT AS <jaime.perez@uninett.no>
  *
diff --git a/modules/saml/www/disco.php b/modules/saml/www/disco.php
index 1f3bac085..8a229f9f3 100644
--- a/modules/saml/www/disco.php
+++ b/modules/saml/www/disco.php
@@ -4,5 +4,5 @@
  * Built-in IdP discovery service.
  */
 
-$discoHandler = new SimpleSAML_XHTML_IdPDisco(array('saml20-idp-remote', 'shib13-idp-remote'), 'saml');
+$discoHandler = new \impleSAML\XHTML\IdPDisco(array('saml20-idp-remote', 'shib13-idp-remote'), 'saml');
 $discoHandler->handleRequest();
diff --git a/modules/saml/www/proxy/invalid_session.php b/modules/saml/www/proxy/invalid_session.php
index 30616af13..95ba63d9a 100644
--- a/modules/saml/www/proxy/invalid_session.php
+++ b/modules/saml/www/proxy/invalid_session.php
@@ -11,24 +11,24 @@
 
 // retrieve the authentication state
 if (!array_key_exists('AuthState', $_REQUEST)) {
-    throw new SimpleSAML_Error_BadRequest('Missing mandatory parameter: AuthState');
+    throw new \SimpleSAML_Error_BadRequest('Missing mandatory parameter: AuthState');
 }
 
 try {
     // try to get the state
-    $state = SimpleSAML_Auth_State::loadState($_REQUEST['AuthState'], 'saml:proxy:invalid_idp');
-} catch (Exception $e) {
+    $state = \SimpleSAML_Auth_State::loadState($_REQUEST['AuthState'], 'saml:proxy:invalid_idp');
+} catch (\Exception $e) {
     // the user probably hit the back button after starting the logout, try to recover the state with another stage
-    $state = SimpleSAML_Auth_State::loadState($_REQUEST['AuthState'], 'core:Logout:afterbridge');
+    $state = \SimpleSAML_Auth_State::loadState($_REQUEST['AuthState'], 'core:Logout:afterbridge');
 
     // success! Try to continue with reauthentication, since we no longer have a valid session here
-    $idp = SimpleSAML_IdP::getById($state['core:IdP']);
-    sspmod_saml_Auth_Source_SP::reauthPostLogout($idp, $state);
+    $idp = \SimpleSAML_IdP::getById($state['core:IdP']);
+    \sspmod_saml_Auth_Source_SP::reauthPostLogout($idp, $state);
 }
 
 if (isset($_POST['cancel'])) {
     // the user does not want to logout, cancel login
-    SimpleSAML_Auth_State::throwException(
+    \SimpleSAML_Auth_State::throwException(
         $state,
         new \SimpleSAML\Module\saml\Error\NoAvailableIDP(
             \SAML2\Constants::STATUS_RESPONDER,
@@ -39,13 +39,13 @@ if (isset($_POST['cancel'])) {
 
 if (isset($_POST['continue'])) {
     // log the user out before being able to login again
-    $as = SimpleSAML_Auth_Source::getById($state['saml:sp:AuthId'], 'sspmod_saml_Auth_Source_SP');
-    /** @var sspmod_saml_Auth_Source_SP $as */
+    $as = \SimpleSAML_Auth_Source::getById($state['saml:sp:AuthId'], 'sspmod_saml_Auth_Source_SP');
+    /** @var \sspmod_saml_Auth_Source_SP $as */
     $as->reauthLogout($state);
 }
 
 $cfg = \SimpleSAML\Configuration::getInstance();
-$template = new SimpleSAML_XHTML_Template($cfg, 'saml:proxy/invalid_session.php');
+$template = new \SimpleSAML\XHTML\Template($cfg, 'saml:proxy/invalid_session.php');
 $translator = $template->getTranslator();
 $template->data['AuthState'] = (string)$_REQUEST['AuthState'];
 
diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php
index d8d3f7ea1..8fefb13d1 100644
--- a/modules/saml/www/sp/metadata.php
+++ b/modules/saml/www/sp/metadata.php
@@ -1,7 +1,7 @@
 <?php
 
 if (!array_key_exists('PATH_INFO', $_SERVER)) {
-    throw new SimpleSAML_Error_BadRequest('Missing authentication source id in metadata URL');
+    throw new \SimpleSAML_Error_BadRequest('Missing authentication source id in metadata URL');
 }
 
 $config = \SimpleSAML\Configuration::getInstance();
@@ -9,13 +9,13 @@ if ($config->getBoolean('admin.protectmetadata', false)) {
     \SimpleSAML\Utils\Auth::requireAdmin();
 }
 $sourceId = substr($_SERVER['PATH_INFO'], 1);
-$source = SimpleSAML_Auth_Source::getById($sourceId);
+$source = \SimpleSAML_Auth_Source::getById($sourceId);
 if ($source === null) {
-    throw new SimpleSAML_Error_AuthSource($sourceId, 'Could not find authentication source.');
+    throw new \SimpleSAML_Error_AuthSource($sourceId, 'Could not find authentication source.');
 }
 
-if (!($source instanceof sspmod_saml_Auth_Source_SP)) {
-    throw new SimpleSAML_Error_AuthSource($sourceId,
+if (!($source instanceof \sspmod_saml_Auth_Source_SP)) {
+    throw new \SimpleSAML_Error_AuthSource($sourceId,
         'The authentication source is not a SAML Service Provider.');
 }
 
@@ -31,7 +31,7 @@ $slosvcdefault = array(
 );
 
 $slob = $spconfig->getArray('SingleLogoutServiceBinding', $slosvcdefault);
-$slol = SimpleSAML\Module::getModuleURL('saml/sp/saml2-logout.php/'.$sourceId);
+$slol = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-logout.php/'.$sourceId);
 
 foreach ($slob as $binding) {
     if ($binding == \SAML2\Constants::BINDING_SOAP && !($store instanceof \SimpleSAML\Store\SQL)) {
@@ -66,35 +66,35 @@ foreach ($assertionsconsumerservices as $services) {
     switch ($services) {
         case 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST':
             $acsArray['Binding'] = \SAML2\Constants::BINDING_HTTP_POST;
-            $acsArray['Location'] = SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/'.$sourceId);
+            $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/'.$sourceId);
             if (!in_array(\SAML2\Constants::NS_SAMLP, $supported_protocols, true)) {
                 $supported_protocols[] = \SAML2\Constants::NS_SAMLP;
             }
             break;
         case 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post':
             $acsArray['Binding'] = 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post';
-            $acsArray['Location'] = SimpleSAML\Module::getModuleURL('saml/sp/saml1-acs.php/'.$sourceId);
+            $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml1-acs.php/'.$sourceId);
             if (!in_array('urn:oasis:names:tc:SAML:1.1:protocol', $supported_protocols, true)) {
                 $supported_protocols[] = 'urn:oasis:names:tc:SAML:1.1:protocol';
             }
             break;
         case 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact':
             $acsArray['Binding'] = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact';
-            $acsArray['Location'] = SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/'.$sourceId);
+            $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/'.$sourceId);
             if (!in_array(\SAML2\Constants::NS_SAMLP, $supported_protocols, true)) {
                 $supported_protocols[] = \SAML2\Constants::NS_SAMLP;
             }
             break;
         case 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01':
             $acsArray['Binding'] = 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01';
-            $acsArray['Location'] = SimpleSAML\Module::getModuleURL('saml/sp/saml1-acs.php/'.$sourceId.'/artifact');
+            $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml1-acs.php/'.$sourceId.'/artifact');
             if (!in_array('urn:oasis:names:tc:SAML:1.1:protocol', $supported_protocols, true)) {
                 $supported_protocols[] = 'urn:oasis:names:tc:SAML:1.1:protocol';
             }
             break;
         case 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser':
             $acsArray['Binding'] = 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser';
-            $acsArray['Location'] = SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/'.$sourceId);
+            $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/'.$sourceId);
             $acsArray['hoksso:ProtocolBinding'] = \SAML2\Constants::BINDING_HTTP_REDIRECT;
             if (!in_array(\SAML2\Constants::NS_SAMLP, $supported_protocols, true)) {
                 $supported_protocols[] = \SAML2\Constants::NS_SAMLP;
@@ -108,7 +108,7 @@ foreach ($assertionsconsumerservices as $services) {
 $metaArray20['AssertionConsumerService'] = $eps;
 
 $keys = array();
-$certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($spconfig, false, 'new_');
+$certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($spconfig, false, 'new_');
 if ($certInfo !== null && array_key_exists('certData', $certInfo)) {
     $hasNewCert = true;
 
@@ -124,7 +124,7 @@ if ($certInfo !== null && array_key_exists('certData', $certInfo)) {
     $hasNewCert = false;
 }
 
-$certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($spconfig);
+$certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($spconfig);
 if ($certInfo !== null && array_key_exists('certData', $certInfo)) {
     $certData = $certInfo['certData'];
 
@@ -257,11 +257,11 @@ if (isset($metaArray20['attributes']) && is_array($metaArray20['attributes'])) {
 }
 
 // sign the metadata if enabled
-$xml = SimpleSAML_Metadata_Signer::sign($xml, $spconfig->toArray(), 'SAML 2 SP');
+$xml = \SimpleSAML_Metadata_Signer::sign($xml, $spconfig->toArray(), 'SAML 2 SP');
 
 if (array_key_exists('output', $_REQUEST) && $_REQUEST['output'] == 'xhtml') {
 
-    $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin');
+    $t = new \SimpleSAML\XHTML\Template($config, 'metadata.php', 'admin');
 
     $t->data['clipboard.js'] = true;
     $t->data['header'] = 'saml20-sp'; // TODO: Replace with headerString in 2.0
diff --git a/modules/saml/www/sp/wrong_authncontextclassref.php b/modules/saml/www/sp/wrong_authncontextclassref.php
index 490a86a40..9cb93bf70 100644
--- a/modules/saml/www/sp/wrong_authncontextclassref.php
+++ b/modules/saml/www/sp/wrong_authncontextclassref.php
@@ -1,5 +1,5 @@
 <?php
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$t = new SimpleSAML_XHTML_Template($globalConfig, 'saml:sp/wrong_authncontextclassref.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($globalConfig, 'saml:sp/wrong_authncontextclassref.tpl.php');
 $t->show();
diff --git a/modules/sanitycheck/www/index.php b/modules/sanitycheck/www/index.php
index 55f70198f..d7302529e 100644
--- a/modules/sanitycheck/www/index.php
+++ b/modules/sanitycheck/www/index.php
@@ -8,7 +8,7 @@ $hookinfo = array(
     'info' => &$info,
     'errors' => &$errors,
 );
-SimpleSAML\Module::callHooks('sanitycheck', $hookinfo);
+\SimpleSAML\Module::callHooks('sanitycheck', $hookinfo);
 
 if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'text') {
 
@@ -20,7 +20,7 @@ if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'text') {
     exit;
 }
 
-$t = new SimpleSAML_XHTML_Template($config, 'sanitycheck:check.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'sanitycheck:check.tpl.php');
 $t->data['pageid'] = 'sanitycheck';
 $t->data['errors'] = $errors;
 $t->data['info'] = $info;
diff --git a/modules/statistics/lib/StatDataset.php b/modules/statistics/lib/StatDataset.php
index ac56cfc7e..993cf3eff 100644
--- a/modules/statistics/lib/StatDataset.php
+++ b/modules/statistics/lib/StatDataset.php
@@ -5,6 +5,7 @@
  * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no>
  * @package SimpleSAMLphp
  */
+
 class sspmod_statistics_StatDataset
 {
     protected $statconfig;
@@ -44,9 +45,9 @@ class sspmod_statistics_StatDataset
         $this->delimiter = '_';
         $this->max = 0;
 
-        $this->datehandlerTick = new sspmod_statistics_DateHandler($this->statconfig->getValue('offset', 0));
+        $this->datehandlerTick = new \sspmod_statistics_DateHandler($this->statconfig->getValue('offset', 0));
         if ($this->timeresconfig->getValue('customDateHandler', 'default') === 'month') {
-            $this->datehandlerFile = new sspmod_statistics_DateHandlerMonth(0);
+            $this->datehandlerFile = new \sspmod_statistics_DateHandlerMonth(0);
         } else {
             $this->datehandlerFile = $this->datehandlerTick;
         }
@@ -233,19 +234,19 @@ class sspmod_statistics_StatDataset
     public function getDelimiterPresentation()
     {
         $config = \SimpleSAML\Configuration::getInstance();
-        $t = new SimpleSAML_XHTML_Template($config, 'statistics:statistics.tpl.php');
+        $t = new \SimpleSAML\XHTML\Template($config, 'statistics:statistics.tpl.php');
 
         $availdelimiters = $this->availDelimiters();
 
         // create a delimiter presentation filter for this rule...
         if ($this->ruleconfig->hasValue('fieldPresentation')) {
             $fieldpresConfig = $this->ruleconfig->getConfigItem('fieldPresentation');
-            $classname = SimpleSAML\Module::resolveClass(
+            $classname = \SimpleSAML\Module::resolveClass(
                 $fieldpresConfig->getValue('class'),
                 'Statistics_FieldPresentation'
             );
             if (!class_exists($classname)) {
-                throw new Exception('Could not find field presentation plugin ['.$classname.']: No class found');
+                throw new \Exception('Could not find field presentation plugin ['.$classname.']: No class found');
             }
             $presentationHandler = new $classname($availdelimiters, $fieldpresConfig->getValue('config'), $t);
 
@@ -276,20 +277,20 @@ class sspmod_statistics_StatDataset
     {
         $statdir = $this->statconfig->getValue('statdir');
         $resarray = array();
-        $rules = SimpleSAML\Utils\Arrays::arrayize($this->ruleid);
+        $rules = \SimpleSAML\Utils\Arrays::arrayize($this->ruleid);
         foreach ($rules as $rule) {
             // Get file and extract results.
             $resultFileName = $statdir.'/'.$rule.'-'.$this->timeres.'-'.$this->fileslot.'.stat';
             if (!file_exists($resultFileName)) {
-                throw new Exception('Aggregated statitics file ['.$resultFileName.'] not found.');
+                throw new \Exception('Aggregated statitics file ['.$resultFileName.'] not found.');
             }
             if (!is_readable($resultFileName)) {
-                throw new Exception('Could not read statitics file ['.$resultFileName.']. Bad file permissions?');
+                throw new \Exception('Could not read statitics file ['.$resultFileName.']. Bad file permissions?');
             }
             $resultfile = file_get_contents($resultFileName);
             $newres = unserialize($resultfile);
             if (empty($newres)) {
-                throw new Exception('Aggregated statistics in file ['.$resultFileName.'] was empty.');
+                throw new \Exception('Aggregated statistics in file ['.$resultFileName.'] was empty.');
             }
             $resarray[] = $newres;
         }
diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php
index 7dc2448ba..a7eeeeca0 100644
--- a/modules/statistics/www/showstats.php
+++ b/modules/statistics/www/showstats.php
@@ -4,7 +4,7 @@ $config = \SimpleSAML\Configuration::getInstance();
 $statconfig = \SimpleSAML\Configuration::getConfig('module_statistics.php');
 $session = \SimpleSAML\Session::getSessionFromRequest();
 
-sspmod_statistics_AccessCheck::checkAccess($statconfig);
+\sspmod_statistics_AccessCheck::checkAccess($statconfig);
 
 /*
  * Check input parameters
@@ -38,11 +38,11 @@ if ($preferRule2 === '_') {
 /*
  * Create statistics data.
  */
-$ruleset = new sspmod_statistics_Ruleset($statconfig);
+$ruleset = new \sspmod_statistics_Ruleset($statconfig);
 $statrule = $ruleset->getRule($preferRule);
 $rule = $statrule->getRuleID();
 
-$t = new SimpleSAML_XHTML_Template($config, 'statistics:statistics.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'statistics:statistics.tpl.php');
 $t->data['pageid'] = 'statistics';
 $t->data['header'] = 'stat';
 $t->data['available.rules'] = $ruleset->availableRulesNames();
@@ -66,7 +66,7 @@ try {
         }
         exit;
     }
-} catch (Exception $e) {
+} catch (\Exception $e) {
     $t->data['error'] = "No data available";
     $t->show();
     exit;
@@ -100,7 +100,7 @@ if (isset($preferRule2)) {
 
         $datasets[] = $dataset2->getPercentValues();
         $maxes[] = $dataset2->getMax();
-    } catch (Exception $e) {
+    } catch (\Exception $e) {
         $t->data['error'] = "No data available to compare";
         $t->show();
         exit;
@@ -109,7 +109,7 @@ if (isset($preferRule2)) {
 
 $dimx = $statconfig->getValue('dimension.x', 800);
 $dimy = $statconfig->getValue('dimension.y', 350);
-$grapher = new sspmod_statistics_Graph_GoogleCharts($dimx, $dimy);
+$grapher = new \sspmod_statistics_Graph_GoogleCharts($dimx, $dimy);
 
 $t->data['imgurl'] = $grapher->show($axis['axis'], $axis['axispos'], $datasets, $maxes);
 if (isset($piedata)) {
@@ -166,7 +166,7 @@ function getBaseURL($t, $type = 'get', $key = null, $value = null)
     }
 
     if ($type === 'get') {
-        return SimpleSAML\Module::getModuleURL("statistics/showstats.php").'?'.http_build_query($vars, '', '&amp;');
+        return \SimpleSAML\Module::getModuleURL("statistics/showstats.php").'?'.http_build_query($vars, '', '&amp;');
     } else {
         $text = '';
         foreach ($vars as $k => $v) {
diff --git a/modules/statistics/www/statmeta.php b/modules/statistics/www/statmeta.php
index 60c51db4c..65910d820 100644
--- a/modules/statistics/www/statmeta.php
+++ b/modules/statistics/www/statmeta.php
@@ -3,13 +3,13 @@
 $config = \SimpleSAML\Configuration::getInstance();
 $statconfig = \SimpleSAML\Configuration::getConfig('module_statistics.php');
 
-sspmod_statistics_AccessCheck::checkAccess($statconfig);
+\sspmod_statistics_AccessCheck::checkAccess($statconfig);
 
 $aggr = new sspmod_statistics_Aggregator();
 $aggr->loadMetadata();
 $metadata = $aggr->getMetadata();
 
-$t = new SimpleSAML_XHTML_Template($config, 'statistics:statmeta.tpl.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'statistics:statmeta.tpl.php');
 
 if ($metadata !== null) {
     if (in_array('lastrun', $metadata, true)) {
diff --git a/templates/includes/attributes.php b/templates/includes/attributes.php
index 79aae3130..98e6abe31 100644
--- a/templates/includes/attributes.php
+++ b/templates/includes/attributes.php
@@ -51,7 +51,7 @@ function present_eptid(\SimpleSAML\Locale\Translate $t, \SAML2\XML\saml\NameID $
     return '<td class="attrvalue">'.present_assoc($eptid);
 }
 
-function present_attributes(SimpleSAML_XHTML_Template $t, $attributes, $nameParent)
+function present_attributes(\SimpleSAML\XHTML\Template $t, $attributes, $nameParent)
 {
     $alternate = array('odd', 'even');
     $i = 0;
@@ -100,11 +100,11 @@ function present_attributes(SimpleSAML_XHTML_Template $t, $attributes, $namePare
                         '" /></td></tr>';
                 } elseif (is_a($value[0], 'DOMNodeList')) {
                     // try to see if we have a NameID here
-                    /** @var DOMNodeList $value [0] */
+                    /** @var \DOMNodeList $value [0] */
                     $n = $value[0]->length;
                     for ($idx = 0; $idx < $n; $idx++) {
                         $elem = $value[0]->item($idx);
-                        /* @var DOMElement $elem */
+                        /* @var \DOMElement $elem */
                         if (!($elem->localName === 'NameID' && $elem->namespaceURI === \SAML2\Constants::NS_SAML)) {
                             continue;
                         }
diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php
index a007aa793..3b24bf531 100644
--- a/www/admin/hostnames.php
+++ b/www/admin/hostnames.php
@@ -7,7 +7,7 @@ $config = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists..
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 $attributes = array();
 
@@ -25,7 +25,7 @@ $attributes['getSelfHostWithPath()'] = array(\SimpleSAML\Utils\HTTP::getSelfHost
 $attributes['getFirstPathElement()'] = array(\SimpleSAML\Utils\HTTP::getFirstPathElement());
 $attributes['selfURL()'] = array(\SimpleSAML\Utils\HTTP::getSelfURL());
 
-$template = new SimpleSAML_XHTML_Template($config, 'hostnames.php');
+$template = new \SimpleSAML\XHTML\Template($config, 'hostnames.php');
 
 $template->data['remaining']  = $session->getAuthData('admin', 'Expire') - time();
 $template->data['attributes'] = $attributes;
diff --git a/www/admin/index.php b/www/admin/index.php
index 8dde15c9e..28bec413b 100644
--- a/www/admin/index.php
+++ b/www/admin/index.php
@@ -7,7 +7,7 @@ $config = \SimpleSAML\Configuration::getInstance();
 $session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists..
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 $adminpages = array(
     'hostnames.php' => 'Diagnostics on hostname, port and protocol',
@@ -16,7 +16,7 @@ $adminpages = array(
     'sandbox.php' => 'Sandbox for testing changes to layout and css',
 );
 
-$template = new SimpleSAML_XHTML_Template($config, 'index.php');
+$template = new \SimpleSAML\XHTML\Template($config, 'index.php');
 
 $template->data['pagetitle'] = 'Admin';
 $template->data['adminpages'] = $adminpages;
diff --git a/www/admin/metadata-converter.php b/www/admin/metadata-converter.php
index 9a20e0046..7fba906da 100644
--- a/www/admin/metadata-converter.php
+++ b/www/admin/metadata-converter.php
@@ -3,7 +3,7 @@
 require_once('../_include.php');
 
 // make sure that the user has admin access rights
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 $config = \SimpleSAML\Configuration::getInstance();
 
@@ -15,7 +15,7 @@ if (!empty($_FILES['xmlfile']['tmp_name'])) {
 
 if (!empty($xmldata)) {
     \SimpleSAML\Utils\XML::checkSAMLMessage($xmldata, 'saml-meta');
-    $entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsString($xmldata);
+    $entities = \SimpleSAML_Metadata_SAMLParser::parseDescriptorsString($xmldata);
 
     // get all metadata for the entities
     foreach ($entities as &$entity) {
@@ -28,7 +28,7 @@ if (!empty($xmldata)) {
     }
 
     // transpose from $entities[entityid][type] to $output[type][entityid]
-    $output = SimpleSAML\Utils\Arrays::transpose($entities);
+    $output = \SimpleSAML\Utils\Arrays::transpose($entities);
 
     // merge all metadata of each type to a single string which should be added to the corresponding file
     foreach ($output as $type => &$entities) {
@@ -52,7 +52,7 @@ if (!empty($xmldata)) {
     $output = array();
 }
 
-$template = new SimpleSAML_XHTML_Template($config, 'metadata-converter.php', 'admin');
+$template = new \SimpleSAML\XHTML\Template($config, 'metadata-converter.php', 'admin');
 $template->data['clipboard.js'] = true;
 $template->data['xmldata'] = $xmldata;
 $template->data['output'] = $output;
diff --git a/www/admin/sandbox.php b/www/admin/sandbox.php
index 2f000536b..e15d02fd7 100644
--- a/www/admin/sandbox.php
+++ b/www/admin/sandbox.php
@@ -9,7 +9,7 @@ $session = \SimpleSAML\Session::getSessionFromRequest();
 // Check if valid local session exists..
 //SimpleSAML\Utils\Auth::requireAdmin();
 
-$template = new SimpleSAML_XHTML_Template($config, 'sandbox.php');
+$template = new \SimpleSAML\XHTML\Template($config, 'sandbox.php');
 
 $template->data['pagetitle'] = 'Sandbox';
 $template->data['sometext'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.';
diff --git a/www/errorreport.php b/www/errorreport.php
index c03eb8d1e..f04eb9eac 100644
--- a/www/errorreport.php
+++ b/www/errorreport.php
@@ -8,7 +8,7 @@ $config = \SimpleSAML\Configuration::getInstance();
 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
     // the message has been sent. Show error report page
 
-    $t = new SimpleSAML_XHTML_Template($config, 'errorreport.php', 'errors');
+    $t = new \SimpleSAML\XHTML\Template($config, 'errorreport.php', 'errors');
     $t->show();
     exit;
 }
@@ -21,8 +21,8 @@ $data = null;
 try {
     $session = \SimpleSAML\Session::getSessionFromRequest();
     $data = $session->getData('core:errorreport', $reportId);
-} catch (Exception $e) {
-    SimpleSAML\Logger::error('Error loading error report data: '.var_export($e->getMessage(), true));
+} catch (\Exception $e) {
+    \SimpleSAML\Logger::error('Error loading error report data: '.var_export($e->getMessage(), true));
 }
 
 if ($data === null) {
@@ -121,7 +121,7 @@ if ($from === 'no-reply@example.org' && $replyto !== null) {
 // send the email
 $toAddress = $config->getString('technicalcontact_email', 'na@example.org');
 if ($config->getBoolean('errorreporting', true) && $toAddress !== 'na@example.org') {
-    $email = new SimpleSAML_XHTML_EMail($toAddress, 'SimpleSAMLphp error report', $from);
+    $email = new \SimpleSAML\XHTML\EMail($toAddress, 'SimpleSAMLphp error report', $from);
     $email->setBody($message);
     $email->send();
     SimpleSAML\Logger::error('Report with id '.$reportId.' sent to <'.$toAddress.'>.');
diff --git a/www/logout.php b/www/logout.php
index 97d4a7fec..97c7d2b41 100644
--- a/www/logout.php
+++ b/www/logout.php
@@ -16,7 +16,7 @@ if (array_key_exists('link_text', $_REQUEST)) {
     $text = '{logout:default_link_text}';
 }
 
-$t = new SimpleSAML_XHTML_Template($config, 'logout.php');
+$t = new \SimpleSAML\XHTML\Template($config, 'logout.php');
 $t->data['link'] = $link;
 $t->data['text'] = $text;
 $t->show();
diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php
index d68e8473a..5b2c3d3be 100644
--- a/www/saml2/idp/metadata.php
+++ b/www/saml2/idp/metadata.php
@@ -8,9 +8,9 @@ use SimpleSAML\Utils\Crypto as Crypto;
 use SimpleSAML\Utils\HTTP as HTTP;
 use SimpleSAML\Utils\Config\Metadata as Metadata;
 
-// load SimpleSAMLphp, configuration and metadata
+// load SimpleSAMLphp configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
-$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
+$metadata = \SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 if (!$config->getBoolean('enable.saml20-idp', false)) {
     throw new SimpleSAML_Error_Error('NOACCESS');
@@ -148,7 +148,7 @@ try {
         );
 
         if (!$idpmeta->hasValue('OrganizationURL')) {
-            throw new SimpleSAML_Error_Exception('If OrganizationName is set, OrganizationURL must also be set.');
+            throw new \SimpleSAML_Error_Exception('If OrganizationName is set, OrganizationURL must also be set.');
         }
         $metaArray['OrganizationURL'] = $idpmeta->getLocalizedString('OrganizationURL');
     }
@@ -210,12 +210,12 @@ try {
     $metaflat = '$metadata['.var_export($idpentityid, true).'] = '.var_export($metaArray, true).';';
 
     // sign the metadata if enabled
-    $metaxml = SimpleSAML_Metadata_Signer::sign($metaxml, $idpmeta->toArray(), 'SAML 2 IdP');
+    $metaxml = \SimpleSAML_Metadata_Signer::sign($metaxml, $idpmeta->toArray(), 'SAML 2 IdP');
 
     if (array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml') {
         $defaultidp = $config->getString('default-saml20-idp', null);
 
-        $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin');
+        $t = new \SimpleSAML\XHTML\Template($config, 'metadata.php', 'admin');
 
         $t->data['clipboard.js'] = true;
         $t->data['available_certs'] = $availableCerts;
@@ -234,5 +234,5 @@ try {
         exit(0);
     }
 } catch (Exception $exception) {
-    throw new SimpleSAML_Error_Error('METADATA', $exception);
+    throw new \SimpleSAML_Error_Error('METADATA', $exception);
 }
diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php
index d580e2d40..9b94da9ed 100644
--- a/www/shib13/idp/metadata.php
+++ b/www/shib13/idp/metadata.php
@@ -4,15 +4,15 @@ require_once('../../_include.php');
 
 // load configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
-$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
+$metadata = \SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 if (!$config->getBoolean('enable.shib13-idp', false)) {
-    throw new SimpleSAML_Error_Error('NOACCESS');
+    throw new \SimpleSAML_Error_Error('NOACCESS');
 }
 
 // check if valid local session exists
 if ($config->getBoolean('admin.protectmetadata', false)) {
-    SimpleSAML\Utils\Auth::requireAdmin();
+    \SimpleSAML\Utils\Auth::requireAdmin();
 }
 
 try {
@@ -22,7 +22,7 @@ try {
     $idpmeta = $metadata->getMetaDataConfig($idpentityid, 'shib13-idp-hosted');
 
     $keys = array();
-    $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, false, 'new_');
+    $certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, false, 'new_');
     if ($certInfo !== null) {
         $keys[] = array(
             'type'            => 'X509Certificate',
@@ -32,7 +32,7 @@ try {
         );
     }
 
-    $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, true);
+    $certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, true);
     $keys[] = array(
         'type'            => 'X509Certificate',
         'signing'         => true,
@@ -62,12 +62,11 @@ try {
         );
 
         if (!$idpmeta->hasValue('OrganizationURL')) {
-            throw new SimpleSAML_Error_Exception('If OrganizationName is set, OrganizationURL must also be set.');
+            throw new \SimpleSAML_Error_Exception('If OrganizationName is set, OrganizationURL must also be set.');
         }
         $metaArray['OrganizationURL'] = $idpmeta->getLocalizedString('OrganizationURL');
     }
 
-
     $metaflat = '$metadata['.var_export($idpentityid, true).'] = '.var_export($metaArray, true).';';
 
     $metaBuilder = new \SimpleSAML\Metadata\SAMLBuilder($idpentityid);
@@ -81,13 +80,12 @@ try {
     $metaxml = $metaBuilder->getEntityDescriptorText();
 
     // sign the metadata if enabled
-    $metaxml = SimpleSAML_Metadata_Signer::sign($metaxml, $idpmeta->toArray(), 'Shib 1.3 IdP');
-
+    $metaxml = \SimpleSAML_Metadata_Signer::sign($metaxml, $idpmeta->toArray(), 'Shib 1.3 IdP');
 
     if (array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml') {
         $defaultidp = $config->getString('default-shib13-idp', null);
 
-        $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin');
+        $t = new \SimpleSAML\XHTML\Template($config, 'metadata.php', 'admin');
 
         $t->data['clipboard.js'] = true;
         $t->data['header'] = 'shib13-idp'; // TODO: Replace with headerString in 2.0
@@ -107,6 +105,6 @@ try {
         echo $metaxml;
         exit(0);
     }
-} catch (Exception $exception) {
-    throw new SimpleSAML_Error_Error('METADATA', $exception);
+} catch (\Exception $exception) {
+    throw new \SimpleSAML_Error_Error('METADATA', $exception);
 }
-- 
GitLab