Fix coding style
This commit is contained in:
parent
d260c3fb94
commit
a37e65be52
|
@ -4,11 +4,10 @@
|
||||||
|
|
||||||
namespace Icinga\Form\Config\Authentication;
|
namespace Icinga\Form\Config\Authentication;
|
||||||
|
|
||||||
use \Exception;
|
use Exception;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Authentication\DbConnection;
|
|
||||||
use Icinga\Authentication\Backend\DbUserBackend;
|
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
|
use Icinga\Authentication\Backend\DbUserBackend;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form class for adding/modifying database authentication backends
|
* Form class for adding/modifying database authentication backends
|
||||||
|
@ -16,6 +15,8 @@ use Icinga\Exception\ConfigurationError;
|
||||||
class DbBackendForm extends BaseBackendForm
|
class DbBackendForm extends BaseBackendForm
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* The available database resources prepared to be used as select input data
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $resources;
|
protected $resources;
|
||||||
|
@ -43,6 +44,9 @@ class DbBackendForm extends BaseBackendForm
|
||||||
$this->resources = array_combine($dbResources, $dbResources);
|
$this->resources = array_combine($dbResources, $dbResources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Form::createElements()
|
||||||
|
*/
|
||||||
public function createElements(array $formData)
|
public function createElements(array $formData)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
@ -94,7 +98,7 @@ class DbBackendForm extends BaseBackendForm
|
||||||
*
|
*
|
||||||
* @return bool Whether validation succeeded or not
|
* @return bool Whether validation succeeded or not
|
||||||
*
|
*
|
||||||
* @see BaseBackendForm::isValidAuthenticationBackend
|
* @see BaseBackendForm::isValidAuthenticationBackend()
|
||||||
*/
|
*/
|
||||||
public function isValidAuthenticationBackend()
|
public function isValidAuthenticationBackend()
|
||||||
{
|
{
|
||||||
|
@ -104,13 +108,14 @@ class DbBackendForm extends BaseBackendForm
|
||||||
));
|
));
|
||||||
$dbUserBackend = new DbUserBackend($testConnection);
|
$dbUserBackend = new DbUserBackend($testConnection);
|
||||||
if ($dbUserBackend->count() < 1) {
|
if ($dbUserBackend->count() < 1) {
|
||||||
$this->addErrorMessage(t("No users found under the specified database backend"));
|
$this->addErrorMessage(t('No users found under the specified database backend'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->addErrorMessage(sprintf(t('Using the specified backend failed: %s'), $e->getMessage()));
|
$this->addErrorMessage(sprintf(t('Using the specified backend failed: %s'), $e->getMessage()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,10 @@
|
||||||
|
|
||||||
namespace Icinga\Form\Config\Authentication;
|
namespace Icinga\Form\Config\Authentication;
|
||||||
|
|
||||||
use \Exception;
|
use Exception;
|
||||||
use \Zend_Config;
|
|
||||||
use Icinga\Web\Form;
|
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Authentication\Backend\LdapUserBackend;
|
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
|
use Icinga\Authentication\Backend\LdapUserBackend;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for adding or modifying LDAP authentication backends
|
* Form for adding or modifying LDAP authentication backends
|
||||||
|
@ -17,6 +15,8 @@ use Icinga\Exception\ConfigurationError;
|
||||||
class LdapBackendForm extends BaseBackendForm
|
class LdapBackendForm extends BaseBackendForm
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* The available ldap resources prepared to be used as select input data
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $resources;
|
protected $resources;
|
||||||
|
@ -44,6 +44,9 @@ class LdapBackendForm extends BaseBackendForm
|
||||||
$this->resources = array_combine($ldapResources, $ldapResources);
|
$this->resources = array_combine($ldapResources, $ldapResources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Form::createElements()
|
||||||
|
*/
|
||||||
public function createElements(array $formData)
|
public function createElements(array $formData)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
@ -130,23 +133,21 @@ class LdapBackendForm extends BaseBackendForm
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the current configuration by creating a backend and requesting the user count
|
* Validate the current configuration by connecting to a backend and requesting the user count
|
||||||
*
|
*
|
||||||
* @return bool Whether validation succeeded or not
|
* @return bool Whether validation succeeded or not
|
||||||
*
|
*
|
||||||
* @see BaseBackendForm::isValidAuthenticationBacken
|
* @see BaseBackendForm::isValidAuthenticationBacken()
|
||||||
*/
|
*/
|
||||||
public function isValidAuthenticationBackend()
|
public function isValidAuthenticationBackend()
|
||||||
{
|
{
|
||||||
if (! ResourceFactory::ldapAvailable()) {
|
if (false === ResourceFactory::ldapAvailable()) {
|
||||||
/*
|
// It should be possible to run icingaweb without the php ldap extension. When the user
|
||||||
* It should be possible to run icingaweb without the php ldap extension, when
|
// tries to create an ldap backend without ldap being installed we display an error.
|
||||||
* no ldap backends are needed. When the user tries to create an ldap backend
|
|
||||||
* without ldap installed we need to show him an error.
|
|
||||||
*/
|
|
||||||
$this->addErrorMessage(t('Using ldap is not possible, the php extension "ldap" is not installed.'));
|
$this->addErrorMessage(t('Using ldap is not possible, the php extension "ldap" is not installed.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$cfg = $this->getConfig();
|
$cfg = $this->getConfig();
|
||||||
$backendConfig = new Zend_Config($cfg[$this->getValue('name')]);
|
$backendConfig = new Zend_Config($cfg[$this->getValue('name')]);
|
||||||
|
@ -157,11 +158,6 @@ class LdapBackendForm extends BaseBackendForm
|
||||||
$backendConfig->user_name_attribute
|
$backendConfig->user_name_attribute
|
||||||
);
|
);
|
||||||
$testConn->assertAuthenticationPossible();
|
$testConn->assertAuthenticationPossible();
|
||||||
/*
|
|
||||||
if ($testConn->count() === 0) {
|
|
||||||
throw new Exception('No Users Found On Directory Server');
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
$this->addErrorMessage(
|
$this->addErrorMessage(
|
||||||
t('Connection Validation Failed: ' . $exc->getMessage())
|
t('Connection Validation Failed: ' . $exc->getMessage())
|
||||||
|
|
Loading…
Reference in New Issue