From 3d32ff6d8ba32ce0a6560741b9338f21941236c7 Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Wed, 20 Apr 2016 13:11:13 +0200
Subject: [PATCH] The data store can be a custom class in a module. When we
 cannot load a class matching the 'store.type' configuration option we don't
 handle the exception, causing a fatal error. Use the new
 CriticalConfigurationError to fix that. This fixes #369.

---
 lib/SimpleSAML/Store.php | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/SimpleSAML/Store.php b/lib/SimpleSAML/Store.php
index 914b6b687..6a51c1e6c 100644
--- a/lib/SimpleSAML/Store.php
+++ b/lib/SimpleSAML/Store.php
@@ -50,7 +50,17 @@ abstract class SimpleSAML_Store
                 break;
             default:
                 // datastore from module
-                $className = SimpleSAML\Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
+                try {
+                    $className = SimpleSAML\Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
+                } catch (Exception $e) {
+                    $c = $config->toArray();
+                    $c['store.type'] = 'phpsession';
+                    throw new SimpleSAML\Error\CriticalConfigurationError(
+                        "Invalid 'store.type' configuration option. Cannot find store '$storeType'.",
+                        null,
+                        $c
+                    );
+                }
                 self::$instance = new $className();
         }
 
-- 
GitLab