1: <?php
2: /**
3: * The Horde_Corde_Auth_Imsp class provides basic authentication against an IMSP
4: * server.
5: *
6: * Copyright 2004-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you did
9: * not receive this file, see http://opensource.org/licenses/lgpl-2.1.php
10: *
11: * @author Michael J Rubinsky <mrubinsk@horde.org>
12: * @category Horde
13: * @license http://opensource.org/licenses/lgpl-2.1.php LGPL
14: * @package Auth
15: */
16: class Horde_Core_Auth_Imsp extends Horde_Auth_Base
17: {
18: /**
19: *
20: * @var Horde_Imsp_Client_Base
21: */
22: protected $_imsp;
23:
24: /**
25: * Private authentication function.
26: *
27: * @param string $userID Username for IMSP server.
28: * @param array $credentials Hash containing 'password' element.
29: *
30: * @return boolean True on success / False on failure.
31: */
32: protected function _authenticate($userID, $credentials)
33: {
34: // Need to create the Imsp socket here since it requires a user/password
35: // to create, and we don't have one until this method.
36: $this->_params['username'] = $userID;
37: $this->_params['password'] = $credentials['password'];
38: $this->_imsp = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imsp')->create(null, $this->_params);
39: if (!$result = $this->_imsp->authenticate(false)) {
40: throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
41: }
42: }
43:
44: }
45: