factory() public static method

Attempts to return a concrete Horde_Auth_Base instance based on $driver.
Deprecation:
public static factory ( string $driver, array $params = null ) : Horde_Auth_Base
$driver string Either a driver name, or the full class name to use (class must extend Horde_Auth_Base).
$params array A hash containing any additional configuration or parameters a subclass might need.
return Horde_Auth_Base The newly created concrete instance.
Exemplo n.º 1
0
 /**
  * Factory for ActiveSync Auth object.
  *
  * @return Horde_Core_ActiveSync_Auth
  */
 protected function _getAuth()
 {
     global $conf, $injector;
     $params = array('base_driver' => $injector->getInstance('Horde_Core_Factory_Auth')->create());
     if ($conf['activesync']['auth']['type'] != 'basic') {
         $x_params = $conf['activesync']['auth']['params'];
         $x_params['default_user'] = $GLOBALS['registry']->getAuth();
         $x_params['logger'] = $this->_injector->getInstance('Horde_Log_Logger');
         $params['transparent_driver'] = Horde_Auth::factory('Horde_Core_Auth_X509', $x_params);
     }
     $obj = new Horde_Core_ActiveSync_Auth($params);
     return $obj;
 }
Exemplo n.º 2
0
 /**
  * Asks for the administrator settings.
  *
  * @return string  The administrator name.
  */
 protected function _configAuth(Horde_Variables $vars)
 {
     $vars->auth__driver = 'sql';
     $vars->auth__params__driverconfig = 'horde';
     while (true) {
         $admin_user = $this->_cli->prompt('Specify a user name for the administrator account:');
         if (empty($admin_user)) {
             $this->_cli->writeln($this->_cli->red('An administration user is required'));
             continue;
         }
         $admin_pass = $this->_cli->passwordPrompt('Specify a password for the administrator account:');
         if (empty($admin_pass)) {
             $this->_cli->writeln($this->_cli->red('An administrator password is required'));
             continue;
         }
         $params = array('db' => $GLOBALS['injector']->getInstance('Horde_Db_Adapter'), 'encryption' => isset($GLOBALS['conf']['auth']['params']['encryption']) ? $GLOBALS['conf']['auth']['params']['encryption'] : 'ssha');
         $auth = Horde_Auth::factory('sql', $params);
         try {
             $exists = $auth->exists($admin_user);
         } catch (Horde_Exception $e) {
             $this->_cli->message('An error occured while trying to list the users. Error messages:', 'cli.error');
             $this->_cli->writeln($e->getMessage());
             return;
         }
         try {
             if ($exists) {
                 if ($this->_cli->prompt('This user exists already, do you want to update his password?', array('y' => 'Yes', 'n' => 'No'), 'y') == 'y') {
                     $auth->updateUser($admin_user, $admin_user, array('password' => $admin_pass));
                 } else {
                     break;
                 }
             } else {
                 $auth->addUser($admin_user, array('password' => $admin_pass));
             }
         } catch (Horde_Exception $e) {
             $this->_cli->message('An error occured while adding or updating the administrator. Error messages:', 'cli.error');
             $this->_cli->writeln($e->getMessage());
             return;
         }
         break;
     }
     return $admin_user;
 }
Exemplo n.º 3
0
 /**
  * Return the Horde_Auth_Imap instance that uses IMP configuration.
  *
  * @return Horde_Auth_Imap  The singleton instance.
  * @throws IMP_Exception
  */
 public function create(Horde_Injector $injector)
 {
     global $injector, $registry;
     $admin = $injector->getInstance('IMP_Factory_Imap')->create()->config->admin;
     if (!$admin) {
         throw new IMP_Exception('Admin access not enabled.');
     }
     $params = $registry->callByPackage('imp', 'server');
     if (is_null($params)) {
         throw new IMP_Exception('No server parameters found.');
     }
     $params_map = array('password' => 'admin_password', 'user' => 'admin_user', 'userhierarchy' => 'userhierarchy');
     foreach ($admin as $key => $val) {
         if (isset($params_map[$key])) {
             $params[$params_map[$key]] = $val;
         }
     }
     $params['default_user'] = $registry->getAuth();
     $params['logger'] = $injector->getInstance('Horde_Log_Logger');
     return Horde_Auth::factory('Imap', $params);
 }