rename IMP auth driver for class loading
authorChuck Hagenbuch <chuck@horde.org>
Tue, 14 Jul 2009 05:14:53 +0000 (01:14 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Tue, 14 Jul 2009 05:14:53 +0000 (01:14 -0400)
imp/lib/Auth.php [new file with mode: 0644]
imp/lib/Auth/Imp.php [deleted file]
imp/lib/IMP.php
imp/lib/Session.php

diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php
new file mode 100644 (file)
index 0000000..071f9df
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * The Horde_Auth:: class provides an IMP implementation of the Horde
+ * authentication system.
+ *
+ * Required parameters: NONE
+ * Optional parameters: NONE
+ *
+ * Copyright 2003-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @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 (file)
index cc0bdd3..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * The Horde_Auth_Imp:: class provides an IMP implementation of the Horde
- * authentication system.
- *
- * Required parameters: NONE
- * Optional parameters: NONE
- *
- * Copyright 2003-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @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);
-        }
-    }
-}
index f3b352b..708738d 100644 (file)
@@ -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);
         }
 
index 887ff26..cbe16c1 100644 (file)
@@ -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;