1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
<?php
/**
* The Auth_imsp class provides basic authentication against an IMSP server.
* This will be most benificial if already using an IMSP based preference
* system or IMSP based addressbook system
*
* $Horde: framework/Auth/Auth/imsp.php,v 1.2.10.10 2006/01/01 21:28:07 jan Exp $
*
* Copyright 2004-2006 Michael Rubinsky <mrubinsk@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 Rubinsky <mrubinsk@horde.org>
* @package Horde_Auth
*/
class Auth_imsp extends Auth{
/**
* An array of capabilities, so that the driver can report which
* operations it supports and which it doesn't.
*
* @var array
*/
var $capabilities = array('add' => false,
'update' => false,
'resetpassword' => false,
'remove' => false,
'list' => false,
'transparent' => false);
/**
* Constructor function. Creates new Auth_imsp object.
*
* @param array $params A hash containing parameters.
*/
function Auth_imsp($params = array())
{
$this->_setParams($params);
}
/**
* Private authentication function.
*
* @access private
*
* @param string $userID Username for IMSP server.
* @param array $credentials Hash containing 'password' element.
*
* @return boolean True on success / False on failure.
*/
function _authenticate($userID, $credentials)
{
require_once 'Net/IMSP/Auth.php';
$this->_params['username'] = $userID;
$this->_params['password'] = $credentials['password'];
$imsp = &Net_IMSP_Auth::singleton($this->_params['auth_method']);
if (is_a($imsp, 'PEAR_Error')) {
return $imsp;
}
$result = $imsp->authenticate($this->_params, false);
if (is_a($result, 'PEAR_Error')) {
$this->_setAuthError(AUTH_REASON_BADLOGIN);
return false;
} else {
return true;
}
}
/**
* Checks the params array and sets default values.
*
* @access private
* @param array $params Hash containing IMSP parameters.
*/
function _setParams($params)
{
$this->_params['server'] = $params['server'];
$this->_params['port'] = $params['port'];
$this->_params['auth_method'] = $params['auth_method'];
if (isset($params['auth_mechanism'])) {
$this->_params['auth_mechanism'] = $params['auth_mechanism'];
$this->_params['socket'] = $params['socket'];
$this->_params['command'] = $params['command'];
}
}
}
|