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