Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1173 → Rev 1713

/trunk/api/pear/Auth/PrefManager.php
File deleted
/trunk/api/pear/Auth/RADIUS.php
File deleted
/trunk/api/pear/Auth/SASL/Plain.php
File deleted
/trunk/api/pear/Auth/SASL/DigestMD5.php
File deleted
/trunk/api/pear/Auth/SASL/Anonymous.php
File deleted
\ No newline at end of file
/trunk/api/pear/Auth/SASL/Common.php
File deleted
/trunk/api/pear/Auth/SASL/CramMD5.php
File deleted
\ No newline at end of file
/trunk/api/pear/Auth/SASL/Login.php
File deleted
\ No newline at end of file
/trunk/api/pear/Auth/HTTP.php
File deleted
/trunk/api/pear/Auth/SASL.php
File deleted
\ No newline at end of file
/trunk/api/pear/Auth/Auth.php
17,7 → 17,7
* @author Martin Jansen <mj@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Auth.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Auth.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @deprecated File deprecated since Release 1.2.0
*/
/trunk/api/pear/Auth/Container.php
18,7 → 18,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Container.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Container.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
31,7 → 31,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth_Container
46,6 → 46,13
*/
var $activeUser = "";
 
/**
* The Auth object this container is attached to.
*
* @access public
*/
var $_auth_obj = null;
 
// }}}
// {{{ Auth_Container() [constructor]
 
72,6 → 79,7
*/
function fetchData($username, $password, $isChallengeResponse=false)
{
$this->log('Auth_Container::fetchData() called.', AUTH_LOG_DEBUG);
}
 
// }}}
90,6 → 98,7
*/
function verifyPassword($password1, $password2, $cryptType = "md5")
{
$this->log('Auth_Container::verifyPassword() called.', AUTH_LOG_DEBUG);
switch ($cryptType) {
case "crypt" :
return ((string)crypt($password1, $password2) === (string)$password2);
104,7 → 113,7
default :
if (function_exists($cryptType)) {
return ((string)$cryptType($password1) === (string)$password2);
} elseif (method_exists($this,$cryptType)) {
} elseif (method_exists($this,$cryptType)) {
return ((string)$this->$cryptType($password1) === (string)$password2);
} else {
return false;
115,9 → 124,9
 
// }}}
// {{{ supportsChallengeResponse()
 
/**
* Returns true if the container supports Challenge Response
* Returns true if the container supports Challenge Response
* password authentication
*/
function supportsChallengeResponse()
127,7 → 136,7
 
// }}}
// {{{ getCryptType()
 
/**
* Returns the crypt current crypt type of the container
*
146,6 → 155,7
*/
function listUsers()
{
$this->log('Auth_Container::listUsers() called.', AUTH_LOG_DEBUG);
return AUTH_METHOD_NOT_SUPPORTED;
}
 
161,6 → 171,7
*/
function getUser($username)
{
$this->log('Auth_Container::getUser() called.', AUTH_LOG_DEBUG);
$users = $this->listUsers();
if ($users === AUTH_METHOD_NOT_SUPPORTED) {
return AUTH_METHOD_NOT_SUPPORTED;
187,6 → 198,7
*/
function addUser($username, $password, $additional=null)
{
$this->log('Auth_Container::addUser() called.', AUTH_LOG_DEBUG);
return AUTH_METHOD_NOT_SUPPORTED;
}
 
200,6 → 212,7
*/
function removeUser($username)
{
$this->log('Auth_Container::removeUser() called.', AUTH_LOG_DEBUG);
return AUTH_METHOD_NOT_SUPPORTED;
}
 
214,11 → 227,36
*/
function changePassword($username, $password)
{
$this->log('Auth_Container::changePassword() called.', AUTH_LOG_DEBUG);
return AUTH_METHOD_NOT_SUPPORTED;
}
 
// }}}
// {{{ log()
 
/**
* Log a message to the Auth log
*
* @param string The message
* @param int
* @return boolean
*/
function log($message, $level = AUTH_LOG_DEBUG) {
 
if (is_null($this->_auth_obj)) {
 
return false;
 
} else {
 
return $this->_auth_obj->log($message, $level);
 
}
 
}
 
// }}}
 
}
 
?>
/trunk/api/pear/Auth/Controller.php
18,14 → 18,14
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Controller.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Controller.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.3.0
*/
 
/**
* Controlls access to a group of php access
* and redirects to a predefined login page as
* Controlls access to a group of php access
* and redirects to a predefined login page as
* needed
*
* In all pages
46,7 → 46,7
* $authController->start();
* if( $authController->isAuthorised() ){
* $authController->redirectBack();
* }
* }
* </code>
*
* @category Authentication
54,7 → 54,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.3.0
*/
63,29 → 63,29
 
// {{{ properties
 
/**
/**
* The Auth instance this controller is managing
*
* @var object Auth
*/
var $auth = null;
 
/**
* The login URL
* @var string
* */
var $login = null;
 
/**
* The default index page to use when the caller page is not set
*
* @var string
* @var string
*/
var $default = null;
/**
* If this is set to true after a succesfull login the
* Auth_Controller::redirectBack() is invoked automatically
 
/**
* If this is set to true after a succesfull login the
* Auth_Controller::redirectBack() is invoked automatically
*
* @var boolean
*/
93,7 → 93,7
 
// }}}
// {{{ Auth_Controller() [constructor]
 
/**
* Constructor
*
121,10 → 121,10
 
// }}}
// {{{ setAutoRedirectBack()
/**
 
/**
* Enables auto redirection when login is done
*
*
* @param bool Sets the autoRedirectBack flag to this
* @see Auth_Controller::autoRedirectBack
* @return void
136,7 → 136,7
 
// }}}
// {{{ redirectBack()
 
/**
* Redirects Back to the calling page
*
146,12 → 146,12
{
// If redirectback go there
// else go to the default page
 
$returnUrl = $this->auth->getAuthData('returnUrl');
if(!$returnUrl) {
$returnUrl = $this->_defaultPage;
}
 
// Add some entropy to the return to make it unique
// avoind problems with cached pages and proxies
if(strpos($returnUrl, '?') === false) {
162,7 → 162,7
// Track the auth status
if($this->auth->status != '') {
$url .= '&authstatus='.$this->auth->status;
}
}
header('Location:'.$returnUrl);
print("You could not be redirected to <a href=\"$returnUrl\">$returnUrl</a>");
}
169,10 → 169,10
 
// }}}
// {{{ redirectLogin()
 
/**
* Redirects to the login Page if not authorised
*
*
* put return page on the query or in auth
*
* @return void
180,10 → 180,10
function redirectLogin()
{
// Go to the login Page
 
// For Auth, put some check to avoid infinite redirects, this should at least exclude
// the login page
 
$url = $this->_loginPage;
if(strpos($url, '?') === false) {
$url .= '?';
204,7 → 204,7
 
// }}}
// {{{ start()
 
/**
* Starts the Auth Procedure
*
226,18 → 226,18
$this->auth->start();
// Logged on and on login page
if(strstr($_SERVER['PHP_SELF'], $this->_loginPage) && $this->auth->checkAuth()){
$this->autoRedirectBack ?
$this->autoRedirectBack ?
$this->redirectBack() :
null ;
}
}
 
 
}
 
// }}}
// {{{ isAuthorised()
 
/**
* Checks is the user is logged on
* @see Auth::checkAuth()
/trunk/api/pear/Auth/Anonymous.php
18,7 → 18,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Anonymous.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Anonymous.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.3.0
*/
30,8 → 30,8
 
/**
* Anonymous Authentication
*
* This class provides anonymous authentication if username and password
*
* This class provides anonymous authentication if username and password
* were not supplied
*
* @category Authentication
40,11 → 40,11
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.3.0
*/
class Auth_Anonymous extends Auth
class Auth_Anonymous extends Auth
{
 
// {{{ properties
65,10 → 65,10
 
// }}}
// {{{ Auth_Anonymous() [constructor]
 
/**
* Pass all parameters to Parent Auth class
*
*
* Set up the storage driver.
*
* @param string Type of the storage driver
87,10 → 87,10
 
// }}}
// {{{ login()
 
/**
* Login function
*
*
* If no username & password is passed then login as the username
* provided in $this->anonymous_username else call standard login()
* function.
100,8 → 100,8
* @see Auth::login()
*/
function login() {
if ( $this->allow_anonymous
&& empty($this->username)
if ( $this->allow_anonymous
&& empty($this->username)
&& empty($this->password) ) {
$this->setAuth($this->anonymous_username);
if (is_callable($this->loginCallback)) {
115,7 → 115,7
 
// }}}
// {{{ forceLogin()
 
/**
* Force the user to login
*
/trunk/api/pear/Auth/Frontend/Html.php
18,7 → 18,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Html.php,v 1.1 2006-12-14 15:04:29 jp_milcent Exp $
* @version CVS: $Id: Html.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.3.0
*/
25,7 → 25,7
 
/**
* Standard Html Login form
*
*
* @category Authentication
* @package Auth
* @author Yavor Shahpasov <yavo@netsmart.com.cy>
32,12 → 32,12
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.3.0
*/
class Auth_Frontend_Html {
 
// {{{ render()
 
/**
49,7 → 49,7
*/
function render(&$caller, $username = '') {
$loginOnClick = 'return true;';
 
// Try To Use Challene response
// TODO javascript might need some improvement for work on other browsers
if($caller->advancedsecurity && $caller->storage->supportsChallengeResponse() ) {
68,7 → 68,7
print ' var secret = document.getElementById(\'authsecret\')'."\n";
//print ' alert(pass);alert(secret); '."\n";
 
// If using md5 for password storage md5 the password before
// If using md5 for password storage md5 the password before
// we hash it with the secret
// print ' alert(pass.value);';
if ($caller->storage->getCryptType() == 'md5' ) {
101,7 → 101,7
} else if (!empty ($caller->status) && $caller->status == AUTH_SECURITY_BREACH) {
$status = '<i>Security problem detected. </i>'."\n";
}
 
print '<form method="post" action="'.$caller->server['PHP_SELF'].'" '
.'onSubmit="'.$loginOnClick.'">'."\n";
print '<table border="0" cellpadding="2" cellspacing="0" '
113,7 → 113,7
print '<tr>'."\n";
print ' <td>Username:</td>'."\n";
print ' <td><input type="text" id="'.$caller->getPostUsernameField()
.'" name="'.$caller->getPostUsernameField().'" value="' . $username
.'" name="'.$caller->getPostUsernameField().'" value="' . $username
.'" /></td>'."\n";
print '</tr>'."\n";
print '<tr>'."\n";
122,7 → 122,7
.'" name="'.$caller->getPostPasswordField().'" /></td>'."\n";
print '</tr>'."\n";
print '<tr>'."\n";
 
//onClick=" '.$loginOnClick.' "
print ' <td colspan="2" bgcolor="#eeeeee"><input value="Login" '
.'id="doLogin" name="doLogin" type="submit" /></td>'."\n";
129,7 → 129,7
print '</tr>'."\n";
print '</table>'."\n";
 
// Might be a good idea to make the variable name variable
// Might be a good idea to make the variable name variable
print '<input type="hidden" id="authsecret" name="authsecret" value="" />';
print '</form>'."\n";
print '</center>'."\n";
136,7 → 136,7
}
 
// }}}
 
}
 
?>
/trunk/api/pear/Auth/Container/KADM5.php
18,7 → 18,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: KADM5.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: KADM5.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.4.0
*/
48,7 → 48,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.4.0
*/
82,9 → 82,9
if (!extension_loaded('kadm5')) {
return PEAR::raiseError("Cannot use Kerberos V authentication, KADM5 extension not loaded!", 41, PEAR_ERROR_DIE);
}
 
$this->_setDefaults();
 
if (isset($options['hostname'])) {
$this->options['hostname'] = $options['hostname'];
}
97,7 → 97,7
if (isset($options['checkServer'])) {
$this->options['checkServer'] = $options['checkServer'];
}
 
if ($this->options['checkServer']) {
$this->_checkServer();
}
105,7 → 105,7
 
// }}}
// {{{ fetchData()
 
/**
* Try to login to the KADM5 server
*
114,14 → 114,15
* @return boolean
*/
function fetchData($username, $password) {
$this->log('Auth_Container_KADM5::fetchData() called.', AUTH_LOG_DEBUG);
if ( ($username == NULL) || ($password == NULL) ) {
return false;
}
 
$server = $this->options['hostname'];
$realm = $this->options['realm'];
$check = @kadm5_init_with_password($server, $realm, $username, $password);
 
if ($check == false) {
return false;
} else {
128,10 → 129,10
return true;
}
}
 
// }}}
// {{{ _setDefaults()
 
/**
* Set some default options
*
143,10 → 144,10
$this->options['timeout'] = 10;
$this->options['checkServer'] = false;
}
 
// }}}
// {{{ _checkServer()
 
/**
* Check if the given server and port are reachable
*
162,7 → 163,7
return PEAR::raiseError($message, 41, PEAR_ERROR_DIE);
}
}
 
// }}}
 
}
/trunk/api/pear/Auth/Container/MDB.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Lorenzo Alberton <l.alberton@quipo.it>
* @author Lorenzo Alberton <l.alberton@quipo.it>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: MDB.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: MDB.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.3
*/
44,7 → 44,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.3
*/
109,6 → 109,7
*/
function _connect($dsn)
{
$this->log('Auth_Container_MDB::_connect() called.', AUTH_LOG_DEBUG);
if (is_string($dsn) || is_array($dsn)) {
$this->db =& MDB::connect($dsn, $this->options['db_options']);
} elseif (is_subclass_of($dsn, 'mdb_common')) {
179,6 → 180,7
*/
function query($query)
{
$this->log('Auth_Container_MDB::query() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return $err;
204,6 → 206,7
$this->options['db_fields'] = '';
$this->options['cryptType'] = 'md5';
$this->options['db_options'] = array();
$this->options['db_where'] = '';
$this->options['auto_quote'] = true;
}
 
261,7 → 264,7
 
return '';
}
 
// }}}
// {{{ fetchData()
 
283,6 → 286,7
*/
function fetchData($username, $password, $isChallengeResponse=false)
{
$this->log('Auth_Container_MDB::fetchData() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
309,6 → 313,14
$this->db->getTextValue($username)
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " AND ".$this->options['db_where'];
}
 
$this->log('Running SQL against MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getRow($query, null, null, null, MDB_FETCHMODE_ASSOC);
 
if (MDB::isError($res) || PEAR::isError($res)) {
322,7 → 334,7
// Perform trimming here before the hashing
$password = trim($password, "\r\n");
$res[$this->options['passwordcol']] = trim($res[$this->options['passwordcol']], "\r\n");
 
// If using Challenge Response md5 the pass with the secret
if ($isChallengeResponse) {
$res[$this->options['passwordcol']] =
332,7 → 344,7
$res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]);
}
}
 
if ($this->verifyPassword($password,
$res[$this->options['passwordcol']],
$this->options['cryptType'])) {
342,6 → 354,8
$key == $this->options['usernamecol']) {
continue;
}
 
$this->log('Storing additional field: '.$key, AUTH_LOG_DEBUG);
// Use reference to the auth object if exists
// This is because the auth session variable can change so a static
// call to setAuthData does not make sense
365,6 → 379,7
*/
function listUsers()
{
$this->log('Auth_Container_MDB::listUsers() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
379,7 → 394,7
} else {
$sql_from = $this->options['final_usernamecol']
.', '.$this->options['final_passwordcol'];
 
if (strlen($fields = $this->_quoteDBFields()) > 0) {
$sql_from .= ', '.$fields;
}
390,6 → 405,14
$this->options['final_table']
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " WHERE ".$this->options['db_where'];
}
 
$this->log('Running SQL against MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getAll($query, null, null, null, MDB_FETCHMODE_ASSOC);
 
if (MDB::isError($res)) {
400,6 → 423,7
$retVal[] = $user;
}
}
$this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG);
return $retVal;
}
 
418,6 → 442,7
*/
function addUser($username, $password, $additional = "")
{
$this->log('Auth_Container_MDB::addUser() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
457,6 → 482,8
$additional_value
);
 
$this->log('Running SQL against MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB::isError($res)) {
478,6 → 505,7
*/
function removeUser($username)
{
$this->log('Auth_Container_MDB::removeUser() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
489,6 → 517,14
$this->db->getTextValue($username)
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " AND ".$this->options['db_where'];
}
 
$this->log('Running SQL against MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB::isError($res)) {
508,6 → 544,7
*/
function changePassword($username, $password)
{
$this->log('Auth_Container_MDB::changePassword() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
531,6 → 568,14
$this->db->getTextValue($username)
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " AND ".$this->options['db_where'];
}
 
$this->log('Running SQL against MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB::isError($res)) {
/trunk/api/pear/Auth/Container/SOAP.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Bruno Pedro <bpedro@co.sapo.pt>
* @author Bruno Pedro <bpedro@co.sapo.pt>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: SOAP.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: SOAP.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
83,7 → 83,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
170,6 → 170,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_SOAP::fetchData() called.', AUTH_LOG_DEBUG);
// check if all required options are set
if (array_intersect($this->_requiredOptions, array_keys($this->_options)) != $this->_requiredOptions) {
return false;
/trunk/api/pear/Auth/Container/DBLite.php
18,7 → 18,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: DBLite.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: DBLite.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.3.0
*/
45,7 → 45,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.3.0
*/
93,6 → 93,7
$this->options['db_fields'] = '';
$this->options['cryptType'] = 'md5';
$this->options['db_options'] = array();
$this->options['db_where'] = '';
$this->options['auto_quote'] = true;
 
if (is_array($dsn)) {
117,6 → 118,7
*/
function _connect(&$dsn)
{
$this->log('Auth_Container_DBLite::_connect() called.', AUTH_LOG_DEBUG);
if (is_string($dsn) || is_array($dsn)) {
$this->db =& DB::connect($dsn, $this->options['db_options']);
} elseif (is_subclass_of($dsn, "db_common")) {
218,7 → 220,7
 
return '';
}
 
// }}}
// {{{ fetchData()
 
237,6 → 239,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_DBLite::fetchData() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
255,10 → 258,19
$sql_from .= ', '.$fields;
}
}
 
$query = "SELECT ".$sql_from.
" FROM ".$this->options['final_table'].
" WHERE ".$this->options['final_usernamecol']." = ".$this->db->quoteSmart($username);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " AND ".$this->options['db_where'];
}
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);
 
if (DB::isError($res)) {
277,6 → 289,9
$key == $this->options['usernamecol']) {
continue;
}
 
$this->log('Storing additional field: '.$key, AUTH_LOG_DEBUG);
 
// Use reference to the auth object if exists
// This is because the auth session variable can change so a static call to setAuthData does not make sence
if (is_object($this->_auth_obj)) {
/trunk/api/pear/Auth/Container/SMBPasswd.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Michael Bretterklieber <michael@bretterklieber.com>
* @author Michael Bretterklieber <michael@bretterklieber.com>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: SMBPasswd.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: SMBPasswd.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.3
*/
56,7 → 56,7
* @package Auth
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.3
*/
104,14 → 104,16
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_SMBPasswd::fetchData() called.', AUTH_LOG_DEBUG);
return $this->pwfile->verifyAccount($username, $password);
}
 
// }}}
// {{{ listUsers()
 
function listUsers()
{
$this->log('Auth_Container_SMBPasswd::fetchData() called.', AUTH_LOG_DEBUG);
return $this->pwfile->getAccounts();
}
 
129,6 → 131,7
*/
function addUser($username, $password, $additional = '')
{
$this->log('Auth_Container_SMBPasswd::addUser() called.', AUTH_LOG_DEBUG);
$res = $this->pwfile->addUser($user, $additional['userid'], $pass);
if ($res === true) {
return $this->pwfile->save();
146,6 → 149,7
*/
function removeUser($username)
{
$this->log('Auth_Container_SMBPasswd::removeUser() called.', AUTH_LOG_DEBUG);
$res = $this->pwfile->delUser($username);
if ($res === true) {
return $this->pwfile->save();
160,15 → 164,16
* Change password for user in the storage container
*
* @param string Username
* @param string The new password
* @param string The new password
*/
function changePassword($username, $password)
{
$res = $this->pwfile->modUser($username, '', $password);
if ($res === true) {
return $this->pwfile->save();
}
return $res;
$this->log('Auth_Container_SMBPasswd::changePassword() called.', AUTH_LOG_DEBUG);
$res = $this->pwfile->modUser($username, '', $password);
if ($res === true) {
return $this->pwfile->save();
}
return $res;
}
 
// }}}
/trunk/api/pear/Auth/Container/Array.php
18,7 → 18,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Array.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Array.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @since File available since Release 1.4.0
*/
 
64,7 → 64,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @since File available since Release 1.4.0
*/
 
99,16 → 99,16
{
if (!is_array($data)) {
PEAR::raiseError('The options for Auth_Container_Array must be an array');
}
}
if (isset($data['users']) && is_array($data['users'])) {
$this->users = $data['users'];
} else {
$this->users = array();
PEAR::raiseError('Auth_Container_Array: no user data found inoptions array');
}
PEAR::raiseError('Auth_Container_Array: no user data found in options array');
}
if (isset($data['cryptType'])) {
$this->cryptType = $data['cryptType'];
}
}
}
 
// }}}
128,12 → 128,13
*/
function fetchData($user, $pass)
{
$this->log('Auth_Container_Array::fetchData() called.', AUTH_LOG_DEBUG);
if ( isset($this->users[$user])
&& $this->verifyPassword($pass, $this->users[$user], $this->cryptType)) {
return true;
}
return false;
}
}
 
// }}}
// {{{ listUsers()
145,15 → 146,16
*/
function listUsers()
{
$this->log('Auth_Container_Array::listUsers() called.', AUTH_LOG_DEBUG);
$ret = array();
foreach ($this->users as $username => $password) {
$ret[]['username'] = $username;
}
}
return $ret;
}
}
 
// }}}
 
}
}
 
?>
/trunk/api/pear/Auth/Container/File.php
14,14 → 14,14
*
* @category Authentication
* @package Auth
* @author Stefan Ekman <stekman@sedata.org>
* @author Stefan Ekman <stekman@sedata.org>
* @author Martin Jansen <mj@php.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Michael Wallner <mike@php.net>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: File.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: File.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
45,14 → 45,14
*
* @category Authentication
* @package Auth
* @author Stefan Ekman <stekman@sedata.org>
* @author Stefan Ekman <stekman@sedata.org>
* @author Martin Jansen <mj@php.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Michael Wallner <mike@php.net>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth_Container_File extends Auth_Container
62,7 → 62,7
 
/**
* Path to passwd file
*
*
* @var string
*/
var $pwfile = '';
85,7 → 85,7
*/
function Auth_Container_File($filename) {
$this->_setDefaults();
 
// Only file is a valid option here
if(is_array($filename)) {
$this->pwfile = $filename['file'];
107,19 → 107,22
*/
function fetchData($user, $pass)
{
$this->log('Auth_Container_File::fetchData() called.', AUTH_LOG_DEBUG);
return File_Passwd::staticAuth($this->options['type'], $this->pwfile, $user, $pass);
}
 
// }}}
// {{{ listUsers()
 
/**
* List all available users
*
*
* @return array
*/
function listUsers()
{
$this->log('Auth_Container_File::listUsers() called.', AUTH_LOG_DEBUG);
 
$pw_obj = &$this->_load();
if (PEAR::isError($pw_obj)) {
return array();
131,11 → 134,13
}
 
foreach ($users as $key => $value) {
$retVal[] = array("username" => $key,
$retVal[] = array("username" => $key,
"password" => $value['passwd'],
"cvsuser" => $value['system']);
}
 
$this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG);
 
return $retVal;
}
 
153,6 → 158,7
*/
function addUser($user, $pass, $additional='')
{
$this->log('Auth_Container_File::addUser() called.', AUTH_LOG_DEBUG);
$params = array($user, $pass);
if (is_array($additional)) {
foreach ($additional as $item) {
166,17 → 172,17
if (PEAR::isError($pw_obj)) {
return false;
}
 
$res = call_user_func_array(array(&$pw_obj, 'addUser'), $params);
if (PEAR::isError($res)) {
return false;
}
 
$res = $pw_obj->save();
if (PEAR::isError($res)) {
return false;
}
 
return true;
}
 
191,21 → 197,22
*/
function removeUser($user)
{
$this->log('Auth_Container_File::removeUser() called.', AUTH_LOG_DEBUG);
$pw_obj = &$this->_load();
if (PEAR::isError($pw_obj)) {
return false;
}
 
$res = $pw_obj->delUser($user);
if (PEAR::isError($res)) {
return false;
}
 
$res = $pw_obj->save();
if (PEAR::isError($res)) {
return false;
}
 
return true;
}
 
216,54 → 223,56
* Change password for user in the storage container
*
* @param string Username
* @param string The new password
* @param string The new password
*/
function changePassword($username, $password)
{
$this->log('Auth_Container_File::changePassword() called.', AUTH_LOG_DEBUG);
$pw_obj = &$this->_load();
if (PEAR::isError($pw_obj)) {
return false;
}
 
$res = $pw_obj->changePasswd($username, $password);
if (PEAR::isError($res)) {
return false;
}
 
$res = $pw_obj->save();
if (PEAR::isError($res)) {
return false;
}
 
return true;
}
 
// }}}
// {{{ _load()
 
/**
* Load and initialize the File_Passwd object
*
*
* @return object File_Passwd_Cvs|PEAR_Error
*/
function &_load()
{
static $pw_obj;
 
if (!isset($pw_obj)) {
$this->log('Instanciating File_Password object of type '.$this->options['type'], AUTH_LOG_DEBUG);
$pw_obj = File_Passwd::factory($this->options['type']);
if (PEAR::isError($pw_obj)) {
return $pw_obj;
}
 
$pw_obj->setFile($this->pwfile);
 
$res = $pw_obj->load();
if (PEAR::isError($res)) {
return $res;
}
}
 
return $pw_obj;
}
 
/trunk/api/pear/Auth/Container/LDAP.php
14,12 → 14,12
*
* @category Authentication
* @package Auth
* @author Jan Wagner <wagner@netsols.de>
* @author Jan Wagner <wagner@netsols.de>
* @author Adam Ashley <aashley@php.net>
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: LDAP.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: LDAP.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
103,7 → 103,7
* or the value of userattr (usually uid)
* group: the name of group to search for
* groupscope: Scope for group searching: one, sub (default), or base
* start_tls: enable/disable the use of START_TLS encrypted connection
* start_tls: enable/disable the use of START_TLS encrypted connection
* (default: false)
* debug: Enable/Disable debugging output (default: false)
* try_all: Whether to try all user accounts returned from the search
177,14 → 177,14
* It seems that binding anonymously to an Active Directory
* is not allowed, so you have to set binddn and bindpw for
* user searching.
*
*
* LDAP Referrals need to be set to false for AD to work sometimes.
*
* Example a3 shows a full blown and tested example for connection to
* Example a3 shows a full blown and tested example for connection to
* Windows 2000 Active Directory with group mebership checking
*
* Note also that if you want an encrypted connection to an MS LDAP
* server, then, on your webserver, you must specify
* Note also that if you want an encrypted connection to an MS LDAP
* server, then, on your webserver, you must specify
* TLS_REQCERT never
* in /etc/ldap/ldap.conf or in the webserver user's ~/.ldaprc (which
* may or may not be read depending on your configuration).
197,7 → 197,7
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth_Container_LDAP extends Auth_Container
275,29 → 275,34
*/
function _connect()
{
$this->log('Auth_Container_LDAP::_connect() called.', AUTH_LOG_DEBUG);
// connect
if (isset($this->options['url']) && $this->options['url'] != '') {
$this->_debug('Connecting with URL', __LINE__);
$this->log('Connecting with URL', AUTH_LOG_DEBUG);
$conn_params = array($this->options['url']);
} else {
$this->_debug('Connecting with host:port', __LINE__);
$this->log('Connecting with host:port', AUTH_LOG_DEBUG);
$conn_params = array($this->options['host'], $this->options['port']);
}
 
if (($this->conn_id = @call_user_func_array('ldap_connect', $conn_params)) === false) {
$this->log('Connection to server failed.', AUTH_LOG_DEBUG);
$this->log('LDAP ERROR: '.ldap_errno($this->conn_id).': '.ldap_error($this->conn_id), AUTH_LOG_DEBUG);
return PEAR::raiseError('Auth_Container_LDAP: Could not connect to server.', 41);
}
$this->_debug('Successfully connected to server', __LINE__);
$this->log('Successfully connected to server', AUTH_LOG_DEBUG);
 
// switch LDAP version
if (is_numeric($this->options['version']) && $this->options['version'] > 2) {
$this->_debug("Switching to LDAP version {$this->options['version']}", __LINE__);
$this->log("Switching to LDAP version {$this->options['version']}", AUTH_LOG_DEBUG);
@ldap_set_option($this->conn_id, LDAP_OPT_PROTOCOL_VERSION, $this->options['version']);
 
// start TLS if available
if (isset($this->options['start_tls']) && $this->options['start_tls']) {
$this->_debug("Starting TLS session", __LINE__);
if (isset($this->options['start_tls']) && $this->options['start_tls']) {
$this->log("Starting TLS session", AUTH_LOG_DEBUG);
if (@ldap_start_tls($this->conn_id) === false) {
$this->log('Could not start TLS session', AUTH_LOG_DEBUG);
$this->log('LDAP ERROR: '.ldap_errno($this->conn_id).': '.ldap_error($this->conn_id), AUTH_LOG_DEBUG);
return PEAR::raiseError('Auth_Container_LDAP: Could not start tls.', 41);
}
}
305,26 → 310,30
 
// switch LDAP referrals
if (is_bool($this->options['referrals'])) {
$this->_debug("Switching LDAP referrals to " . (($this->options['referrals']) ? 'true' : 'false'), __LINE__);
@ldap_set_option($this->conn_id, LDAP_OPT_REFERRALS, $this->options['referrals']);
$this->log("Switching LDAP referrals to " . (($this->options['referrals']) ? 'true' : 'false'), AUTH_LOG_DEBUG);
if (@ldap_set_option($this->conn_id, LDAP_OPT_REFERRALS, $this->options['referrals']) === false) {
$this->log('Could not change LDAP referrals options', AUTH_LOG_DEBUG);
$this->log('LDAP ERROR: '.ldap_errno($this->conn_id).': '.ldap_error($this->conn_id), AUTH_LOG_DEBUG);
}
}
 
// bind with credentials or anonymously
if (strlen($this->options['binddn']) && strlen($this->options['bindpw'])) {
$this->_debug('Binding with credentials', __LINE__);
$this->log('Binding with credentials', AUTH_LOG_DEBUG);
$bind_params = array($this->conn_id, $this->options['binddn'], $this->options['bindpw']);
} else {
$this->_debug('Binding anonymously', __LINE__);
$this->log('Binding anonymously', AUTH_LOG_DEBUG);
$bind_params = array($this->conn_id);
}
 
// bind for searching
if ((@call_user_func_array('ldap_bind', $bind_params)) === false) {
$this->_debug();
$this->log('Bind failed', AUTH_LOG_DEBUG);
$this->log('LDAP ERROR: '.ldap_errno($this->conn_id).': '.ldap_error($this->conn_id), AUTH_LOG_DEBUG);
$this->_disconnect();
return PEAR::raiseError("Auth_Container_LDAP: Could not bind to LDAP server.", 41);
}
$this->_debug('Binding was successful', __LINE__);
$this->log('Binding was successful', AUTH_LOG_DEBUG);
 
return true;
}
339,8 → 348,9
*/
function _disconnect()
{
$this->log('Auth_Container_LDAP::_disconnect() called.', AUTH_LOG_DEBUG);
if ($this->_isValidLink()) {
$this->_debug('disconnecting from server');
$this->log('disconnecting from server');
@ldap_unbind($this->conn_id);
}
}
355,6 → 365,7
*/
function _getBaseDN()
{
$this->log('Auth_Container_LDAP::_getBaseDN() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
361,13 → 372,13
}
 
if ($this->options['basedn'] == "" && $this->_isValidLink()) {
$this->_debug("basedn not set, searching via namingContexts.", __LINE__);
$this->log("basedn not set, searching via namingContexts.", AUTH_LOG_DEBUG);
 
$result_id = @ldap_read($this->conn_id, "", "(objectclass=*)", array("namingContexts"));
 
if (@ldap_count_entries($this->conn_id, $result_id) == 1) {
 
$this->_debug("got result for namingContexts", __LINE__);
$this->log("got result for namingContexts", AUTH_LOG_DEBUG);
 
$entry_id = @ldap_first_entry($this->conn_id, $result_id);
$attrs = @ldap_get_attributes($this->conn_id, $entry_id);
374,7 → 385,7
$basedn = $attrs['namingContexts'][0];
 
if ($basedn != "") {
$this->_debug("result for namingContexts was $basedn", __LINE__);
$this->log("result for namingContexts was $basedn", AUTH_LOG_DEBUG);
$this->options['basedn'] = $basedn;
}
}
430,7 → 441,6
$this->options['userattr'] = 'uid';
$this->options['userfilter'] = '(objectClass=posixAccount)';
$this->options['attributes'] = array(''); // no attributes
// $this->options['attrformat'] = 'LDAP'; // returns attribute array as PHP LDAP functions return it
$this->options['attrformat'] = 'AUTH'; // returns attribute like other Auth containers
$this->options['group'] = '';
$this->options['groupdn'] = '';
477,7 → 487,7
 
/**
* Adapt deprecated options from Auth 1.2 LDAP to Auth 1.3 LDAP
*
*
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @access private
* @param array
536,6 → 546,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_LDAP::fetchData() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
548,7 → 559,7
 
// UTF8 Encode username for LDAPv3
if (@ldap_get_option($this->conn_id, LDAP_OPT_PROTOCOL_VERSION, $ver) && $ver == 3) {
$this->_debug('UTF8 encoding username for LDAPv3', __LINE__);
$this->log('UTF8 encoding username for LDAPv3', AUTH_LOG_DEBUG);
$username = utf8_encode($username);
}
 
566,28 → 577,28
$search_basedn .= $this->options['basedn'];
 
// attributes
$attributes = $this->options['attributes'];
$searchAttributes = $this->options['attributes'];
 
// make functions params array
$func_params = array($this->conn_id, $search_basedn, $filter, $attributes);
$func_params = array($this->conn_id, $search_basedn, $filter, $searchAttributes);
 
// search function to use
$func_name = $this->_scope2function($this->options['userscope']);
 
$this->_debug("Searching with $func_name and filter $filter in $search_basedn", __LINE__);
$this->log("Searching with $func_name and filter $filter in $search_basedn", AUTH_LOG_DEBUG);
 
// search
if (($result_id = @call_user_func_array($func_name, $func_params)) === false) {
$this->_debug('User not found', __LINE__);
$this->log('User not found', AUTH_LOG_DEBUG);
} elseif (@ldap_count_entries($this->conn_id, $result_id) >= 1) { // did we get some possible results?
 
$this->_debug('User(s) found', __LINE__);
$this->log('User(s) found', AUTH_LOG_DEBUG);
 
$first = true;
$entry_id = null;
 
do {
 
// then get the user dn
if ($first) {
$entry_id = @ldap_first_entry($this->conn_id, $result_id);
600,11 → 611,11
$user_dn = @ldap_get_dn($this->conn_id, $entry_id);
 
// as the dn is not fetched as an attribute, we save it anyway
if (is_array($attributes) && in_array('dn', $attributes)) {
$this->_debug('Saving DN to AuthData', __LINE__);
if (is_array($searchAttributes) && in_array('dn', $searchAttributes)) {
$this->log('Saving DN to AuthData', AUTH_LOG_DEBUG);
$this->_auth_obj->setAuthData('dn', $user_dn);
}
 
// fetch attributes
if ($attributes = @ldap_get_attributes($this->conn_id, $entry_id)) {
 
625,7 → 636,7
// eg. $this->options['attrformat'] = 'AUTH'
 
if ( strtoupper($this->options['attrformat']) == 'AUTH' ) {
$this->_debug('Saving attributes to Auth data in AUTH format', __LINE__);
$this->log('Saving attributes to Auth data in AUTH format', AUTH_LOG_DEBUG);
unset ($attributes['count']);
foreach ($attributes as $attributeName => $attributeValue ) {
if (is_int($attributeName)) continue;
633,12 → 644,13
unset ($attributeValue['count']);
}
if (count($attributeValue)<=1) $attributeValue = $attributeValue[0];
$this->log('Storing additional field: '.$attributeName, AUTH_LOG_DEBUG);
$this->_auth_obj->setAuthData($attributeName, $attributeValue);
}
}
else
{
$this->_debug('Saving attributes to Auth data in LDAP format', __LINE__);
$this->log('Saving attributes to Auth data in LDAP format', AUTH_LOG_DEBUG);
$this->_auth_obj->setAuthData('attributes', $attributes);
}
}
648,21 → 660,21
// need to catch an empty password as openldap seems to return TRUE
// if anonymous binding is allowed
if ($password != "") {
$this->_debug("Bind as $user_dn", __LINE__);
$this->log("Bind as $user_dn", AUTH_LOG_DEBUG);
 
// try binding as this user with the supplied password
if (@ldap_bind($this->conn_id, $user_dn, $password)) {
$this->_debug('Bind successful', __LINE__);
$this->log('Bind successful', AUTH_LOG_DEBUG);
 
// check group if appropiate
if (strlen($this->options['group'])) {
// decide whether memberattr value is a dn or the username
$this->_debug('Checking group membership', __LINE__);
$this->log('Checking group membership', AUTH_LOG_DEBUG);
$return = $this->checkGroup(($this->options['memberisdn']) ? $user_dn : $username);
$this->_disconnect();
return $return;
} else {
$this->_debug('Authenticated', __LINE__);
$this->log('Authenticated', AUTH_LOG_DEBUG);
$this->_disconnect();
return true; // user authenticated
} // checkGroup
671,7 → 683,7
} while ($this->options['try_all'] == true); // interate through entries
} // get results
// default
$this->_debug('NOT authenticated!', __LINE__);
$this->log('NOT authenticated!', AUTH_LOG_DEBUG);
$this->_disconnect();
return false;
}
691,6 → 703,7
*/
function checkGroup($user)
{
$this->log('Auth_Container_LDAP::checkGroup() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
715,42 → 728,22
array($this->options['memberattr']));
$func_name = $this->_scope2function($this->options['groupscope']);
 
$this->_debug("Searching with $func_name and filter $filter in $search_basedn", __LINE__);
$this->log("Searching with $func_name and filter $filter in $search_basedn", AUTH_LOG_DEBUG);
 
// search
if (($result_id = @call_user_func_array($func_name, $func_params)) != false) {
if (@ldap_count_entries($this->conn_id, $result_id) == 1) {
@ldap_free_result($result_id);
$this->_debug('User is member of group', __LINE__);
$this->log('User is member of group', AUTH_LOG_DEBUG);
return true;
}
}
// default
$this->_debug('User is NOT member of group', __LINE__);
$this->log('User is NOT member of group', AUTH_LOG_DEBUG);
return false;
}
 
// }}}
// {{{ _debug()
 
/**
* Outputs debugging messages
*
* @access private
* @param string Debugging Message
* @param integer Line number
*/
function _debug($msg = '', $line = 0)
{
if ($this->options['debug'] == true) {
if ($msg == '' && $this->_isValidLink()) {
$msg = 'LDAP_Error: ' . @ldap_err2str(@ldap_errno($this->_conn_id));
}
print("$line: $msg <br />");
}
}
 
// }}}
// {{{ _quoteFilterString()
 
/**
/trunk/api/pear/Auth/Container/POP3.php
14,13 → 14,13
*
* @category Authentication
* @package Auth
* @author Stefan Ekman <stekman@sedata.org>
* @author Stefan Ekman <stekman@sedata.org>
* @author Martin Jansen <mj@php.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: POP3.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: POP3.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
44,11 → 44,11
* @category Authentication
* @package Auth
* @author Martin Jansen <mj@php.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
77,7 → 77,7
* String 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'
* - Attempt this authentication style first
* then fallback to autodetection.
* @var mixed
* @var mixed
*/
var $method=true;
 
127,9 → 127,11
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_POP3::fetchData() called.', AUTH_LOG_DEBUG);
$pop3 =& new Net_POP3();
$res = $pop3->connect($this->server, $this->port, $this->method);
if (!$res) {
$this->log('Connection to POP3 server failed.', AUTH_LOG_DEBUG);
return $res;
}
$result = $pop3->login($username, $password);
/trunk/api/pear/Auth/Container/SAP.php
20,7 → 20,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: SAP.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: SAP.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.4.0
*/
48,13 → 48,13
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @since Class available since Release 1.4.0
*/
class Auth_Container_SAP extends Auth_Container {
 
// {{{ properties
 
/**
* @var array Default options
*/
116,6 → 116,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_SAP::fetchData() called.', AUTH_LOG_DEBUG);
$connection_options = $this->options;
$connection_options['USER'] = $username;
$connection_options['PASSWD'] = $password;
130,6 → 131,7
return false;
} else {
if (!empty($this->options['GETSSO2'])) {
$this->log('Attempting to retrieve SSO2 ticket.', AUTH_LOG_DEBUG);
if ($ticket = @saprfc_get_ticket($rfc)) {
$this->options['MYSAPSSO2'] = $ticket;
unset($this->options['GETSSO2']);
141,7 → 143,7
@saprfc_close($rfc);
return true;
}
 
}
 
// }}}
/trunk/api/pear/Auth/Container/MDB2.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Lorenzo Alberton <l.alberton@quipo.it>
* @author Lorenzo Alberton <l.alberton@quipo.it>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: MDB2.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: MDB2.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.3.0
*/
44,7 → 44,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.3.0
*/
109,6 → 109,7
*/
function _connect($dsn)
{
$this->log('Auth_Container_MDB2::_connect() called.', AUTH_LOG_DEBUG);
if (is_string($dsn) || is_array($dsn)) {
$this->db =& MDB2::connect($dsn, $this->options['db_options']);
} elseif (is_subclass_of($dsn, 'MDB2_Driver_Common')) {
128,7 → 129,7
if (MDB2::isError($this->db) || PEAR::isError($this->db)) {
return PEAR::raiseError($this->db->getMessage(), $this->db->code);
}
 
if ($this->options['auto_quote']) {
$this->options['final_table'] = $this->db->quoteIdentifier($this->options['table'], true);
$this->options['final_usernamecol'] = $this->db->quoteIdentifier($this->options['usernamecol'], true);
138,7 → 139,7
$this->options['final_usernamecol'] = $this->options['usernamecol'];
$this->options['final_passwordcol'] = $this->options['passwordcol'];
}
 
return true;
}
 
179,6 → 180,7
*/
function query($query)
{
$this->log('Auth_Container_MDB2::query() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return $err;
204,6 → 206,7
$this->options['db_fields'] = '';
$this->options['cryptType'] = 'md5';
$this->options['db_options'] = array();
$this->options['db_where'] = '';
$this->options['auto_quote'] = true;
}
 
261,7 → 264,7
 
return '';
}
 
// }}}
// {{{ fetchData()
 
283,6 → 286,7
*/
function fetchData($username, $password, $isChallengeResponse=false)
{
$this->log('Auth_Container_MDB2::fetchData() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
308,6 → 312,14
$this->db->quote($username, 'text')
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " AND ".$this->options['db_where'];
}
 
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->queryRow($query, null, MDB2_FETCHMODE_ASSOC);
if (MDB2::isError($res) || PEAR::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode());
338,6 → 350,9
$key == $this->options['usernamecol']) {
continue;
}
 
$this->log('Storing additional field: '.$key, AUTH_LOG_DEBUG);
 
// Use reference to the auth object if exists
// This is because the auth session variable can change so a static call to setAuthData does not make sense
$this->_auth_obj->setAuthData($key, $value);
360,6 → 375,7
*/
function listUsers()
{
$this->log('Auth_Container_MDB2::listUsers() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
385,6 → 401,14
$this->options['final_table']
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " WHERE ".$this->options['db_where'];
}
 
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
if (MDB2::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode());
394,6 → 418,7
$retVal[] = $user;
}
}
$this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG);
return $retVal;
}
 
412,6 → 437,7
*/
function addUser($username, $password, $additional = "")
{
$this->log('Auth_Container_MDB2::addUser() called.', AUTH_LOG_DEBUG);
 
// Prepare for a database query
$err = $this->_prepare();
453,6 → 479,8
$additional_value
);
 
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB2::isError($res)) {
474,6 → 502,7
*/
function removeUser($username)
{
$this->log('Auth_Container_MDB2::removeUser() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
486,6 → 515,14
$this->db->quote($username, 'text')
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " AND ".$this->options['db_where'];
}
 
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB2::isError($res)) {
505,6 → 542,7
*/
function changePassword($username, $password)
{
$this->log('Auth_Container_MDB2::changePassword() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
529,6 → 567,14
$this->db->quote($username, 'text')
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " AND ".$this->options['db_where'];
}
 
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB2::isError($res)) {
/trunk/api/pear/Auth/Container/DB.php
18,7 → 18,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: DB.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: DB.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
43,7 → 43,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth_Container_DB extends Auth_Container
109,6 → 109,8
*/
function _connect($dsn)
{
$this->log('Auth_Container_DB::_connect() called.', AUTH_LOG_DEBUG);
 
if (is_string($dsn) || is_array($dsn)) {
$this->db = DB::Connect($dsn, $this->options['db_options']);
} elseif (is_subclass_of($dsn, 'db_common')) {
205,6 → 207,7
$this->options['db_fields'] = '';
$this->options['cryptType'] = 'md5';
$this->options['db_options'] = array();
$this->options['db_where'] = '';
$this->options['auto_quote'] = true;
}
 
262,7 → 265,7
 
return '';
}
 
// }}}
// {{{ fetchData()
 
284,6 → 287,7
*/
function fetchData($username, $password, $isChallengeResponse=false)
{
$this->log('Auth_Container_DB::fetchData() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
307,6 → 311,14
" FROM ".$this->options['final_table'].
" WHERE ".$this->options['final_usernamecol']." = ".$this->db->quoteSmart($username);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " AND ".$this->options['db_where'];
}
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);
 
if (DB::isError($res)) {
326,12 → 338,12
if ($isChallengeResponse) {
$res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]
.$this->_auth_obj->session['loginchallenege']);
 
// UGLY cannot avoid without modifying verifyPassword
if ($this->options['cryptType'] == 'md5') {
$res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]);
}
 
//print " Hashed Password [{$res[$this->options['passwordcol']]}]<br/>\n";
}
 
344,8 → 356,11
$key == $this->options['usernamecol']) {
continue;
}
 
$this->log('Storing additional field: '.$key, AUTH_LOG_DEBUG);
 
// Use reference to the auth object if exists
// This is because the auth session variable can change so a
// This is because the auth session variable can change so a
// static call to setAuthData does not make sence
$this->_auth_obj->setAuthData($key, $value);
}
366,6 → 381,7
*/
function listUsers()
{
$this->log('Auth_Container_DB::listUsers() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
390,6 → 406,15
$sql_from,
$this->options['final_table']
);
 
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$query .= " WHERE ".$this->options['db_where'];
}
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC);
 
if (DB::isError($res)) {
400,6 → 425,7
$retVal[] = $user;
}
}
$this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG);
return $retVal;
}
 
418,15 → 444,16
*/
function addUser($username, $password, $additional = "")
{
$this->log('Auth_Container_DB::addUser() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
 
if ( isset($this->options['cryptType'])
if ( isset($this->options['cryptType'])
&& $this->options['cryptType'] == 'none') {
$cryptFunction = 'strval';
} elseif ( isset($this->options['cryptType'])
} elseif ( isset($this->options['cryptType'])
&& function_exists($this->options['cryptType'])) {
$cryptFunction = $this->options['cryptType'];
} else {
459,6 → 486,8
$additional_value
);
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (DB::isError($res)) {
481,17 → 510,30
*/
function removeUser($username)
{
$this->log('Auth_Container_DB::removeUser() called.', AUTH_LOG_DEBUG);
 
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
 
$query = sprintf("DELETE FROM %s WHERE %s = %s",
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$where = " AND ".$this->options['db_where'];
} else {
$where = '';
}
 
$query = sprintf("DELETE FROM %s WHERE %s = %s %s",
$this->options['final_table'],
$this->options['final_usernamecol'],
$this->db->quoteSmart($username)
$this->db->quoteSmart($username),
$where
);
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (DB::isError($res)) {
512,15 → 554,16
*/
function changePassword($username, $password)
{
$this->log('Auth_Container_DB::changePassword() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
 
if ( isset($this->options['cryptType'])
if ( isset($this->options['cryptType'])
&& $this->options['cryptType'] == 'none') {
$cryptFunction = 'strval';
} elseif ( isset($this->options['cryptType'])
} elseif ( isset($this->options['cryptType'])
&& function_exists($this->options['cryptType'])) {
$cryptFunction = $this->options['cryptType'];
} else {
529,14 → 572,25
 
$password = $cryptFunction($password);
 
$query = sprintf("UPDATE %s SET %s = %s WHERE %s = %s",
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$where = " AND ".$this->options['db_where'];
} else {
$where = '';
}
 
$query = sprintf("UPDATE %s SET %s = %s WHERE %s = %s %s",
$this->options['final_table'],
$this->options['final_passwordcol'],
$this->db->quoteSmart($password),
$this->options['final_usernamecol'],
$this->db->quoteSmart($username)
$this->db->quoteSmart($username),
$where
);
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (DB::isError($res)) {
/trunk/api/pear/Auth/Container/IMAP.php
14,17 → 14,17
*
* @category Authentication
* @package Auth
* @author Jeroen Houben <jeroen@terena.nl>
* @author Jeroen Houben <jeroen@terena.nl>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: IMAP.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: IMAP.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
 
/**
* Include Auth_Container base class
* Include Auth_Container base class
*/
require_once "Auth/Container.php";
 
77,7 → 77,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
148,6 → 148,7
* @access private
*/
function _checkServer() {
$this->log('Auth_Container_IMAP::_checkServer() called.', AUTH_LOG_DEBUG);
$fp = @fsockopen ($this->options['host'], $this->options['port'],
$errno, $errstr, $this->options['timeout']);
if (is_resource($fp)) {
188,13 → 189,16
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_IMAP::fetchData() called.', AUTH_LOG_DEBUG);
$dsn = '{'.$this->options['host'].':'.$this->options['port'].$this->options['baseDSN'].'}';
$conn = @imap_open ($dsn, $username, $password, OP_HALFOPEN);
if (is_resource($conn)) {
$this->log('Successfully connected to IMAP server.', AUTH_LOG_DEBUG);
$this->activeUser = $username;
@imap_close($conn);
return true;
} else {
$this->log('Connection to IMAP server failed.', AUTH_LOG_DEBUG);
$this->activeUser = '';
return false;
}
/trunk/api/pear/Auth/Container/vpopmail.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Stanislav Grozev <tacho@orbitel.bg>
* @author Stanislav Grozev <tacho@orbitel.bg>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: vpopmail.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: vpopmail.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
41,7 → 41,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
74,6 → 74,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_vpopmail::fetchData() called.', AUTH_LOG_DEBUG);
$userdata = array();
$userdata = preg_split("/@/", $username, 2);
$result = @vpopmail_auth_user($userdata[0], $userdata[1], $password);
/trunk/api/pear/Auth/Container/SOAP5.php
19,7 → 19,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: SOAP5.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: SOAP5.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @since File available since Release 1.4.0
*/
 
38,7 → 38,7
* thats using the PEAR SOAP Package.
*
* This class takes one parameter (options), where
* you specify the following fields:
* you specify the following fields:
* * location and uri, or wsdl file
* * method to call on the SOAP service
* * usernamefield, the name of the parameter where the username is supplied
58,10 → 58,10
* 'wsdl' => NULL,
* 'location' => 'http://your.soap.service/endpoint',
* 'uri' => 'urn:/Your/Namespace',
* 'method' => 'checkAuth',
* 'method' => 'checkAuth',
* 'usernamefield' => 'username',
* 'passwordfield' => 'password',
* 'matchpasswords' => false,
* 'matchpasswords' => false,
* '_features' => array (
* 'extra_parameter' => 'example_value',
* 'another_parameter' => 'foobar'
79,10 → 79,10
*
* $options = array (
* 'wsdl' => 'http://your.soap.service/wsdl',
* 'method' => 'checkAuth',
* 'method' => 'checkAuth',
* 'usernamefield' => 'username',
* 'passwordfield' => 'password',
* 'matchpasswords' => false,
* 'matchpasswords' => false,
* '_features' => array (
* 'extra_parameter' => 'example_value',
* 'another_parameter' => 'foobar'
101,7 → 101,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @since Class available since Release 1.4.0
*/
class Auth_Container_SOAP5 extends Auth_Container
115,7 → 115,7
* @access private
*/
var $_requiredOptions = array(
'location',
'location',
'uri',
'method',
'usernamefield',
143,7 → 143,7
* @access public
*/
var $soapResponse = array();
 
// }}}
// {{{ Auth_Container_SOAP5()
 
164,7 → 164,7
if (!empty($this->_options['_features'])) {
$this->_features = $this->_options['_features'];
unset($this->_options['_features']);
}
}
}
 
// }}}
181,7 → 181,8
* @return mixed Returns the SOAP response or false if something went wrong
*/
function fetchData($username, $password)
{
{
$this->log('Auth_Container_SOAP5::fetchData() called.', AUTH_LOG_DEBUG);
$result = $this->_validateOptions();
if (PEAR::isError($result))
return $result;
188,8 → 189,8
 
// create a SOAP client
$soapClient = new SoapClient($this->_options["wsdl"], $this->_options);
$params = array();
 
$params = array();
// first, assign the optional features
foreach ($this->_features as $fieldName => $fieldValue) {
$params[$fieldName] = $fieldValue;
196,11 → 197,11
}
// assign username and password ...
$params[$this->_options['usernamefield']] = $username;
$params[$this->_options['passwordfield']] = $password;
$params[$this->_options['passwordfield']] = $password;
 
try {
$this->soapResponse = $soapClient->__soapCall($this->_options['method'], $params);
 
if ($this->_options['matchpasswords']) {
// check if passwords match
if ($password == $this->soapResponse[$this->_options['passwordfield']]) {
208,17 → 209,17
} else {
return false;
}
} else {
} else {
return true;
}
} catch (SoapFault $e) {
return PEAR::raiseError("Error retrieving authentication data. Received SOAP Fault: ".$e->faultstring, $e->faultcode);
}
}
}
 
// }}}
// {{{ _validateOptions()
 
/**
* Validate that the options passed to the container class are enough for us to proceed
*
225,22 → 226,22
* @access private
* @param array
*/
function _validateOptions($array)
function _validateOptions()
{
if ( ( is_null($this->options['wsdl'])
&& is_null($this->options['location'])
&& is_null($this->options['uri']))
|| ( is_null($this->options['wsdl'])
&& ( is_null($this->options['location'])
|| is_null($this->options['uri'])))) {
if ( ( is_null($this->_options['wsdl'])
&& is_null($this->_options['location'])
&& is_null($this->_options['uri']))
|| ( is_null($this->_options['wsdl'])
&& ( is_null($this->_options['location'])
|| is_null($this->_options['uri'])))) {
return PEAR::raiseError('Either a WSDL file or a location/uri pair must be specified.');
}
if (is_null($this->options['method'])) {
if (is_null($this->_options['method'])) {
return PEAR::raiseError('A method to call on the soap service must be specified.');
}
return true;
}
 
// }}}
// {{{ _setDefaults()
 
252,16 → 253,16
*/
function _setDefaults()
{
$this->options['wsdl'] = null;
$this->options['location'] = null;
$this->options['uri'] = null;
$this->options['method'] = null;
$this->options['usernamefield'] = 'username';
$this->options['passwordfield'] = 'password';
$this->options['matchpasswords'] = true;
$this->_options['wsdl'] = null;
$this->_options['location'] = null;
$this->_options['uri'] = null;
$this->_options['method'] = null;
$this->_options['usernamefield'] = 'username';
$this->_options['passwordfield'] = 'password';
$this->_options['matchpasswords'] = true;
}
 
// }}}
 
}
?>
/trunk/api/pear/Auth/Container/PEAR.php
18,19 → 18,19
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: PEAR.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: PEAR.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.3.0
*/
 
/**
* Include PEAR HTTP_Client.
*/
require_once 'HTTP/Client.php';
/**
* Include Auth_Container base class
*/
require_once 'Auth/Container.php';
/**
* Include PEAR XML_RPC
*/
require_once 'XML/RPC.php';
 
/**
* Storage driver for authenticating against PEAR website
42,9 → 42,10
* @package Auth
* @author Yavor Shahpasov <yavo@netsmart.com.cy>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @author Adam Harvey <aharvey@php.net>
* @copyright 2001-2007 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.1 $
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.3.0
*/
57,17 → 58,17
* Constructor
*
* Currently does nothing
*
*
* @return void
*/
function Auth_Container_Pear()
{
 
}
 
// }}}
// {{{ fetchData()
 
/**
* Get user information from pear.php.net
*
80,24 → 81,35
*/
function fetchData($username, $password)
{
$rpc = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net');
$rpc_message = new XML_RPC_Message("user.info", array(new XML_RPC_Value($username, "string")) );
// Error Checking howto ???
$result = $rpc->send($rpc_message);
$value = $result->value();
$userinfo = xml_rpc_decode($value);
if ($userinfo['password'] == md5($password)) {
$this->activeUser = $userinfo['handle'];
foreach ($userinfo as $uk=>$uv) {
$this->_auth_obj->setAuthData($uk, $uv);
}
return true;
$this->log('Auth_Container_PEAR::fetchData() called.', AUTH_LOG_DEBUG);
 
$client = new HTTP_Client;
 
$this->log('Auth_Container_PEAR::fetchData() getting salt.', AUTH_LOG_DEBUG);
$code = $client->get('https://pear.php.net/rest-login.php/getsalt');
if ($code != 200) {
return PEAR::raiseError('Bad response to salt request.', $code);
}
return false;
$resp = $client->currentResponse();
$salt = $resp['body'];
 
$this->log('Auth_Container_PEAR::fetchData() calling validate.', AUTH_LOG_DEBUG);
$code = $client->post('https://pear.php.net/rest-login.php/validate',
array('username' => $username,
'password' => md5($salt.md5($password))));
if ($code != 200) {
return PEAR::raiseError('Bad response to validate request.', $code);
}
$resp = $client->currentResponse();
 
list($code, $message) = explode(' ', $resp['body'], 1);
if ($code != 8) {
return PEAR::raiseError($message, $code);
}
return true;
}
 
// }}}
 
}
?>
/trunk/api/pear/Auth/Container/RADIUS.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Michael Bretterklieber <michael@bretterklieber.com>
* @author Michael Bretterklieber <michael@bretterklieber.com>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: RADIUS.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: RADIUS.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
41,7 → 41,7
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.4.3 File: $Revision: 1.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
55,12 → 55,12
* @var object
*/
var $radius;
 
/**
* Contains the authentication type
* @var string
*/
var $authtype;
var $authtype;
 
// }}}
// {{{ Auth_Container_RADIUS() [constructor]
89,7 → 89,7
PEAR::raiseError("Unknown Authtype, please use one of: "
."PAP, CHAP_MD5, MSCHAPv1, MSCHAPv2!", 41, PEAR_ERROR_DIE);
}
 
$this->radius = new $classname;
 
if (isset($options['configfile'])) {
107,7 → 107,7
$this->radius->addServer($servername, $port, $sharedsecret, $timeout, $maxtries);
}
}
 
if (!$this->radius->start()) {
PEAR::raiseError($this->radius->getError(), 41, PEAR_ERROR_DIE);
}
125,38 → 125,40
*/
function fetchData($username, $password, $challenge = null)
{
$this->log('Auth_Container_RADIUS::fetchData() called.', AUTH_LOG_DEBUG);
 
switch($this->authtype) {
case 'CHAP_MD5':
case 'MSCHAPv1':
if (isset($challenge)) {
$this->radius->challenge = $challenge;
$this->radius->chapid = 1;
$this->radius->response = pack('H*', $password);
} else {
case 'CHAP_MD5':
case 'MSCHAPv1':
if (isset($challenge)) {
$this->radius->challenge = $challenge;
$this->radius->chapid = 1;
$this->radius->response = pack('H*', $password);
} else {
require_once 'Crypt/CHAP.php';
$classname = 'Crypt_' . $this->authtype;
$crpt = new $classname;
$crpt->password = $password;
$this->radius->challenge = $crpt->challenge;
$this->radius->chapid = $crpt->chapid;
$this->radius->response = $crpt->challengeResponse();
}
break;
 
case 'MSCHAPv2':
require_once 'Crypt/CHAP.php';
$classname = 'Crypt_' . $this->authtype;
$crpt = new $classname;
$crpt = new Crypt_MSCHAPv2;
$crpt->username = $username;
$crpt->password = $password;
$this->radius->challenge = $crpt->challenge;
$this->radius->chapid = $crpt->chapid;
$this->radius->response = $crpt->challengeResponse();
$this->radius->challenge = $crpt->authChallenge;
$this->radius->peerChallenge = $crpt->peerChallenge;
$this->radius->chapid = $crpt->chapid;
$this->radius->response = $crpt->challengeResponse();
break;
}
 
case 'MSCHAPv2':
require_once 'Crypt/CHAP.php';
$crpt = new Crypt_MSCHAPv2;
$crpt->username = $username;
$crpt->password = $password;
$this->radius->challenge = $crpt->authChallenge;
$this->radius->peerChallenge = $crpt->peerChallenge;
$this->radius->chapid = $crpt->chapid;
$this->radius->response = $crpt->challengeResponse();
break;
 
default:
$this->radius->password = $password;
break;
default:
$this->radius->password = $password;
break;
}
 
$this->radius->username = $username;
/trunk/api/pear/Auth/Container/Multiple.php
New file
0,0 → 1,188
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
 
/**
* Storage driver for using multiple storage drivers in a fall through fashion
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category Authentication
* @package Auth
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Multiple.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @since File available since Release 1.5.0
*/
 
/**
* Include Auth_Container base class
*/
require_once "Auth/Container.php";
/**
* Include PEAR package for error handling
*/
require_once "PEAR.php";
 
/**
* Storage driver for using multiple storage drivers in a fall through fashion
*
* This storage driver provides a mechanism for working through multiple
* storage drivers until either one allows successful login or the list is
* exhausted.
*
* This container takes an array of options of the following form:
*
* array(
* array(
* 'type' => <standard container type name>,
* 'options' => <normal array of options for container>,
* ),
* );
*
* Full example:
*
* $options = array(
* array(
* 'type' => 'DB',
* 'options' => array(
* 'dsn' => "mysql://user:password@localhost/database",
* ),
* ),
* array(
* 'type' => 'Array',
* 'options' => array(
* 'cryptType' => 'md5',
* 'users' => array(
* 'admin' => md5('password'),
* ),
* ),
* ),
* );
*
* $auth = new Auth('Multiple', $options);
*
* @category Authentication
* @package Auth
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.5.4 File: $Revision: 1.2 $
* @since File available since Release 1.5.0
*/
 
class Auth_Container_Multiple extends Auth_Container {
 
// {{{ properties
 
/**
* The options for each container
*
* @var array $options
*/
var $options = array();
 
/**
* The instanciated containers
*
* @var array $containers
*/
var $containers = array();
 
// }}}
// {{{ Auth_Container_Multiple()
 
/**
* Constructor for Array Container
*
* @param array $data Options for the container
* @return void
*/
function Auth_Container_Multiple($options)
{
if (!is_array($options)) {
PEAR::raiseError('The options for Auth_Container_Multiple must be an array');
}
if (count($options) < 1) {
PEAR::raiseError('You must define at least one sub container to use in Auth_Container_Multiple');
}
foreach ($options as $option) {
if (!isset($option['type'])) {
PEAR::raiseError('No type defined for sub container');
}
}
$this->options = $options;
}
 
// }}}
// {{{ fetchData()
 
/**
* Get user information from array
*
* This function uses the given username to fetch the corresponding
* login data from the array. If an account that matches the passed
* username and password is found, the function returns true.
* Otherwise it returns false.
*
* @param string Username
* @param string Password
* @return boolean|PEAR_Error Error object or boolean
*/
function fetchData($user, $pass)
{
$this->log('Auth_Container_Multiple::fetchData() called.', AUTH_LOG_DEBUG);
 
foreach ($this->options as $key => $options) {
 
$this->log('Using Container '.$key.' of type '.$options['type'].'.', AUTH_LOG_DEBUG);
 
if (isset($this->containers[$key]) && is_a($this->containers[$key], 'Auth_Container')) {
 
$container = &$this->containers[$key];
 
} else {
 
$this->containers[$key] = &$this->_auth_obj->_factory($options['type'], $options['options']);
$this->containers[$key]->_auth_obj = &$this->_auth_obj;
$container = &$this->containers[$key];
 
}
 
$result = $container->fetchData($user, $pass);
 
if (PEAR::isError($result)) {
 
$this->log('Container '.$key.': '.$result->getMessage(), AUTH_LOG_ERR);
return $result;
 
} elseif ($result == true) {
 
$this->log('Container '.$key.': Authentication successful.', AUTH_LOG_DEBUG);
return true;
 
} else {
 
$this->log('Container '.$key.': Authentication failed.', AUTH_LOG_DEBUG);
 
}
 
}
 
$this->log('Auth_Container_Multiple: All containers rejected user credentials.', AUTH_LOG_DEBUG);
 
return false;
 
}
 
// }}}
 
}
 
?>