From: Chuck Hagenbuch Date: Tue, 14 Jul 2009 05:14:53 +0000 (-0400) Subject: rename IMP auth driver for class loading X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=fcbfdc9e6494d10c6290a76e5ce279663ce7f918;p=horde.git rename IMP auth driver for class loading --- diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php new file mode 100644 index 000000000..071f9dfcc --- /dev/null +++ b/imp/lib/Auth.php @@ -0,0 +1,70 @@ + + * @package Horde_Auth + */ +class IMP_Auth extends Horde_Auth_Base +{ + /** + * Find out if a set of login credentials are valid, and if + * requested, mark the user as logged in in the current session. + * + * @param string $userID The userID to check. + * @param array $credentials The credentials to check. + * @param boolean $login Whether to log the user in. If false, we'll + * only test the credentials and won't modify + * the current session. + * + * @return boolean Whether or not the credentials are valid. + */ + public function authenticate($userID = null, $credentials = array(), + $login = false) + { + return parent::authenticate($userID, $credentials, $login && (Horde_Auth::getProvider() == 'imp')); + } + + /** + * Find out if a set of login credentials are valid. + * + * @param string $userID The userID to check. + * @param array $credentials An array of login credentials. + * + * @throws Horde_Exception + */ + protected function _authenticate($userID, $credentials) + { + // Check for valid IMAP Client object. + if (!$GLOBALS['imp_imap']->ob) { + // Attempt to create IMAP Client object + $key = isset($credentials['server']) ? $credentials['server'] : IMP_Session::getAutoLoginServer(); + if (is_null($key) || + !isset($credentials['password']) || + !$GLOBALS['imp_imap']->createImapObject($userID, $credentials['password'], $key)) { + IMP::loginLogMessage('failed', __FILE__, __LINE__); + throw new Horde_Exception('', Horde_Auth::REASON_FAILED); + } + } + + try { + $GLOBALS['imp_imap']->ob->login(); + } catch (Horde_Imap_Client_Exception $e) { + IMP::loginLogMessage($e->getMessage(), __FILE__, __LINE__); + if ($e->getCode() == Horde_Imap_Client_Exception::SERVER_CONNECT) { + throw new Horde_Exception(_("Could not connect to the remote server.")); + } + + throw new Horde_Exception('', Horde_Auth::REASON_BADLOGIN); + } + } +} diff --git a/imp/lib/Auth/Imp.php b/imp/lib/Auth/Imp.php deleted file mode 100644 index cc0bdd39f..000000000 --- a/imp/lib/Auth/Imp.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @package Horde_Auth - */ -class IMP_Auth_Imp extends Horde_Auth_Driver -{ - /** - * Find out if a set of login credentials are valid, and if - * requested, mark the user as logged in in the current session. - * - * @param string $userID The userID to check. - * @param array $credentials The credentials to check. - * @param boolean $login Whether to log the user in. If false, we'll - * only test the credentials and won't modify - * the current session. - * - * @return boolean Whether or not the credentials are valid. - */ - public function authenticate($userID = null, $credentials = array(), - $login = false) - { - return parent::authenticate($userID, $credentials, $login && (Horde_Auth::getProvider() == 'imp')); - } - - /** - * Find out if a set of login credentials are valid. - * - * @param string $userID The userID to check. - * @param array $credentials An array of login credentials. - * - * @throws Horde_Exception - */ - protected function _authenticate($userID, $credentials) - { - // Check for valid IMAP Client object. - if (!$GLOBALS['imp_imap']->ob) { - // Attempt to create IMAP Client object - $key = isset($credentials['server']) ? $credentials['server'] : IMP_Session::getAutoLoginServer(); - if (is_null($key) || - !isset($credentials['password']) || - !$GLOBALS['imp_imap']->createImapObject($userID, $credentials['password'], $key)) { - IMP::loginLogMessage('failed', __FILE__, __LINE__); - throw new Horde_Exception('', Horde_Auth::REASON_FAILED); - } - } - - try { - $GLOBALS['imp_imap']->ob->login(); - } catch (Horde_Imap_Client_Exception $e) { - IMP::loginLogMessage($e->getMessage(), __FILE__, __LINE__); - if ($e->getCode() == Horde_Imap_Client_Exception::SERVER_CONNECT) { - throw new Horde_Exception(_("Could not connect to the remote server.")); - } - - throw new Horde_Exception('', Horde_Auth::REASON_BADLOGIN); - } - } -} diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index f3b352b18..708738d75 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -74,7 +74,7 @@ class IMP if ($hordeauth) { $reason = Horde_Auth::isAuthenticated(); } else { - $auth_imp = Horde_Auth::singleton(array('imp', 'imp')); + $auth_imp = new IMP_Auth(); $reason = $auth_imp->authenticate(null, array(), false); } diff --git a/imp/lib/Session.php b/imp/lib/Session.php index 887ff262e..cbe16c1e4 100644 --- a/imp/lib/Session.php +++ b/imp/lib/Session.php @@ -108,7 +108,7 @@ class IMP_Session /* Do necessary authentication now (since Horde_Auth:: may need to set * values in Horde-land). */ - $auth_imp = Horde_Auth::singleton(array('imp', 'imp')); + $auth_imp = new IMP_Auth(); if ($auth_imp->authenticate($sess['uniquser'], array('password' => $password), true) !== true) { unset($_SESSION['imp']); return false;