コード例 #1
0
ファイル: account.php プロジェクト: netcon-source/apps
 public function getImapConnection()
 {
     //
     // TODO: cache connections for / within accounts???
     //
     $host = $this->info['host'];
     $user = $this->info['user'];
     $password = $this->info['password'];
     $port = $this->info['port'];
     $ssl_mode = $this->info['ssl_mode'];
     $client = new \Horde_Imap_Client_Socket(array('username' => $user, 'password' => $password, 'hostspec' => $host, 'port' => $port, 'secure' => $ssl_mode, 'timeout' => 2));
     $client->login();
     return $client;
 }
コード例 #2
0
ファイル: Imap.php プロジェクト: raz0rsdge/horde
 /**
  */
 public function valid(array $opts = array())
 {
     if (empty($opts['users'])) {
         unset($opts['auth']);
         /* We still need a username as it is required by the IMAP
          * object. */
         $opts['users'] = array('testing');
     }
     switch ($this->tls) {
         case 'starttls':
             $secure = 'tls';
             break;
         case 'tls':
             $secure = 'ssl';
             break;
         default:
             $secure = !empty($opts['insecure']) ?: 'tls';
             break;
     }
     foreach ($opts['users'] as $user) {
         try {
             $imap = new Horde_Imap_Client_Socket(array('hostspec' => $this->host, 'password' => isset($opts['auth']) ? $opts['auth'] : null, 'port' => $this->port, 'secure' => $secure, 'timeout' => 2, 'username' => $user));
             if (isset($opts['auth'])) {
                 $imap->login();
                 $this->username = $user;
             } else {
                 $imap->noop();
             }
             if ($secure === 'tls') {
                 $this->tls = 'starttls';
             } elseif ($secure === true) {
                 $this->tls = $imap->isSecureConnection() ? 'starttls' : false;
             }
             $imap->shutdown();
             return true;
         } catch (Horde_Imap_Client_Exception $e) {
         }
     }
     return false;
 }
コード例 #3
0
ファイル: Auth.php プロジェクト: horde/horde
 /**
  * Returns a Horde_Auth_Base driver for the given driver/configuration.
  *
  * @param string $driver      Driver name.
  * @param array $orig_params  Driver parameters.
  *
  * @return Horde_Auth_Base  Authentication object.
  */
 protected function _create($driver, $orig_params = null)
 {
     /* Get proper driver name now that we have grabbed the
      * configuration. */
     if (strcasecmp($driver, 'application') === 0) {
         $driver = 'Horde_Core_Auth_Application';
     } elseif (strcasecmp($driver, 'httpremote') === 0) {
         /* BC */
         $driver = 'Http_Remote';
     } elseif (strcasecmp($driver, 'composite') === 0) {
         $driver = 'Horde_Core_Auth_Composite';
     } elseif (strcasecmp($driver, 'ldap') === 0) {
         $driver = 'Horde_Core_Auth_Ldap';
     } elseif (strcasecmp($driver, 'msad') === 0) {
         $driver = 'Horde_Core_Auth_Msad';
     } elseif (strcasecmp($driver, 'shibboleth') === 0) {
         $driver = 'Horde_Core_Auth_Shibboleth';
     } elseif (strcasecmp($driver, 'imsp') === 0) {
         $driver = 'Horde_Core_Auth_Imsp';
     } elseif (strcasecmp($driver, 'x509') === 0) {
         $driver = 'Horde_Core_Auth_X509';
     } else {
         $driver = implode('_', array_map('Horde_String::ucwords', explode('_', Horde_String::lower(basename($driver)))));
     }
     $params = is_null($orig_params) ? Horde::getDriverConfig('auth', $driver) : $orig_params;
     $driver = $this->_getDriverName($driver, 'Horde_Auth');
     $lc_driver = Horde_String::lower($driver);
     switch ($lc_driver) {
         case 'horde_core_auth_composite':
             // Both of these params are required, but we need to skip if
             // non-existent to return a useful error message later.
             if (!empty($params['admin_driver'])) {
                 $params['admin_driver'] = $this->_create($params['admin_driver']['driver'], $params['admin_driver']['params']);
             }
             if (!empty($params['auth_driver'])) {
                 $params['auth_driver'] = $this->_create($params['auth_driver']['driver'], $params['auth_driver']['params']);
             }
             break;
         case 'horde_auth_cyrsql':
             $imap_config = array('hostspec' => empty($params['cyrhost']) ? null : $params['cyrhost'], 'password' => $params['cyrpass'], 'port' => empty($params['cyrport']) ? null : $params['cyrport'], 'secure' => $params['secure'] == 'none' ? null : $params['secure'], 'username' => $params['cyradmin']);
             try {
                 $ob = new Horde_Imap_Client_Socket($imap_config);
                 $ob->login();
                 $params['imap'] = $ob;
             } catch (Horde_Imap_Client_Exception $e) {
                 throw new Horde_Auth_Exception($e);
             }
             $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
             break;
         case 'horde_auth_http_remote':
             $params['client'] = $this->_injector->getInstance('Horde_Core_Factory_HttpClient')->create();
             break;
         case 'horde_core_auth_application':
             if (isset($this->_instances[$params['app']])) {
                 return $this->_instances[$params['app']];
             }
             break;
         case 'horde_core_auth_imsp':
             $params['imsp'] = $this->_injector->getInstance('Horde_Core_Factory_Imsp')->create();
             break;
         case 'horde_auth_kolab':
             $params['kolab'] = $this->_injector->getInstance('Horde_Kolab_Session');
             break;
         case 'horde_core_auth_ldap':
         case 'horde_core_auth_msad':
             $params['ldap'] = $this->_injector->getInstance('Horde_Core_Factory_Ldap')->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
             break;
         case 'horde_core_auth_x509':
             if (!empty($params['password_source']) && $params['password_source'] == 'unified') {
                 $params['password'] = $params['unified_password'];
                 unset($params['password_source'], $params['unified_password']);
             }
             // @TODO: Add filters
             break;
         case 'horde_auth_customsql':
         case 'horde_auth_sql':
             $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
             break;
     }
     $params['default_user'] = $GLOBALS['registry']->getAuth();
     $params['logger'] = $this->_injector->getInstance('Horde_Log_Logger');
     if (!empty($params['count_bad_logins'])) {
         $params['history_api'] = $this->_injector->getInstance('Horde_History');
     }
     if (!empty($params['login_block'])) {
         $params['lock_api'] = $this->_injector->getInstance('Horde_Lock');
     }
     $auth_ob = new $driver($params);
     if ($lc_driver == 'horde_core_auth_application') {
         $this->_instances[$params['app']] = $auth_ob;
     }
     return $auth_ob;
 }
コード例 #4
0
ファイル: mail.php プロジェクト: blablubli/owncloudapps
 private static function getImapConnection($account)
 {
     //
     // TODO: cash connections for / within accounts???
     //
     $host = $account['host'];
     $user = $account['user'];
     $password = $account['password'];
     $port = $account['port'];
     $ssl_mode = $account['ssl_mode'];
     $client = new \Horde_Imap_Client_Socket(array('username' => $user, 'password' => $password, 'hostspec' => $host, 'port' => $port, 'secure' => $ssl_mode));
     $client->login();
     return $client;
 }