Eric Lippmann 07d04628cf Merge branch 'feature/installation-and-configuration-cleanup-5638'
Conflicts:
	config/config.ini.in
	library/Icinga/Application/ApplicationBootstrap.php
	library/Icinga/Application/Cli.php
	library/Icinga/Application/EmbeddedWeb.php
	library/Icinga/Application/Logger.php
	library/Icinga/Application/Modules/Manager.php
	library/Icinga/Application/Web.php
	library/Icinga/Authentication/Backend/DbUserBackend.php
	library/Icinga/Authentication/Manager.php
	library/Icinga/User/Preferences/IniStore.php
	test/php/library/Icinga/Application/LoggerTest.php
2014-03-03 19:03:39 +01:00

67 lines
1.4 KiB
PHP

<?php
namespace Icinga\Authentication;
use Iterator;
use Zend_Config;
use Icinga\Logger\Logger;
use Icinga\Exception\ConfigurationError;
class AuthChain implements Iterator
{
private $config;
private $currentBackend;
public function __construct(Zend_Config $config)
{
$this->config = $config;
}
public function rewind()
{
$this->config->rewind();
}
public function current()
{
return $this->currentBackend;
}
public function key()
{
return $this->config->key();
}
public function next()
{
$this->config->next();
}
public function valid()
{
if (!$this->config->valid()) {
return false;
}
$backendConfig = $this->config->current();
if ((bool) $backendConfig->get('disabled', false) === true) {
$this->next();
return $this->valid();
}
try {
$name = $this->key();
$backend = UserBackend::create($name, $backendConfig);
} catch (ConfigurationError $e) {
Logger::error(
new ConfigurationError(
'Cannot create authentication backend "' . $name . '". An exception was thrown:', 0, $e
)
);
$this->next();
return $this->valid();
}
$this->currentBackend = $backend;
return true;
}
}