[geeklog-cvs] Auth_Enterprise/Server/providers AEBaseProvider.class.php,1.1.1.1,1.2 AEPearDB.class.php,1.1.1.1,1.2
tony at geeklog.net
tony at geeklog.net
Tue Oct 28 19:52:43 EST 2003
- Previous message (by thread): [geeklog-cvs] Auth_Enterprise/Client AEBaseClientProvider.class.php,1.1.1.1,1.2 AEClient.class.php,1.1.1.1,1.2 AEClientProviderFactory.class.php,1.1.1.1,1.2 AEUser.class.php,1.1.1.1,1.2 AEXMLRPC.class.php,1.1.1.1,1.2
- Next message (by thread): [geeklog-cvs] Auth_Enterprise/Common AEGroup.class.php,1.1.1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvs/geeklog/Auth_Enterprise/Server/providers
In directory geeklog_prod:/tmp/cvs-serv1664/Server/providers
Modified Files:
AEBaseProvider.class.php AEPearDB.class.php
Log Message:
Authenticate method nearly complete using XML_RPC
Index: AEBaseProvider.class.php
===================================================================
RCS file: /usr/cvs/geeklog/Auth_Enterprise/Server/providers/AEBaseProvider.class.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** AEBaseProvider.class.php 23 Oct 2003 14:17:35 -0000 1.1.1.1
--- AEBaseProvider.class.php 29 Oct 2003 00:52:40 -0000 1.2
***************
*** 1,121 ****
<?php
!
! /**
! * Auth_Enterprise Server Common Include File
! *
! * Files needed by all server implementations should be included here
! *
! * This source file is subject to version 2.02 of the PHP license,
! * that is bundled with this package in the file LICENSE, and is
! * available at through the world-wide-web at
! * http://www.php.net/license/2_02.txt.
! * If you did not receive a copy of the PHP license and are unable to
! * obtain it through the world-wide-web, please send a note to
! * license at php.net so we can mail you a copy immediately.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @copyright 2003
! * @version $Id$
! *
! */
!
! /**
! * The Auth_Enterprise service inteface
*/
require_once 'Auth_Enterprise/Common/AEServiceInterface.class.php';
!
! /**
! * The base provider class.
! *
! * The base provider is an abstract class from which all
! * Auth_Enterprise providers inherit from. A provider is
! * instantiated by the service at run time. Which provider
! * an application uses depends on what it wants to authenticate
! * against. For example, you could have an LDAP provider, a
! * an IMAP provider, a /etc/passwd provider, etc.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @package net.geeklog.auth_enterprise.server
! *
! */
! class AEBaseProvider extends AEServiceInterface {
! /**
! * Authenticates a user to an application
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function authenticate()
! {
! }
!
! /**
! * Registers a new account with the service
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function createAccount()
! {
! }
!
! /**
! * Changes a user's password
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function changePassword()
! {
! }
!
! /**
! * Allows an application level admin to change a
! * user's password
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function changePasswordByAdmin()
! {
! }
!
! /**
! * Gets the application privileges for a given user
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function getUserPrivileges()
! {
! }
!
! /**
! * Sets the application privileges for a given user
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function setUserPrivileges()
! {
}
!
! /**
! * Lists all available privileges for a given application
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function listAppPrivileges()
! {
}
}
-
?>
--- 1,115 ----
<?php
! /**
! * Auth_Enterprise Server Common Include File
! *
! * Files needed by all server implementations should be included here
! *
! * This source file is subject to version 2.02 of the PHP license,
! * that is bundled with this package in the file LICENSE, and is
! * available at through the world-wide-web at
! * http://www.php.net/license/2_02.txt.
! * If you did not receive a copy of the PHP license and are unable to
! * obtain it through the world-wide-web, please send a note to
! * license at php.net so we can mail you a copy immediately.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @copyright 2003
! * @version $Id$
! *
*/
+ /**
+ * The Auth_Enterprise service inteface
+ */
require_once 'Auth_Enterprise/Common/AEServiceInterface.class.php';
! /**
! * The base provider class.
! *
! * The base provider is an abstract class from which all
! * Auth_Enterprise providers inherit from. A provider is
! * instantiated by the service at run time. Which provider
! * an application uses depends on what it wants to authenticate
! * against. For example, you could have an LDAP provider, a
! * an IMAP provider, a /etc/passwd provider, etc.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @package net.geeklog.auth_enterprise.server
! *
! */
! class AEBaseProvider extends AEServiceInterface {
! /**
! * Authenticates a user to an application
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function authenticate()
! {
! }
!
! /**
! * Registers a new account with the service
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function createAccount()
! {
}
! /**
! * Changes a user's password
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function changePassword()
! {
! }
!
! /**
! * Allows an application level admin to change a
! * user's password
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function changePasswordByAdmin()
! {
! }
!
! /**
! * Gets the application privileges for a given user
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function getUserPrivileges()
! {
! }
!
! /**
! * Sets the application privileges for a given user
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function setUserPrivileges()
! {
}
+ /**
+ * Lists all available privileges for a given application
+ *
+ * @author Tony Bibbs <tony at geeklog.net>
+ * @access public
+ *
+ */
+ function listAppPrivileges()
+ {
+ }
}
?>
Index: AEPearDB.class.php
===================================================================
RCS file: /usr/cvs/geeklog/Auth_Enterprise/Server/providers/AEPearDB.class.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** AEPearDB.class.php 23 Oct 2003 14:17:35 -0000 1.1.1.1
--- AEPearDB.class.php 29 Oct 2003 00:52:40 -0000 1.2
***************
*** 1,224 ****
<?php
!
! /**
! * Auth_Enterprise
! *
! * This source file is subject to version 2.02 of the PHP license,
! * that is bundled with this package in the file LICENSE, and is
! * available at through the world-wide-web at
! * http://www.php.net/license/2_02.txt.
! * If you did not receive a copy of the PHP license and are unable to
! * obtain it through the world-wide-web, please send a note to
! * license at php.net so we can mail you a copy immediately.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @copyright 2003
! * @version $Id$
! *
! */
!
! /**
! * Service user object
*/
require_once 'Auth_Enterprise/Server/AEServiceUser.class.php';
!
! /**
! * Auth Enterprise's Group class
! */
! //require_once 'Auth_Enterprise/Common/AEGroup.class.php';
!
! /**
! * Bring in the base Auth_Enterprise provider
! */
require_once 'Auth_Enterprise/Server/providers/AEBaseProvider.class.php';
!
! /**
! * Bring in PEAR's database abstraction layer
! */
require_once 'DB.php';
!
! /**
! * Auth_Enteprise PEAR database provider
! *
! * This provider allows installations of Auth_Enteprise to use
! * any database supported by PEAR::DB as a backend for all
! * application authentication data
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @package net.geeklog.auth_enterprise.common
! * @todo For PHP5 this will become a real interface so do
! * not implement anything here.
! */
! class AEPearDB extends AEBaseProvider {
! /**
! * Instance of PEAR::DB Object
! * @access private
! * @var object
! */
! var $_db = null;
!
! var $_fetchMode = null;
!
! /**
! * Constructor
! *
! * Build PEAR DB database connection
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function AEPearDB()
! {
! AEUtility::logMessage("Got in AEPearDB constructor",__FILE__,__LINE__);
! global $gConf;
!
! $dsn = "{$gConf[AE_PROVIDER_PEAR_DB]['dbms']}://{$gConf[AE_PROVIDER_PEAR_DB]['dbuser']}:{$gConf[AE_PROVIDER_PEAR_DB]['dbpassword']}@{$gConf[AE_PROVIDER_PEAR_DB]['dbhost']}/{$gConf[AE_PROVIDER_PEAR_DB]['dbname']}";
! $this->_db = DB::connect($dsn, true);
!
! if (DB::isError($this->_db)) {
! trigger_error($this->_db->toString(), E_USER_ERROR);
! die ('Unable to connect to the database');
! }
}
!
! /**
! * Authenticates a user
! *
! * There is a long calling chain from the client end to this point but,
! * finally, this is where the real work gets done. This method will authenticate
! * a user against a DBMS that is supported by PEAR::DB
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @param string $appId App user is authenticating to
! * @param string $userId ID of user trying to log in
! * @param string $password Password to try logging in with
! * @return object AEServiceUser Object *referece*
! *
! */
! function &authenticate($appId, $userId, $password)
! {
! //$encryptedPass = MD5($password);
! $encryptedPass = $password;
! $prepStmt = $this->_db->prepare('SELECT user_id,username,password,account_locked,failed_attempts,pwd_last_set FROM user WHERE username = ? AND password = ?');
! AEUtility::logMessage($prepStmt,__FILE__,__LINE__);
! $result = $this->_db->execute($prepStmt, array($userId, $encryptedPass));
! if (DB::isError($result)) {
! trigger_error($result->toString(), E_USER_ERROR);
! trigger_error('Database error encountered in authenticate method of SQLProvider.class.php: ' . $result->getMessage());
! }
! if ($result->numRows() > 0) {
! $user = &$this->_mapResultToUserObject($result);
! $user->setAppId($appId);
!
! // Ensure the account hasn't been locked
! if ($user->getAccountLocked()) {
! // return an exception
! }
!
! // Check to see if password has expired.
! if ($user->isPasswordExpired()) {
! //return an exception
! }
!
! // We get the groups as those will be sent back in user object
! $user->setGroups($this->getGroups($appId, $user->getUserName()));
! //$user->setPrivileges($this->getPrivileges($appId, $user->getUserName(), $groupArray));
! print 'here2'; exit;
!
! $this->_isAuthenticated = true;
AEUtility::logObject($user,__FILE__,__LINE__);
!
! return $user;
! } else {
! AEUtility::logMessage('Authenticate failed',__FILE__,__LINE__);
! }
! }
!
! /**
! * Builds AAServiceUser object from SQL result from authenticate
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access private
! * @param object $sqlResult Valid database resource object
! * @return AAServiceUser User object
! *
! */
! function &_mapResultToUserObject($sqlResult)
! {
! // Pull data into array
! $user = new AEServiceUser();
! $row = $sqlResult->fetchRow($this->_fetchMode);
!
! // Set user attributes
! $user->setUserId($row[0]);
! $user->setUserName($row[1]);
! $user->setPassword($row[2]);
! if ($row[3] == 1) {
! $user->setAccountLocked(true);
! } else {
! $user->setAccountLocked(false);
! }
! $user->setFailedAttempts($row[4]);
! $user->setLastPWChange($row[5]);
!
! return $user;
! }
!
! function getGroups($appId, $userName, $userGroups = '', $currentGroupId = '')
! {
! AEUtility::logMessage('in getGroups', __FILE__, __LINE__);
!
! if (empty($userGroups)) {
! $userGroups = array();
! }
!
! if (empty($currentGroupId)) {
! $prepStmt = $this->_db->prepare('SELECT main_group_id,group_display_name,group_logical_name,group_descr
! FROM group_assignment,groups,user
! WHERE app_id = ?
! AND group_id = main_group_id
! AND user.user_id = assigned_user_id
! AND user.username = ?');
! $result = $this->_db->execute($prepStmt, array($appId, $userName));
! } else {
!
! $prepStmt = $this->_db->prepare('SELECT main_group_id,group_display_name,group_logical_name,group_descr
! FROM group_assignment,groups
! WHERE group_id = main_group_id
! AND assigned_group_id = ?');
! $result = $this->_db->execute($prepStmt, array($currentGroupId));
! }
!
! AEUtility::logMessage('Done with query', __FILE__, __LINE__);
! if (DB::isError($result)) {
! trigger_error($result->toString(), E_USER_ERROR);
}
!
! if ($result->numRows() == 0) {
! return $userGroups;
}
!
! $curGroup = new AEGroup();
! while ($row = $result->fetchRow($this->_fetchMode)) {
! AEUtility::logObject($row, __FILE__, __LINE__);
! $curGroup->setGroupId($row[0]);
! $curGroup->setGroupLogicalName($row[2]);
! $curGroup->setGroupDisplayName($row[1]);
! $curGroup->setGroupDesc($row[3]);
! $userGroups[] = $curGroup;
! $userGroups = $this->getGroups($appId,$userName,$userGroups,$row[0]);
! AEUtility::logObject($curGroup, __FILE__, __LINE__);
}
!
! if (is_array($userGroups)) {
! ksort($userGroups);
}
!
! return $userGroups;
! }
!
}
-
?>
--- 1,219 ----
<?php
! /**
! * Auth_Enterprise
! *
! * This source file is subject to version 2.02 of the PHP license,
! * that is bundled with this package in the file LICENSE, and is
! * available at through the world-wide-web at
! * http://www.php.net/license/2_02.txt.
! * If you did not receive a copy of the PHP license and are unable to
! * obtain it through the world-wide-web, please send a note to
! * license at php.net so we can mail you a copy immediately.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @copyright 2003
! * @version $Id$
! *
*/
+ /**
+ * Service user object
+ */
require_once 'Auth_Enterprise/Server/AEServiceUser.class.php';
! /**
! * Bring in the base Auth_Enterprise provider
! */
require_once 'Auth_Enterprise/Server/providers/AEBaseProvider.class.php';
! /**
! * Bring in PEAR's database abstraction layer
! */
require_once 'DB.php';
! /**
! * Auth_Enteprise PEAR database provider
! *
! * This provider allows installations of Auth_Enteprise to use
! * any database supported by PEAR::DB as a backend for all
! * application authentication data
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @package net.geeklog.auth_enterprise.common
! * @todo For PHP5 this will become a real interface so do
! * not implement anything here.
! */
! class AEPearDB extends AEBaseProvider {
! /**
! * Instance of PEAR::DB Object
! * @access private
! * @var object
! */
! var $_db = null;
!
! /**
! * Indicates the mode we fetch the data array in
! * @access private
! * @var int
! */
! var $_fetchMode = null;
!
! /**
! * Constructor
! *
! * Build PEAR DB database connection
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! function AEPearDB()
! {
! global $gConf;
!
! AEUtility::logMessage("Got in AEPearDB constructor",__FILE__,__LINE__);
! $dsn = "{$gConf[AE_PROVIDER_PEAR_DB]['dbms']}://{$gConf[AE_PROVIDER_PEAR_DB]['dbuser']}:{$gConf[AE_PROVIDER_PEAR_DB]['dbpassword']}@{$gConf[AE_PROVIDER_PEAR_DB]['dbhost']}/{$gConf[AE_PROVIDER_PEAR_DB]['dbname']}";
! $this->_db = DB::connect($dsn, true);
! if (DB::isError($this->_db)) {
! trigger_error($this->_db->toString(), E_USER_ERROR);
! }
}
! /**
! * Authenticates a user
! *
! * There is a long calling chain from the client end to this point but,
! * finally, this is where the real work gets done. This method will authenticate
! * a user against a DBMS that is supported by PEAR::DB
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @param string $appId App user is authenticating to
! * @param string $userId ID of user trying to log in
! * @param string $password Password to try logging in with
! * @return object AEServiceUser Object *reference* or PEAR::Error
! *
! */
! function &authenticate($appId, $userId, $password)
! {
! //$encryptedPass = MD5($password);
! $encryptedPass = $password;
! $prepStmt = $this->_db->prepare('SELECT user_id,username,password,account_locked,failed_attempts,pwd_last_set FROM user WHERE username = ? AND password = ?');
! AEUtility::logMessage($prepStmt,__FILE__,__LINE__);
! $result = $this->_db->execute($prepStmt, array($userId, $encryptedPass));
! if (DB::isError($result)) {
! trigger_error($result->toString(), E_USER_ERROR);
! return PEAR::raiseError('Database error while authenticating: ' . $result->toString, '100');
! }
! if ($result->numRows() > 0) {
! $user = &$this->_mapResultToUserObject($result);
!
! // Ensure the account hasn't been locked
! if ($user->getAccountLocked()) {
! return PEAR::raiseError('This account has been locked', '2');
! }
!
! // Check to see if password has expired.
! if ($user->isPasswordExpired()) {
! return PEAR::raiseError('This password has expired','5');
! }
! $user->setAppId($appId);
!
! // We get the groups as those will be sent back in user object
! $user->setGroups($this->getGroups($appId, $user->getUserName()));
! //$user->setPrivileges($this->getPrivileges($appId, $user->getUserName(), $groupArray));
!
! $this->_isAuthenticated = true;
AEUtility::logObject($user,__FILE__,__LINE__);
! return $user;
! } else {
! AEUtility::logMessage('Authenticate failed',__FILE__,__LINE__);
! return PEAR::raiseError('Invalid credentials. Please double check the username and password used.', '100');
! }
! }
!
! /**
! * Builds AAServiceUser object from SQL result from authenticate
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access private
! * @param object $sqlResult Valid database resource object
! * @return AAServiceUser User object
! *
! */
! function &_mapResultToUserObject($sqlResult)
! {
! // Pull data into array
! $user = new AEServiceUser();
! $row = $sqlResult->fetchRow($this->_fetchMode);
!
! // Set user attributes
! $user->setUserId($row[0]);
! $user->setUserName($row[1]);
! $user->setPassword($row[2]);
! if ($row[3] == 1) {
! $user->setAccountLocked(true);
! } else {
! $user->setAccountLocked(false);
! }
! $user->setFailedAttempts($row[4]);
! $user->setLastPWChange($row[5]);
!
! return $user;
! }
!
! /**
! * Gets the groups a user belongs to
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @param string $appId Application ID
! * @param string $userName Username
! * @param array $userGroups Groups collected for user
! * @param int $currentGroupId The group ID we are currently working on
! * @return array Array of groups user belongs to
! *
! */
! function getGroups($appId, $userName, $userGroups = '', $currentGroupId = '')
! {
! AEUtility::logMessage('in getGroups', __FILE__, __LINE__);
!
! if (empty($userGroups)) {
! $userGroups = array();
}
! if (empty($currentGroupId)) {
! $prepStmt = $this->_db->prepare('SELECT main_group_id,group_display_name,group_logical_name,group_descr
! FROM group_assignment,groups,user
! WHERE app_id = ?
! AND group_id = main_group_id
! AND user.user_id = assigned_user_id
! AND user.username = ?');
! $result = $this->_db->execute($prepStmt, array($appId, $userName));
! } else {
! $prepStmt = $this->_db->prepare('SELECT main_group_id,group_display_name,group_logical_name,group_descr
! FROM group_assignment,groups
! WHERE group_id = main_group_id
! AND assigned_group_id = ?');
! $result = $this->_db->execute($prepStmt, array($currentGroupId));
}
! AEUtility::logMessage('Done with query', __FILE__, __LINE__);
! if (DB::isError($result)) {
! trigger_error($result->toString(), E_USER_ERROR);
}
! if ($result->numRows() == 0) {
! return $userGroups;
! }
!
! $curGroup = new AEGroup();
! while ($row = $result->fetchRow($this->_fetchMode)) {
! AEUtility::logObject($row, __FILE__, __LINE__);
! $curGroup->setGroupId($row[0]);
! $curGroup->setGroupLogicalName($row[2]);
! $curGroup->setGroupDisplayName($row[1]);
! $curGroup->setGroupDesc($row[3]);
! $userGroups[] = $curGroup;
! $userGroups = $this->getGroups($appId,$userName,$userGroups,$row[0]);
! AEUtility::logObject($curGroup, __FILE__, __LINE__);
}
! if (is_array($userGroups)) {
! ksort($userGroups);
! }
! return $userGroups;
! }
}
?>
- Previous message (by thread): [geeklog-cvs] Auth_Enterprise/Client AEBaseClientProvider.class.php,1.1.1.1,1.2 AEClient.class.php,1.1.1.1,1.2 AEClientProviderFactory.class.php,1.1.1.1,1.2 AEUser.class.php,1.1.1.1,1.2 AEXMLRPC.class.php,1.1.1.1,1.2
- Next message (by thread): [geeklog-cvs] Auth_Enterprise/Common AEGroup.class.php,1.1.1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the geeklog-cvs
mailing list