From 33de7bd3dd9cc52eef9b322c3adbf25bf3436ab8 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Tue, 29 May 2018 22:48:05 +0200
Subject: [PATCH] Replace SimpleSAML_Session with namespaced version

---
 docs/simplesamlphp-advancedfeatures.md        |   4 +-
 docs/simplesamlphp-maintenance.md             |   2 +-
 docs/simplesamlphp-sp.md                      |   2 +-
 lib/SimpleSAML/Auth/Default.php               |   5 +-
 lib/SimpleSAML/Auth/Simple.php                |   6 +-
 lib/SimpleSAML/Auth/Source.php                |  13 +-
 lib/SimpleSAML/Auth/State.php                 |   9 +-
 lib/SimpleSAML/Error/Error.php                |   4 +-
 lib/SimpleSAML/IdP.php                        |  16 +-
 lib/SimpleSAML/Logger.php                     |   5 +-
 lib/SimpleSAML/Session.php                    | 137 +++++++++---------
 lib/SimpleSAML/SessionHandler.php             |   8 +-
 lib/SimpleSAML/SessionHandlerCookie.php       |   2 +-
 lib/SimpleSAML/SessionHandlerPHP.php          |  10 +-
 lib/SimpleSAML/SessionHandlerStore.php        |   8 +-
 lib/SimpleSAML/Utilities.php                  |   2 +-
 lib/SimpleSAML/Utils/Auth.php                 |   2 +-
 lib/SimpleSAML/Utils/HTTP.php                 |  13 +-
 lib/SimpleSAML/XHTML/IdPDisco.php             |   4 +-
 .../lib/Auth/Process/ExtendIdPSession.php     |   2 +-
 modules/core/www/cardinality_error.php        |   2 +-
 modules/core/www/frontpage_auth.php           |   2 +-
 modules/core/www/frontpage_config.php         |   2 +-
 modules/core/www/frontpage_federation.php     |   2 +-
 modules/core/www/frontpage_welcome.php        |   2 +-
 modules/core/www/postredirect.php             |   4 +-
 modules/core/www/short_sso_interval.php       |   2 +-
 modules/core/www/show_metadata.php            |   2 +-
 modules/cron/www/croninfo.php                 |   2 +-
 .../multiauth/lib/Auth/Source/MultiAuth.php   |   6 +-
 .../negotiate/lib/Auth/Source/Negotiate.php   |   4 +-
 modules/negotiate/www/disable.php             |   2 +-
 modules/negotiate/www/enable.php              |   2 +-
 modules/negotiate/www/retry.php               |   2 +-
 modules/oauth/www/registry.edit.php           |   2 +-
 modules/oauth/www/registry.php                |   2 +-
 modules/saml/lib/Auth/Source/SP.php           |   6 +-
 modules/saml/lib/SP/LogoutStore.php           |   4 +-
 modules/saml/www/sp/saml2-acs.php             |   2 +-
 modules/statistics/www/showstats.php          |   2 +-
 www/admin/hostnames.php                       |   2 +-
 www/admin/index.php                           |   2 +-
 www/admin/metadata-converter.php              |   1 +
 www/admin/phpinfo.php                         |   2 +-
 www/admin/sandbox.php                         |   2 +-
 www/authmemcookie.php                         |   2 +-
 www/errorreport.php                           |   2 +-
 47 files changed, 161 insertions(+), 160 deletions(-)

diff --git a/docs/simplesamlphp-advancedfeatures.md b/docs/simplesamlphp-advancedfeatures.md
index 5bf8d163a..adb7c2486 100644
--- a/docs/simplesamlphp-advancedfeatures.md
+++ b/docs/simplesamlphp-advancedfeatures.md
@@ -127,7 +127,7 @@ Example code for the function with GeoIP country check:
         }
 
         if ($init) {
-            $session->setData($data_type, $data_key, $remote_addr, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
+            $session->setData($data_type, $data_key, $remote_addr, \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END);
             return;
         }
 
@@ -147,7 +147,7 @@ Example code for the function with GeoIP country check:
 
         if ($country_a === $country_b) {
             if ($stored_remote_addr !== $remote_addr) {
-                $session->setData($data_type, $data_key, $remote_addr, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
+                $session->setData($data_type, $data_key, $remote_addr, \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END);
             }
 
             return TRUE;
diff --git a/docs/simplesamlphp-maintenance.md b/docs/simplesamlphp-maintenance.md
index ab38566e9..02e43b4f6 100644
--- a/docs/simplesamlphp-maintenance.md
+++ b/docs/simplesamlphp-maintenance.md
@@ -52,7 +52,7 @@ SimpleSAMLphp as an Identity Provider, or any other applications using it are no
 settings by leaving these options unset or setting them to `null`.
 
 If you need to restore your session's application after calling SimpleSAMLphp, you can do it by calling the `cleanup()` method of the
-`SimpleSAML_Session` class, like described [here](simplesamlphp-sp#section_6).
+`\SimpleSAML\Session` class, like described [here](simplesamlphp-sp#section_6).
 
 ### Configuring memcache
 
diff --git a/docs/simplesamlphp-sp.md b/docs/simplesamlphp-sp.md
index dd50adab9..453b9b525 100644
--- a/docs/simplesamlphp-sp.md
+++ b/docs/simplesamlphp-sp.md
@@ -191,7 +191,7 @@ If we are using PHP sessions in SimpleSAMLphp and in the application we are prot
 existing session when invoked for the first time, and its own session will prevail afterwards. If you want to restore
 your own session after calling SimpleSAMLphp, you can do so by cleaning up the session like this:
 
-    $session = SimpleSAML_Session::getSessionFromRequest();
+    $session = \SimpleSAML\Session::getSessionFromRequest();
     $session->cleanup();
 
 If you don't cleanup SimpleSAMLphp's session and try to use $_SESSION afterwards, you won't be using your own session
diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php
index 17ad9c38e..e50959bfa 100644
--- a/lib/SimpleSAML/Auth/Default.php
+++ b/lib/SimpleSAML/Auth/Default.php
@@ -11,10 +11,9 @@
  *
  * @deprecated This class will be removed in SSP 2.0.
  */
+
 class SimpleSAML_Auth_Default
 {
-
-
     /**
      * @deprecated This method will be removed in SSP 2.0. Use SimpleSAML_Auth_Source::initLogin() instead.
      */
@@ -58,7 +57,7 @@ class SimpleSAML_Auth_Default
         assert(is_string($returnURL));
         assert(is_string($authority));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
 
         $state = $session->getAuthData($authority, 'LogoutState');
         $session->doLogout($authority);
diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index bdc0871ac..8c464778a 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -7,7 +7,7 @@ use \SimpleSAML_Auth_State as State;
 use \SimpleSAML\Configuration;
 use \SimpleSAML_Error_AuthSource as AuthSourceError;
 use \SimpleSAML\Module;
-use \SimpleSAML_Session as Session;
+use \SimpleSAML\Session;
 use \SimpleSAML\Utils\HTTP;
 
 /**
@@ -15,9 +15,9 @@ use \SimpleSAML\Utils\HTTP;
  *
  * @package SimpleSAMLphp
  */
+
 class Simple
 {
-
     /**
      * The id of the authentication source we are accessing.
      *
@@ -242,7 +242,7 @@ class Simple
                 $stateID = State::saveState($state, $state['ReturnStateStage']);
                 $params[$state['ReturnStateParam']] = $stateID;
             }
-            \SimpleSAML\Utils\HTTP::redirectTrustedURL($state['ReturnTo'], $params);
+            HTTP::redirectTrustedURL($state['ReturnTo'], $params);
         }
     }
 
diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php
index 1efb0fae5..e1f4043d2 100644
--- a/lib/SimpleSAML/Auth/Source.php
+++ b/lib/SimpleSAML/Auth/Source.php
@@ -10,6 +10,7 @@ use SimpleSAML\Auth\SourceFactory;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
+
 abstract class SimpleSAML_Auth_Source
 {
     /**
@@ -114,7 +115,7 @@ abstract class SimpleSAML_Auth_Source
         assert(isset($state['ReturnCallback']));
 
         // the default implementation just copies over the previous authentication data
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $data = $session->getAuthState($this->authId);
         foreach ($data as $k => $v) {
             $state[$k] = $v;
@@ -218,7 +219,7 @@ abstract class SimpleSAML_Auth_Source
         $return = $state['SimpleSAML_Auth_Source.Return'];
 
         // save session state
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $authId = $state['SimpleSAML_Auth_Source.id'];
         $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
 
@@ -381,7 +382,7 @@ abstract class SimpleSAML_Auth_Source
 
         $source = $state['SimpleSAML_Auth_Source.logoutSource'];
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         if (!$session->isValid($source)) {
             SimpleSAML\Logger::warning(
                 'Received logout from an invalid authentication source '.
@@ -430,12 +431,12 @@ abstract class SimpleSAML_Auth_Source
             'state'    => $callbackState,
         );
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->setData(
             'SimpleSAML_Auth_Source.LogoutCallbacks',
             $id,
             $data,
-            SimpleSAML_Session::DATA_TIMEOUT_SESSION_END
+            \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END
         );
     }
 
@@ -456,7 +457,7 @@ abstract class SimpleSAML_Auth_Source
 
         $id = strlen($this->authId).':'.$this->authId.$assoc;
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
 
         $data = $session->getData('SimpleSAML_Auth_Source.LogoutCallbacks', $id);
         if ($data === null) {
diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php
index 0e6d451e5..ff9014815 100644
--- a/lib/SimpleSAML/Auth/State.php
+++ b/lib/SimpleSAML/Auth/State.php
@@ -1,6 +1,5 @@
 <?php
 
-
 /**
  * This is a helper class for saving and loading state information.
  *
@@ -30,8 +29,6 @@
  */
 class SimpleSAML_Auth_State
 {
-
-
     /**
      * The index in the state array which contains the identifier.
      */
@@ -205,7 +202,7 @@ class SimpleSAML_Auth_State
 
         // Save state
         $serializedState = serialize($state);
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->setData('SimpleSAML_Auth_State', $id, $serializedState, self::getStateTimeout());
 
         SimpleSAML\Logger::debug('Saved state: '.var_export($return, true));
@@ -265,7 +262,7 @@ class SimpleSAML_Auth_State
 
         $sid = self::parseStateID($id);
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $state = $session->getData('SimpleSAML_Auth_State', $sid['id']);
 
         if ($state === null) {
@@ -327,7 +324,7 @@ class SimpleSAML_Auth_State
 
         SimpleSAML\Logger::debug('Deleting state: '.var_export($state[self::ID], true));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->deleteData('SimpleSAML_Auth_State', $state[self::ID]);
     }
 
diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index b192935d9..aceac89f9 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -205,7 +205,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception
         SimpleSAML\Logger::error('Error report with id '.$reportId.' generated.');
 
         $config = \SimpleSAML\Configuration::getInstance();
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
 
         if (isset($_SERVER['HTTP_REFERER'])) {
             $referer = $_SERVER['HTTP_REFERER'];
@@ -268,7 +268,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception
         }
 
         $data['email'] = '';
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $authorities = $session->getAuthorities();
         foreach ($authorities as $authority) {
             $attributes = $session->getAuthData($authority, 'Attributes');
diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php
index fc5abfc72..5fd3f41d9 100644
--- a/lib/SimpleSAML/IdP.php
+++ b/lib/SimpleSAML/IdP.php
@@ -216,7 +216,7 @@ class SimpleSAML_IdP
 
         $association['core:IdP'] = $this->id;
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->addAssociation($this->associationGroup, $association);
     }
 
@@ -228,7 +228,7 @@ class SimpleSAML_IdP
      */
     public function getAssociations()
     {
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         return $session->getAssociations($this->associationGroup);
     }
 
@@ -242,7 +242,7 @@ class SimpleSAML_IdP
     {
         assert(is_string($assocId));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->terminateAssociation($this->associationGroup, $assocId);
     }
 
@@ -268,12 +268,12 @@ class SimpleSAML_IdP
         assert(is_callable($state['Responder']));
 
         if (isset($state['core:SP'])) {
-            $session = SimpleSAML_Session::getSessionFromRequest();
+            $session = \SimpleSAML\Session::getSessionFromRequest();
             $session->setData(
                 'core:idp-ssotime',
                 $state['core:IdP'].';'.$state['core:SP'],
                 time(),
-                SimpleSAML_Session::DATA_TIMEOUT_SESSION_END
+                \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END
             );
         }
 
@@ -306,7 +306,7 @@ class SimpleSAML_IdP
         }
 
         if (isset($state['core:SP'])) {
-            $session = SimpleSAML_Session::getSessionFromRequest();
+            $session = \SimpleSAML\Session::getSessionFromRequest();
             $previousSSOTime = $session->getData('core:idp-ssotime', $state['core:IdP'].';'.$state['core:SP']);
             if ($previousSSOTime !== null) {
                 $state['PreviousSSOTimestamp'] = $previousSSOTime;
@@ -479,7 +479,7 @@ class SimpleSAML_IdP
 
         if ($assocId !== null) {
             $this->terminateAssociation($assocId);
-            $session = SimpleSAML_Session::getSessionFromRequest();
+            $session = \SimpleSAML\Session::getSessionFromRequest();
             $session->deleteData('core:idp-ssotime', $this->id.':'.$state['saml:SPEntityId']);
         }
 
@@ -509,7 +509,7 @@ class SimpleSAML_IdP
         assert(is_string($assocId));
         assert(is_string($relayState) || $relayState === null);
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->deleteData('core:idp-ssotime', $this->id.';'.substr($assocId, strpos($assocId, ':') + 1));
 
         $handler = $this->getLogoutHandler();
diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php
index f98451de3..3c569a1fa 100644
--- a/lib/SimpleSAML/Logger.php
+++ b/lib/SimpleSAML/Logger.php
@@ -12,7 +12,6 @@ namespace SimpleSAML;
  */
 class Logger
 {
-
     /**
      * @var \SimpleSAML\Logger\LoggingHandlerInterface|false|null
      */
@@ -266,11 +265,11 @@ class Logger
     public static function flush()
     {
         try {
-            $s = \SimpleSAML_Session::getSessionFromRequest();
+            $s = Session::getSessionFromRequest();
         } catch (\Exception $e) {
             // loading session failed. We don't care why, at this point we have a transient session, so we use that
             self::error('Cannot load or create session: '.$e->getMessage());
-            $s = \SimpleSAML_Session::getSessionFromRequest();
+            $s = Session::getSessionFromRequest();
         }
         self::$trackid = $s->getTrackID();
 
diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index 91af0e5a8..0f33aaaad 100644
--- a/lib/SimpleSAML/Session.php
+++ b/lib/SimpleSAML/Session.php
@@ -1,4 +1,7 @@
 <?php
+
+namespace SimpleSAML;
+
 /**
  * The Session class holds information about a user session, and everything attached to it.
  *
@@ -16,9 +19,9 @@
  * @author Jaime Pérez Crespo, UNINETT AS <jaime.perez@uninett.no>
  * @package SimpleSAMLphp
  */
-class SimpleSAML_Session implements Serializable
-{
 
+class Session implements \Serializable
+{
     /**
      * This is a timeout value for setData, which indicates that the data
      * should never be deleted, i.e. lasts the whole session lifetime.
@@ -39,7 +42,7 @@ class SimpleSAML_Session implements Serializable
     /**
      * This variable holds the instance of the session - Singleton approach.
      *
-     * Warning: do not set the instance manually, call SimpleSAML_Session::load() instead.
+     * Warning: do not set the instance manually, call \SimpleSAML\Session::load() instead.
      */
     private static $instance = null;
 
@@ -144,15 +147,15 @@ class SimpleSAML_Session implements Serializable
     {
         if (php_sapi_name() === 'cli' || defined('STDIN')) {
             $this->trackid = 'CL'.bin2hex(openssl_random_pseudo_bytes(4));
-            SimpleSAML\Logger::setTrackId($this->trackid);
+            Logger::setTrackId($this->trackid);
             $this->transient = $transient;
             return;
         }
 
         if ($transient) { // transient session
-            $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+            $sh = SessionHandler::getSessionHandler();
             $this->trackid = 'TR'.bin2hex(openssl_random_pseudo_bytes(4));
-            SimpleSAML\Logger::setTrackId($this->trackid);
+            Logger::setTrackId($this->trackid);
             $this->transient = true;
 
             /*
@@ -164,18 +167,18 @@ class SimpleSAML_Session implements Serializable
                 $this->sessionId = $sh->newSessionId();
             }
         } else { // regular session
-            $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+            $sh = SessionHandler::getSessionHandler();
             $this->sessionId = $sh->newSessionId();
             $sh->setCookie($sh->getSessionCookieName(), $this->sessionId, $sh->getCookieParams());
 
 
             $this->trackid = bin2hex(openssl_random_pseudo_bytes(5));
-            SimpleSAML\Logger::setTrackId($this->trackid);
+            Logger::setTrackId($this->trackid);
 
             $this->markDirty();
 
             // initialize data for session check function if defined
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
+            $globalConfig = Configuration::getInstance();
             $checkFunction = $globalConfig->getArray('session.check_function', null);
             if (isset($checkFunction)) {
                 assert(is_callable($checkFunction));
@@ -235,8 +238,8 @@ class SimpleSAML_Session implements Serializable
     /**
      * Retrieves the current session. Creates a new session if there's not one.
      *
-     * @return SimpleSAML_Session The current session.
-     * @throws Exception When session couldn't be initialized and the session fallback is disabled by configuration.
+     * @return \SimpleSAML\Session The current session.
+     * @throws \Exception When session couldn't be initialized and the session fallback is disabled by configuration.
      */
     public static function getSessionFromRequest()
     {
@@ -249,18 +252,18 @@ class SimpleSAML_Session implements Serializable
         $session = null;
         try {
             $session = self::getSession();
-        } catch (Exception $e) {
+        } catch (\Exception $e) {
             /*
              * For some reason, we were unable to initialize this session. Note that this error might be temporary, and
              * it's possible that we can recover from it in subsequent requests, so we should not try to create a new
              * session here. Therefore, use just a transient session and throw the exception for someone else to handle
              * it.
              */
-            SimpleSAML\Logger::error('Error loading session: '.$e->getMessage());
+            Logger::error('Error loading session: '.$e->getMessage());
             self::useTransientSession();
-            if ($e instanceof SimpleSAML_Error_Exception) {
+            if ($e instanceof \SimpleSAML_Error_Exception) {
                 $cause = $e->getCause();
-                if ($cause instanceof Exception) {
+                if ($cause instanceof \Exception) {
                     throw $cause;
                 }
             }
@@ -268,7 +271,7 @@ class SimpleSAML_Session implements Serializable
         }
 
         // if getSession() found it, use it
-        if ($session instanceof SimpleSAML_Session) {
+        if ($session instanceof Session) {
             return self::load($session);
         }
 
@@ -284,20 +287,20 @@ class SimpleSAML_Session implements Serializable
 
         // try to create a new session
         try {
-            self::load(new SimpleSAML_Session());
-        } catch (\SimpleSAML\Error\CannotSetCookie $e) {
+            self::load(new Session());
+        } catch (Error\CannotSetCookie $e) {
             // can't create a regular session because we can't set cookies. Use transient.
-            $c = \SimpleSAML\Configuration::getInstance();
+            $c = Configuration::getInstance();
             self::useTransientSession();
 
-            if ($e->getCode() === \SimpleSAML\Error\CannotSetCookie::SECURE_COOKIE) {
-                throw new \SimpleSAML\Error\CriticalConfigurationError(
+            if ($e->getCode() === Error\CannotSetCookie::SECURE_COOKIE) {
+                throw new Error\CriticalConfigurationError(
                     $e->getMessage(),
                     null,
                     $c->toArray()
                 );
             }
-            SimpleSAML\Logger::error('Error creating session: '.$e->getMessage());
+            Logger::error('Error creating session: '.$e->getMessage());
         }
 
         // we must have a session now, either regular or transient
@@ -309,14 +312,14 @@ class SimpleSAML_Session implements Serializable
      *
      * @param string|null $sessionId The session we should get, or null to get the current session.
      *
-     * @return SimpleSAML_Session|null The session that is stored in the session handler, or null if the session wasn't
+     * @return \SimpleSAML\Session|null The session that is stored in the session handler, or null if the session wasn't
      * found.
      */
     public static function getSession($sessionId = null)
     {
         assert(is_string($sessionId) || $sessionId === null);
 
-        $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+        $sh = SessionHandler::getSessionHandler();
 
         if ($sessionId === null) {
             $checkToken = true;
@@ -340,7 +343,7 @@ class SimpleSAML_Session implements Serializable
         assert($session instanceof self);
 
         if ($checkToken) {
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
+            $globalConfig = Configuration::getInstance();
 
             if ($session->authToken !== null) {
                 $authTokenCookieName = $globalConfig->getString(
@@ -348,11 +351,11 @@ class SimpleSAML_Session implements Serializable
                     'SimpleSAMLAuthToken'
                 );
                 if (!isset($_COOKIE[$authTokenCookieName])) {
-                    SimpleSAML\Logger::warning('Missing AuthToken cookie.');
+                    Logger::warning('Missing AuthToken cookie.');
                     return null;
                 }
-                if (!SimpleSAML\Utils\Crypto::secureCompare($session->authToken, $_COOKIE[$authTokenCookieName])) {
-                    SimpleSAML\Logger::warning('Invalid AuthToken cookie.');
+                if (!Utils\Crypto::secureCompare($session->authToken, $_COOKIE[$authTokenCookieName])) {
+                    Logger::warning('Invalid AuthToken cookie.');
                     return null;
                 }
             }
@@ -363,7 +366,7 @@ class SimpleSAML_Session implements Serializable
                 assert(is_callable($checkFunction));
                 $check = call_user_func($checkFunction, $session);
                 if ($check !== true) {
-                    SimpleSAML\Logger::warning('Session did not pass check function.');
+                    Logger::warning('Session did not pass check function.');
                     return null;
                 }
             }
@@ -382,12 +385,12 @@ class SimpleSAML_Session implements Serializable
      *
      * Warning: never set self::$instance yourself, call this method instead.
      *
-     * @param SimpleSAML_Session $session The session to load.
-     * @return SimpleSAML_Session The session we just loaded, just for convenience.
+     * @param \SimpleSAML\Session $session The session to load.
+     * @return \SimpleSAML\Session The session we just loaded, just for convenience.
      */
-    private static function load(SimpleSAML_Session $session)
+    private static function load(Session $session)
     {
-        SimpleSAML\Logger::setTrackId($session->getTrackID());
+        Logger::setTrackId($session->getTrackID());
         self::$instance = $session;
         return self::$instance;
     }
@@ -405,7 +408,7 @@ class SimpleSAML_Session implements Serializable
             return;
         }
 
-        self::load(new SimpleSAML_Session(true));
+        self::load(new Session(true));
     }
 
     /**
@@ -437,15 +440,15 @@ class SimpleSAML_Session implements Serializable
         $this->dirty = false;
         $this->callback_registered = false;
 
-        $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+        $sh = SessionHandler::getSessionHandler();
 
         try {
             $sh->saveSession($this);
-        } catch (Exception $e) {
-            if (!($e instanceof SimpleSAML_Error_Exception)) {
-                $e = new SimpleSAML_Error_UnserializableException($e);
+        } catch (\Exception $e) {
+            if (!($e instanceof \SimpleSAML_Error_Exception)) {
+                $e = new \SimpleSAML_Error_UnserializableException($e);
             }
-            SimpleSAML\Logger::error('Unable to save session.');
+            Logger::error('Unable to save session.');
             $e->logError();
         }
     }
@@ -460,8 +463,8 @@ class SimpleSAML_Session implements Serializable
     public function cleanup()
     {
         $this->save();
-        $sh = \SimpleSAML\SessionHandler::getSessionHandler();
-        if ($sh instanceof \SimpleSAML\SessionHandlerPHP) {
+        $sh = SessionHandler::getSessionHandler();
+        if ($sh instanceof SessionHandlerPHP) {
             $sh->restorePrevious();
         }
     }
@@ -550,7 +553,7 @@ class SimpleSAML_Session implements Serializable
         assert(is_int($expire) || $expire === null);
 
         if ($expire === null) {
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
+            $globalConfig = Configuration::getInstance();
             $expire = time() + $globalConfig->getInteger('session.rememberme.lifetime', 14 * 86400);
         }
         $this->rememberMeExpire = $expire;
@@ -574,7 +577,7 @@ class SimpleSAML_Session implements Serializable
         assert(is_string($authority));
         assert(is_array($data) || $data === null);
 
-        SimpleSAML\Logger::debug('Session: doLogin("'.$authority.'")');
+        Logger::debug('Session: doLogin("'.$authority.'")');
 
         $this->markDirty();
 
@@ -589,7 +592,7 @@ class SimpleSAML_Session implements Serializable
 
         $data['Authority'] = $authority;
 
-        $globalConfig = \SimpleSAML\Configuration::getInstance();
+        $globalConfig = Configuration::getInstance();
         if (!isset($data['AuthnInstant'])) {
             $data['AuthnInstant'] = time();
         }
@@ -625,8 +628,8 @@ class SimpleSAML_Session implements Serializable
 
         $this->authData[$authority] = $data;
 
-        $this->authToken = SimpleSAML\Utils\Random::generateID();
-        $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler();
+        $this->authToken = Utils\Random::generateID();
+        $sessionHandler = SessionHandler::getSessionHandler();
 
         if (!$this->transient && (!empty($data['RememberMe']) || $this->rememberMeExpire) &&
             $globalConfig->getBoolean('session.rememberme.enable', false)
@@ -634,12 +637,12 @@ class SimpleSAML_Session implements Serializable
             $this->setRememberMeExpire();
         } else {
             try {
-                SimpleSAML\Utils\HTTP::setCookie(
+                Utils\HTTP::setCookie(
                     $globalConfig->getString('session.authtoken.cookiename', 'SimpleSAMLAuthToken'),
                     $this->authToken,
                     $sessionHandler->getCookieParams()
                 );
-            } catch (SimpleSAML\Error\CannotSetCookie $e) {
+            } catch (Error\CannotSetCookie $e) {
                 /*
                  * Something went wrong when setting the auth token. We cannot recover from this, so we better log a
                  * message and throw an exception. The user is not properly logged in anyway, so clear all login
@@ -647,7 +650,7 @@ class SimpleSAML_Session implements Serializable
                  */
                 unset($this->authToken);
                 unset($this->authData[$authority]);
-                \SimpleSAML\Logger::error('Cannot set authentication token cookie: '.$e->getMessage());
+                Logger::error('Cannot set authentication token cookie: '.$e->getMessage());
                 throw $e;
             }
         }
@@ -662,10 +665,10 @@ class SimpleSAML_Session implements Serializable
      */
     public function doLogout($authority)
     {
-        SimpleSAML\Logger::debug('Session: doLogout('.var_export($authority, true).')');
+        Logger::debug('Session: doLogout('.var_export($authority, true).')');
 
         if (!isset($this->authData[$authority])) {
-            SimpleSAML\Logger::debug('Session: Already logged out of '.$authority.'.');
+            Logger::debug('Session: Already logged out of '.$authority.'.');
             return;
         }
 
@@ -685,7 +688,7 @@ class SimpleSAML_Session implements Serializable
      *
      * @param string $authority The authentication source we are logging out from.
      *
-     * @throws Exception If the handler is not a valid function or method.
+     * @throws \Exception If the handler is not a valid function or method.
      */
     private function callLogoutHandlers($authority)
     {
@@ -701,7 +704,7 @@ class SimpleSAML_Session implements Serializable
                 $classname = $handler[0];
                 $functionname = $handler[1];
 
-                throw new Exception(
+                throw new \Exception(
                     'Logout handler is not a valid function: '.$classname.'::'.
                     $functionname
                 );
@@ -728,7 +731,7 @@ class SimpleSAML_Session implements Serializable
         assert(is_string($authority));
 
         if (!isset($this->authData[$authority])) {
-            SimpleSAML\Logger::debug(
+            Logger::debug(
                 'Session: '.var_export($authority, true).
                 ' not valid because we are not authenticated.'
             );
@@ -736,11 +739,11 @@ class SimpleSAML_Session implements Serializable
         }
 
         if ($this->authData[$authority]['Expire'] <= time()) {
-            SimpleSAML\Logger::debug('Session: '.var_export($authority, true).' not valid because it is expired.');
+            Logger::debug('Session: '.var_export($authority, true).' not valid because it is expired.');
             return false;
         }
 
-        SimpleSAML\Logger::debug('Session: Valid session found with '.var_export($authority, true).'.');
+        Logger::debug('Session: Valid session found with '.var_export($authority, true).'.');
 
         return true;
     }
@@ -754,7 +757,7 @@ class SimpleSAML_Session implements Serializable
     {
         assert(is_null($params) || is_array($params));
 
-        $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler();
+        $sessionHandler = SessionHandler::getSessionHandler();
 
         if ($this->sessionId !== null) {
             $sessionHandler->setCookie($sessionHandler->getSessionCookieName(), $this->sessionId, $params);
@@ -763,8 +766,8 @@ class SimpleSAML_Session implements Serializable
         $params = array_merge($sessionHandler->getCookieParams(), is_array($params) ? $params : array());
 
         if ($this->authToken !== null) {
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
-            \SimpleSAML\Utils\HTTP::setCookie(
+            $globalConfig = Configuration::getInstance();
+            Utils\HTTP::setCookie(
                 $globalConfig->getString('session.authtoken.cookiename', 'SimpleSAMLAuthToken'),
                 $this->authToken,
                 $params
@@ -786,7 +789,7 @@ class SimpleSAML_Session implements Serializable
         $this->markDirty();
 
         if ($expire === null) {
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
+            $globalConfig = Configuration::getInstance();
             $expire = time() + $globalConfig->getInteger('session.duration', 8 * 60 * 60);
         }
 
@@ -800,7 +803,7 @@ class SimpleSAML_Session implements Serializable
      * @param string $classname The class which contains the logout handler.
      * @param string $functionname The logout handler function.
      *
-     * @throws Exception If the handler is not a valid function or method.
+     * @throws \Exception If the handler is not a valid function or method.
      */
     public function registerLogoutHandler($authority, $classname, $functionname)
     {
@@ -809,7 +812,7 @@ class SimpleSAML_Session implements Serializable
         $logout_handler = array($classname, $functionname);
 
         if (!is_callable($logout_handler)) {
-            throw new Exception(
+            throw new \Exception(
                 'Logout handler is not a vaild function: '.$classname.'::'.
                 $functionname
             );
@@ -847,7 +850,7 @@ class SimpleSAML_Session implements Serializable
     /**
      * This function stores data in the data store.
      *
-     * The timeout value can be SimpleSAML_Session::DATA_TIMEOUT_SESSION_END, which indicates
+     * The timeout value can be \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END, which indicates
      * that the data should never be deleted.
      *
      * @param string   $type The type of the data. This is checked when retrieving data from the store.
@@ -857,7 +860,7 @@ class SimpleSAML_Session implements Serializable
      * This parameter is optional. The default value is set in 'session.datastore.timeout',
      * and the default is 4 hours.
      *
-     * @throws Exception If the data couldn't be stored.
+     * @throws \Exception If the data couldn't be stored.
      *
      */
     public function setData($type, $id, $data, $timeout = null)
@@ -871,12 +874,12 @@ class SimpleSAML_Session implements Serializable
 
         if ($timeout === null) {
             // use the default timeout
-            $configuration = \SimpleSAML\Configuration::getInstance();
+            $configuration = Configuration::getInstance();
 
             $timeout = $configuration->getInteger('session.datastore.timeout', null);
             if ($timeout !== null) {
                 if ($timeout <= 0) {
-                    throw new Exception(
+                    throw new \Exception(
                         'The value of the session.datastore.timeout'.
                         ' configuration option should be a positive integer.'
                     );
@@ -1036,7 +1039,7 @@ class SimpleSAML_Session implements Serializable
      */
     public function hasSessionCookie()
     {
-        $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+        $sh = SessionHandler::getSessionHandler();
         return $sh->hasSessionCookie();
     }
 
diff --git a/lib/SimpleSAML/SessionHandler.php b/lib/SimpleSAML/SessionHandler.php
index 4608e3cb6..945a75d6a 100644
--- a/lib/SimpleSAML/SessionHandler.php
+++ b/lib/SimpleSAML/SessionHandler.php
@@ -82,9 +82,9 @@ abstract class SessionHandler
     /**
      * Save the session.
      *
-     * @param \SimpleSAML_Session $session The session object we should save.
+     * @param \SimpleSAML\Session $session The session object we should save.
      */
-    abstract public function saveSession(\SimpleSAML_Session $session);
+    abstract public function saveSession(Session $session);
 
 
     /**
@@ -92,7 +92,7 @@ abstract class SessionHandler
      *
      * @param string|null $sessionId The ID of the session we should load, or null to use the default.
      *
-     * @return \SimpleSAML_Session|null The session object, or null if it doesn't exist.
+     * @return \SimpleSAML\Session|null The session object, or null if it doesn't exist.
      */
     abstract public function loadSession($sessionId = null);
 
@@ -129,7 +129,7 @@ abstract class SessionHandler
      */
     private static function createSessionHandler()
     {
-        $store = \SimpleSAML\Store::getInstance();
+        $store = Store::getInstance();
         if ($store === false) {
             self::$sessionHandler = new SessionHandlerPHP();
         } else {
diff --git a/lib/SimpleSAML/SessionHandlerCookie.php b/lib/SimpleSAML/SessionHandlerCookie.php
index c0bb2e8df..a9995081b 100644
--- a/lib/SimpleSAML/SessionHandlerCookie.php
+++ b/lib/SimpleSAML/SessionHandlerCookie.php
@@ -57,7 +57,7 @@ abstract class SessionHandlerCookie extends SessionHandler
     public function newSessionId()
     {
         $this->session_id = self::createSessionID();
-        \SimpleSAML_Session::createSession($this->session_id);
+        Session::createSession($this->session_id);
 
         return $this->session_id;
     }
diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index 8b0904dab..b17796caf 100644
--- a/lib/SimpleSAML/SessionHandlerPHP.php
+++ b/lib/SimpleSAML/SessionHandlerPHP.php
@@ -125,7 +125,7 @@ class SessionHandlerPHP extends SessionHandler
      * Use this method to restore a previous PHP session existing before SimpleSAMLphp initialized its own session.
      *
      * WARNING: do not use this method directly, unless you know what you are doing. Calling this method directly,
-     * outside of SimpleSAML_Session, could cause SimpleSAMLphp's session to be lost or mess the application's one. The
+     * outside of \SimpleSAML\Session, could cause SimpleSAMLphp's session to be lost or mess the application's one. The
      * session must always be saved properly before calling this method. If you don't understand what this is about,
      * don't use this method.
      */
@@ -168,7 +168,7 @@ class SessionHandlerPHP extends SessionHandler
     {
         // generate new (secure) session id
         $sessionId = bin2hex(openssl_random_pseudo_bytes(16));
-        \SimpleSAML_Session::createSession($sessionId);
+        Session::createSession($sessionId);
 
         return $sessionId;
     }
@@ -215,9 +215,9 @@ class SessionHandlerPHP extends SessionHandler
     /**
      * Save the current session to the PHP session array.
      *
-     * @param \SimpleSAML_Session $session The session object we should save.
+     * @param \SimpleSAML\Session $session The session object we should save.
      */
-    public function saveSession(\SimpleSAML_Session $session)
+    public function saveSession(\SimpleSAML\Session $session)
     {
         $_SESSION['SimpleSAMLphp_SESSION'] = serialize($session);
     }
@@ -228,7 +228,7 @@ class SessionHandlerPHP extends SessionHandler
      *
      * @param string|null $sessionId The ID of the session we should load, or null to use the default.
      *
-     * @return \SimpleSAML_Session|null The session object, or null if it doesn't exist.
+     * @return \SimpleSAML\Session|null The session object, or null if it doesn't exist.
      *
      * @throws \SimpleSAML_Error_Exception If it wasn't possible to disable session cookies or we are trying to load a
      * PHP session with a specific identifier and it doesn't match with the current session identifier.
diff --git a/lib/SimpleSAML/SessionHandlerStore.php b/lib/SimpleSAML/SessionHandlerStore.php
index 108655641..f40b9eb95 100644
--- a/lib/SimpleSAML/SessionHandlerStore.php
+++ b/lib/SimpleSAML/SessionHandlerStore.php
@@ -38,7 +38,7 @@ class SessionHandlerStore extends SessionHandlerCookie
      *
      * @param string|null $sessionId The ID of the session we should load, or null to use the default.
      *
-     * @return \SimpleSAML_Session|null The session object, or null if it doesn't exist.
+     * @return \SimpleSAML\Session|null The session object, or null if it doesn't exist.
      */
     public function loadSession($sessionId = null)
     {
@@ -54,7 +54,7 @@ class SessionHandlerStore extends SessionHandlerCookie
 
         $session = $this->store->get('session', $sessionId);
         if ($session !== null) {
-            assert($session instanceof \SimpleSAML_Session);
+            assert($session instanceof Session);
             return $session;
         }
 
@@ -65,9 +65,9 @@ class SessionHandlerStore extends SessionHandlerCookie
     /**
      * Save a session to the data store.
      *
-     * @param \SimpleSAML_Session $session The session object we should save.
+     * @param \SimpleSAML\Session $session The session object we should save.
      */
-    public function saveSession(\SimpleSAML_Session $session)
+    public function saveSession(Session $session)
     {
         $sessionId = $session->getSessionId();
 
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index b7608ac38..03bd67ba2 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -566,7 +566,7 @@ class SimpleSAML_Utilities
             'url'  => $destination,
         );
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->setData('core_postdatalink', $postId, $postData);
 
         $redirInfo = base64_encode(SimpleSAML\Utils\Crypto::aesEncrypt($session->getSessionId().':'.$postId));
diff --git a/lib/SimpleSAML/Utils/Auth.php b/lib/SimpleSAML/Utils/Auth.php
index cd2dbc29e..adf348110 100644
--- a/lib/SimpleSAML/Utils/Auth.php
+++ b/lib/SimpleSAML/Utils/Auth.php
@@ -41,7 +41,7 @@ class Auth
      */
     public static function isAdmin()
     {
-        $session = \SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         return $session->isValid('admin') || $session->isValid('login-admin');
     }
 
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 011fdb5f3..a6641ac6b 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -2,8 +2,9 @@
 namespace SimpleSAML\Utils;
 
 use SimpleSAML\Configuration;
-use SimpleSAML\Module;
 use SimpleSAML\Logger;
+use SimpleSAML\Module;
+use SimpleSAML\Session;
 
 /**
  * HTTP-related utility methods.
@@ -26,7 +27,7 @@ class HTTP
      */
     private static function getSecurePOSTRedirectURL($destination, $data)
     {
-        $session = \SimpleSAML_Session::getSessionFromRequest();
+        $session = Session::getSessionFromRequest();
         $id = self::savePOSTData($session, $destination, $data);
 
         // get the session ID
@@ -206,7 +207,7 @@ class HTTP
     /**
      * Save the given HTTP POST data and the destination where it should be posted to a given session.
      *
-     * @param \SimpleSAML_Session $session The session where to temporarily store the data.
+     * @param \SimpleSAML\Session $session The session where to temporarily store the data.
      * @param string              $destination The destination URL where the form should be posted.
      * @param array               $data An associative array with the data to be posted to $destination.
      *
@@ -215,7 +216,7 @@ class HTTP
      * @author Andjelko Horvat
      * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
      */
-    private static function savePOSTData(\SimpleSAML_Session $session, $destination, $data)
+    private static function savePOSTData(Session $session, $destination, $data)
     {
         // generate a random ID to avoid replay attacks
         $id = Random::generateID();
@@ -290,7 +291,7 @@ class HTTP
             throw new \InvalidArgumentException('Invalid input parameters.');
         }
 
-        $session = \SimpleSAML_Session::getSessionFromRequest();
+        $session = Session::getSessionFromRequest();
         if ($session->hasSessionCookie()) {
             return;
         }
@@ -677,7 +678,7 @@ class HTTP
             // we need to post the data to HTTP
             $url = self::getSecurePOSTRedirectURL($destination, $data);
         } else { // post the data directly
-            $session = \SimpleSAML_Session::getSessionFromRequest();
+            $session = Session::getSessionFromRequest();
             $id = self::savePOSTData($session, $destination, $data);
             $url = Module::getModuleURL('core/postredirect.php', array('RedirId' => $id));
         }
diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php
index c1b7ef3c3..57a95b99b 100644
--- a/lib/SimpleSAML/XHTML/IdPDisco.php
+++ b/lib/SimpleSAML/XHTML/IdPDisco.php
@@ -42,7 +42,7 @@ class SimpleSAML_XHTML_IdPDisco
     /**
      * The users session.
      *
-     * @var SimpleSAML_Session
+     * @var \SimpleSAML\Session
      */
     protected $session;
 
@@ -120,7 +120,7 @@ class SimpleSAML_XHTML_IdPDisco
         // initialize standard classes
         $this->config = \SimpleSAML\Configuration::getInstance();
         $this->metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-        $this->session = SimpleSAML_Session::getSessionFromRequest();
+        $this->session = \SimpleSAML\Session::getSessionFromRequest();
         $this->instance = $instance;
         $this->metadataSets = $metadataSets;
 
diff --git a/modules/core/lib/Auth/Process/ExtendIdPSession.php b/modules/core/lib/Auth/Process/ExtendIdPSession.php
index c58972743..43780fe99 100644
--- a/modules/core/lib/Auth/Process/ExtendIdPSession.php
+++ b/modules/core/lib/Auth/Process/ExtendIdPSession.php
@@ -24,7 +24,7 @@ class sspmod_core_Auth_Process_ExtendIdPSession extends SimpleSAML_Auth_Processi
 		}
 
 		// Update authority expire time
-		$session = SimpleSAML_Session::getSessionFromRequest();
+		$session = \SimpleSAML\Session::getSessionFromRequest();
 		$session->setAuthorityExpire($state['Authority']);
 
 		/* Update session cookies duration */
diff --git a/modules/core/www/cardinality_error.php b/modules/core/www/cardinality_error.php
index 82a1a4efe..2eb19e354 100644
--- a/modules/core/www/cardinality_error.php
+++ b/modules/core/www/cardinality_error.php
@@ -10,7 +10,7 @@ if (!array_key_exists('StateId', $_REQUEST)) {
 }
 $id = $_REQUEST['StateId'];
 $state = \SimpleSAML_Auth_State::loadState($id, 'core:cardinality');
-$session = \SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 \SimpleSAML\Logger::stats('core:cardinality:error '.$state['Destination']['entityid'].' '.$state['saml:sp:IdP'].
     ' '.implode(',', array_keys($state['core:cardinality:errorAttributes'])));
diff --git a/modules/core/www/frontpage_auth.php b/modules/core/www/frontpage_auth.php
index 20c95f393..243221342 100644
--- a/modules/core/www/frontpage_auth.php
+++ b/modules/core/www/frontpage_auth.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp, configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php
index 72b8c5617..b26829738 100644
--- a/modules/core/www/frontpage_config.php
+++ b/modules/core/www/frontpage_config.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists.
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php
index fb9ba7d6e..713aab5ac 100644
--- a/modules/core/www/frontpage_federation.php
+++ b/modules/core/www/frontpage_federation.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp, configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists.
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_welcome.php b/modules/core/www/frontpage_welcome.php
index ec6171273..8ebb5e6f9 100644
--- a/modules/core/www/frontpage_welcome.php
+++ b/modules/core/www/frontpage_welcome.php
@@ -3,7 +3,7 @@
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists.
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/postredirect.php b/modules/core/www/postredirect.php
index 446a54e2e..06d52ce4b 100644
--- a/modules/core/www/postredirect.php
+++ b/modules/core/www/postredirect.php
@@ -8,7 +8,7 @@
 
 if (array_key_exists('RedirId', $_REQUEST)) {
 	$postId = $_REQUEST['RedirId'];
-	$session = SimpleSAML_Session::getSessionFromRequest();
+	$session = \SimpleSAML\Session::getSessionFromRequest();
 } elseif (array_key_exists('RedirInfo', $_REQUEST)) {
 	$encData = base64_decode($_REQUEST['RedirInfo']);
 
@@ -22,7 +22,7 @@ if (array_key_exists('RedirId', $_REQUEST)) {
 		throw new SimpleSAML_Error_BadRequest('Invalid session info data.');
 	}
 
-	$session = SimpleSAML_Session::getSession($sessionId);
+	$session = \SimpleSAML\Session::getSession($sessionId);
 } else {
 	throw new SimpleSAML_Error_BadRequest('Missing redirection info parameter.');
 }
diff --git a/modules/core/www/short_sso_interval.php b/modules/core/www/short_sso_interval.php
index ec9673327..ce61bdfe6 100644
--- a/modules/core/www/short_sso_interval.php
+++ b/modules/core/www/short_sso_interval.php
@@ -11,7 +11,7 @@ if (!array_key_exists('StateId', $_REQUEST)) {
 }
 $id = $_REQUEST['StateId'];
 $state = SimpleSAML_Auth_State::loadState($id, 'core:short_sso_interval');
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 if (array_key_exists('continue', $_REQUEST)) {
 	// The user has pressed the continue/retry-button
diff --git a/modules/core/www/show_metadata.php b/modules/core/www/show_metadata.php
index 07744c3e1..d1a65b1ae 100644
--- a/modules/core/www/show_metadata.php
+++ b/modules/core/www/show_metadata.php
@@ -2,7 +2,7 @@
 
 // load configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 SimpleSAML\Utils\Auth::requireAdmin();
 
diff --git a/modules/cron/www/croninfo.php b/modules/cron/www/croninfo.php
index 8d207e79e..643d24502 100644
--- a/modules/cron/www/croninfo.php
+++ b/modules/cron/www/croninfo.php
@@ -9,7 +9,7 @@ require_once('_include.php');
 
 // Load SimpleSAMLphp, configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 SimpleSAML\Utils\Auth::requireAdmin();
 
diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php
index f04c09831..8d8283346 100644
--- a/modules/multiauth/lib/Auth/Source/MultiAuth.php
+++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php
@@ -154,8 +154,8 @@ class sspmod_multiauth_Auth_Source_MultiAuth extends SimpleSAML_Auth_Source {
 		}
 
 		/* Save the selected authentication source for the logout process. */
-		$session = SimpleSAML_Session::getSessionFromRequest();
-		$session->setData(self::SESSION_SOURCE, $state[self::AUTHID], $authId, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
+		$session = \SimpleSAML\Session::getSessionFromRequest();
+		$session->setData(self::SESSION_SOURCE, $state[self::AUTHID], $authId, \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END);
 
 		try {
 			$as->authenticate($state);
@@ -180,7 +180,7 @@ class sspmod_multiauth_Auth_Source_MultiAuth extends SimpleSAML_Auth_Source {
 		assert(is_array($state));
 
 		/* Get the source that was used to authenticate */
-		$session = SimpleSAML_Session::getSessionFromRequest();
+		$session = \SimpleSAML\Session::getSessionFromRequest();
 		$authId = $session->getData(self::SESSION_SOURCE, $this->authId);
 
 		$source = SimpleSAML_Auth_Source::getById($authId);
diff --git a/modules/negotiate/lib/Auth/Source/Negotiate.php b/modules/negotiate/lib/Auth/Source/Negotiate.php
index f54d7551c..77d81697b 100644
--- a/modules/negotiate/lib/Auth/Source/Negotiate.php
+++ b/modules/negotiate/lib/Auth/Source/Negotiate.php
@@ -96,7 +96,7 @@ class sspmod_negotiate_Auth_Source_Negotiate extends SimpleSAML_Auth_Source
         }
         /* Go straight to fallback if Negotiate is disabled or if you are sent back to the IdP directly from the SP
         after having logged out. */
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $disabled = $session->getData('negotiate:disable', 'session');
 
         if ($disabled ||
@@ -353,7 +353,7 @@ EOF;
         SimpleSAML\Logger::debug('Negotiate - logout has the following authId: "'.$authId.'"');
 
         if ($authId === null) {
-            $session = SimpleSAML_Session::getSessionFromRequest();
+            $session = \SimpleSAML\Session::getSessionFromRequest();
             $session->setData('negotiate:disable', 'session', true, 24 * 60 * 60);
             parent::logout($state);
         } else {
diff --git a/modules/negotiate/www/disable.php b/modules/negotiate/www/disable.php
index bd9fbc76f..ba5d7834a 100644
--- a/modules/negotiate/www/disable.php
+++ b/modules/negotiate/www/disable.php
@@ -16,7 +16,7 @@ $params = array(
 \SimpleSAML\Utils\HTTP::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', 'True', $params, FALSE);
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$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');
diff --git a/modules/negotiate/www/enable.php b/modules/negotiate/www/enable.php
index 68b8e5af8..926bb3186 100644
--- a/modules/negotiate/www/enable.php
+++ b/modules/negotiate/www/enable.php
@@ -15,7 +15,7 @@ $params = array(
 \SimpleSAML\Utils\HTTP::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', NULL, $params, FALSE);
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$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');
diff --git a/modules/negotiate/www/retry.php b/modules/negotiate/www/retry.php
index a39b9596b..5b76da0f0 100644
--- a/modules/negotiate/www/retry.php
+++ b/modules/negotiate/www/retry.php
@@ -19,7 +19,7 @@ if (isset($idpmeta['auth'])) {
 	if ($source === NULL)
 		throw new SimpleSAML_Error_BadRequest('Invalid AuthId "' . $idpmeta['auth'] . '" - not found.');
 
-	$session = SimpleSAML_Session::getSessionFromRequest();
+	$session = \SimpleSAML\Session::getSessionFromRequest();
 	$session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 	SimpleSAML\Logger::debug('Negotiate(retry) - session enabled, retrying.');
 	$source->authenticate($state);
diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php
index 629f63e71..32cf7bb11 100644
--- a/modules/oauth/www/registry.edit.php
+++ b/modules/oauth/www/registry.edit.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp, configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
-$session = \SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 $oauthconfig = \SimpleSAML\Configuration::getOptionalConfig('module_oauth.php');
 
 $store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
diff --git a/modules/oauth/www/registry.php b/modules/oauth/www/registry.php
index ad7c57347..62b7e3ee8 100644
--- a/modules/oauth/www/registry.php
+++ b/modules/oauth/www/registry.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp, configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
-$session = \SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 $oauthconfig = \SimpleSAML\Configuration::getOptionalConfig('module_oauth.php');
 
 $store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php
index 23de5db8e..a93ed5df6 100644
--- a/modules/saml/lib/Auth/Source/SP.php
+++ b/modules/saml/lib/Auth/Source/SP.php
@@ -440,7 +440,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source
     {
         assert(is_array($state));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $data = $session->getAuthState($this->authId);
         foreach ($data as $k => $v) {
             $state[$k] = $v;
@@ -572,7 +572,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source
         assert(isset($state['ReturnCallback']));
 
         // Update session state
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $authId = $state['saml:sp:AuthId'];
         $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
 
@@ -755,7 +755,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source
         assert(is_string($authId));
         assert(is_string($redirectTo));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
 
         \SimpleSAML\Utils\HTTP::redirectUntrustedURL($redirectTo);
diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php
index d4a400450..18f01d8f8 100644
--- a/modules/saml/lib/SP/LogoutStore.php
+++ b/modules/saml/lib/SP/LogoutStore.php
@@ -211,7 +211,7 @@ class sspmod_saml_SP_LogoutStore
             $sessionIndex = sha1($sessionIndex);
         }
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $sessionId = $session->getSessionId();
 
         if ($store instanceof \SimpleSAML\Store\SQL) {
@@ -281,7 +281,7 @@ class sspmod_saml_SP_LogoutStore
 
             $sessionId = $sessions[$sessionIndex];
 
-            $session = SimpleSAML_Session::getSession($sessionId);
+            $session = \SimpleSAML\Session::getSession($sessionId);
             if ($session === null) {
                 SimpleSAML\Logger::info('saml.LogoutStore: Skipping logout of missing session.');
                 continue;
diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php
index 7e18f0e81..6fd5cee3f 100644
--- a/modules/saml/www/sp/saml2-acs.php
+++ b/modules/saml/www/sp/saml2-acs.php
@@ -49,7 +49,7 @@ if ($idp === null) {
     }
 }
 
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 $prevAuth = $session->getAuthData($sourceId, 'saml:sp:prevAuth');
 if ($prevAuth !== null && $prevAuth['id'] === $response->getId() && $prevAuth['issuer'] === $idp) {
     /* OK, it looks like this message has the same issuer
diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php
index efe2bf33d..7dc2448ba 100644
--- a/modules/statistics/www/showstats.php
+++ b/modules/statistics/www/showstats.php
@@ -2,7 +2,7 @@
 
 $config = \SimpleSAML\Configuration::getInstance();
 $statconfig = \SimpleSAML\Configuration::getConfig('module_statistics.php');
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 sspmod_statistics_AccessCheck::checkAccess($statconfig);
 
diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php
index 216e57cb5..a007aa793 100644
--- a/www/admin/hostnames.php
+++ b/www/admin/hostnames.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists..
 SimpleSAML\Utils\Auth::requireAdmin();
diff --git a/www/admin/index.php b/www/admin/index.php
index 9a78941a4..8dde15c9e 100644
--- a/www/admin/index.php
+++ b/www/admin/index.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists..
 SimpleSAML\Utils\Auth::requireAdmin();
diff --git a/www/admin/metadata-converter.php b/www/admin/metadata-converter.php
index 9b6072580..9a20e0046 100644
--- a/www/admin/metadata-converter.php
+++ b/www/admin/metadata-converter.php
@@ -1,4 +1,5 @@
 <?php
+
 require_once('../_include.php');
 
 // make sure that the user has admin access rights
diff --git a/www/admin/phpinfo.php b/www/admin/phpinfo.php
index 2b6b3d7cc..eb46c9377 100644
--- a/www/admin/phpinfo.php
+++ b/www/admin/phpinfo.php
@@ -3,6 +3,6 @@
 require_once('../_include.php');
 
 // Make sure that the user has admin access rights
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 phpinfo();
diff --git a/www/admin/sandbox.php b/www/admin/sandbox.php
index f6bcb66ba..2f000536b 100644
--- a/www/admin/sandbox.php
+++ b/www/admin/sandbox.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists..
 //SimpleSAML\Utils\Auth::requireAdmin();
diff --git a/www/authmemcookie.php b/www/authmemcookie.php
index c385b16a5..cb18a0e0c 100644
--- a/www/authmemcookie.php
+++ b/www/authmemcookie.php
@@ -96,7 +96,7 @@ try {
     $memcache->set($sessionID, $data, 0, $expirationTime);
 
     // register logout handler
-    $session = SimpleSAML_Session::getSessionFromRequest();
+    $session = \SimpleSAML\Session::getSessionFromRequest();
     $session->registerLogoutHandler($sourceId, 'SimpleSAML_AuthMemCookie', 'logoutHandler');
 
     // redirect the user back to this page to signal that the login is completed
diff --git a/www/errorreport.php b/www/errorreport.php
index ae2bea150..c03eb8d1e 100644
--- a/www/errorreport.php
+++ b/www/errorreport.php
@@ -19,7 +19,7 @@ $text = htmlspecialchars((string) $_REQUEST['text']);
 
 $data = null;
 try {
-    $session = SimpleSAML_Session::getSessionFromRequest();
+    $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));
-- 
GitLab