Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| AuthFactory | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
42 | |
0.00% |
0 / 1 |
| createAdapters | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
42 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\oatbox\user\auth; |
| 23 | |
| 24 | use common_ext_ExtensionsManager; |
| 25 | |
| 26 | /** |
| 27 | * Create the configured auth adapters |
| 28 | * |
| 29 | * @access public |
| 30 | * @author Joel Bout, <joel@taotesting.com> |
| 31 | * @package generis |
| 32 | */ |
| 33 | class AuthFactory |
| 34 | { |
| 35 | public const CONFIG_KEY = 'auth'; |
| 36 | |
| 37 | public static function createAdapters() |
| 38 | { |
| 39 | $adapters = []; |
| 40 | $config = common_ext_ExtensionsManager::singleton()->getExtensionById('generis')->getConfig('auth'); |
| 41 | if (is_array($config)) { |
| 42 | foreach ($config as $key => $adapterConf) { |
| 43 | if (isset($adapterConf['driver'])) { |
| 44 | $className = $adapterConf['driver']; |
| 45 | unset($adapterConf['driver']); |
| 46 | if ( |
| 47 | class_exists($className) |
| 48 | && in_array(__NAMESPACE__ . '\LoginAdapter', class_implements($className)) |
| 49 | ) { |
| 50 | $adapter = new $className(); |
| 51 | $adapter->setOptions($adapterConf); |
| 52 | $adapters[] = $adapter; |
| 53 | } else { |
| 54 | \common_Logger::e($className . ' is not a valid LoginAdapter'); |
| 55 | } |
| 56 | } else { |
| 57 | \common_Logger::e('No driver for auth adapter ' . $key); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | return $adapters; |
| 62 | } |
| 63 | } |