[geeklog-cvs] Auth_Enterprise/Enterprise Client.php,NONE,1.1 Constants.php,NONE,1.1 Exceptions.php,NONE,1.1 Group.php,NONE,1.1 Privilege.php,NONE,1.1 Server.php,NONE,1.1 ServiceInterface.php,NONE,1.1

jellybob at iowaoutdoors.org jellybob at iowaoutdoors.org
Thu Jul 8 10:36:18 EDT 2004


Update of /var/cvs/Auth_Enterprise/Enterprise
In directory www:/tmp/cvs-serv31121/Enterprise

Added Files:
	Client.php Constants.php Exceptions.php Group.php 
	Privilege.php Server.php ServiceInterface.php 
Log Message:
Major changes to the API everywhere.

The README is currently out of date, to find out how to use the new API
please check doc/examples/

Some features are currently untested, and may not work.


--- NEW FILE: Group.php ---
<?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 2004
* @version $Id: Group.php,v 1.1 2004/07/08 14:36:16 jellybob Exp $
*
*/

/**
* Generic group class used to pass group data between the A&A Server and A&A client(s)
*
* @author Tony Bibbs <tony at geeklog.net>
* @package net.geeklog.auth_enterprise.common
*
*/
class Enterprise_Group {
    /**
    * Group ID
    * @access private
    * @var int
    */
    private $groupId = null;
    
    /**
    * Name used to refer to group in code
    * @access private
    * @var string
    */
    private $groupLogicalName = null;
    
    /**
    * Name used in displaying the group to the user
    * @access private     * @var string
    */
    private $groupDisplayName = null;
    
    /**
    * Description for the group
    * @access private
    * @var string
    */
    private $groupDesc = null;
    
    /**
    * Array of privileges group has
    * @access private
    * @var array
    */
    private $privileges = null;
    
    /**
    * Converts an instance of this class into an array
    *
    * This class is needed because PEAR::XMLRPC is unable to encode PHP5 objects.  Until this is
    * addressed we will have to use this method before sending objects back to the calling
    * XMLRPC client application
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return array Array representing this object
    *
    */
    public function toArray()
    {
        $tmpArray = array();
        $tmpArray['groupId'] = $this->groupId;
        $tmpArray['groupLogicalName'] = $this->groupLogicalName;
        $tmpArray['groupDisplayName'] = $this->groupDisplayName;
        $tmpArray['groupDesc'] = $this->groupDesc;
        $privArray = array();
        if (is_array($this->privileges)) {
            foreach($this->privileges as $curPriv) {
                $privArray[] = $curPriv;
            }
        }
        $tmpArray['privileges'] = $privArray;
        
        return $tmpArray;
    }
    
    /**
    * Sets the group ID
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param integer $id ID for group
    *
    */
    public function setGroupId($id)
    {
        $this->groupId = $id;
    }
    
    /**
    * Retrieves the group ID
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return   integer  ID for group
    *
    */
    public function getGroupId()
    {
        return $this->groupId;
    }
    
    /**
    * Sets the group ID
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $name ID for group
    *
    */
    public function setGroupLogicalName($name)
    {
        $this->groupLogicalName = $name;
    }
    
    /**
    * Retrieves the group's logical name (used mainly in code)
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return   string  logical name for group
    *
    */
    public function getGroupLogicalName()
    {
        return $this->groupLogicalName;
    }
    
    /**
    * Sets the group ID
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $name ID for group
    *
    */
    public function setGroupDisplayName($name)
    {
        $this->groupDisplayName = $name;
    }
    
    /**
    * Retrieves the group's Display name (used mainly in code)
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return   string  Display name for group
    *
    */
    public function getGroupDisplayName()
    {
        return $this->groupDisplayName;
    }
    
    /**
    * Sets the group description
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param    string  $desc   Description for group
    *
    */
    public function setGroupDesc($desc)
    {
        $this->groupDesc = $desc;
    }
    
    /**
    * Retrieves the group code
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return   string  Description for group
    *
    */
    public function getGroupDesc()
    {
        return $this->groupDesc;
    }
    
    /**
    * Sets the privileges for the group
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param array $privArray Array of group privileges
    *
    */
    public function setGroupPrivileges($privArray)
    {
        $this->privileges = $privArray;
    }
    
    /**
    * Gets the group privileges
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return array Array of privileges
    *
    */
    public function getGroupPrivileges()
    {
        return $this->privileges;
    }
}

?>
--- NEW FILE: ServiceInterface.php ---
<?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 2004
* @version $Id: ServiceInterface.php,v 1.1 2004/07/08 14:36:16 jellybob Exp $
*
*/

/**
* Auth_Enteprise Service Interfaces
*
* @author Tony Bibbs <tony at geeklog.net>
* @package net.geeklog.auth_enterprise.common
*
*/
interface Auth_Enterprise_ServiceInterface {
    /**
    * Authenticates a user to an application
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function authenticate($userName, $password);
    
    /**
    * Registers a new account with the service
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function createAccountByAdmin($adminUserName, $adminPassword, $userName, $userPassword);
    
    /**
    * Changes a user's password
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function changePassword($userName, $newPassword);
    
    /**
    * Allows an application level admin to change a
    * user's password
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function changePasswordByAdmin($adminUserName, $adminPassword, $userName, $newPassword);
    
    /**
    * Resets a user's password to a randomly generated one
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $userName User to reset password for
    * @return string New randomly generated password
    *
    */
    public function resetPassword($userName);
    
    /**
    * Gets the application privileges for a given user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function getUserPrivilegesByAdmin($adminUserName, $adminPassword, $userName);
    
    /**
    * Sets the application privileges for a given user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function setUserPrivilegesByAdmin($adminUserName, $adminPassword, $userName, $privArray);
    
    /**
    * Lists all available privileges for a given application
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function listAppPrivilegesByAdmin($adminUserName, $adminPassword);
    
    /**
    * Gets the application privileges for a given user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function getUserGroupsByAdmin($adminUserName, $adminPassword, $userName);
    
    /**
    * Sets the application privileges for a given user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function setUserGroupsByAdmin($adminUserName, $adminPassword, $userName, $groupArray);
}

?>

--- NEW FILE: Privilege.php ---
<?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 2004
* @version $Id: Privilege.php,v 1.1 2004/07/08 14:36:16 jellybob Exp $
*
*/

/**
* Auth_Enteprise privilege domain object
*
* This is a simple, lightweight class used to represent application privileges
*
* @author Tony Bibbs <tony at geeklog.net>
* @package net.geeklog.auth_enterprise.common
*
*/
class Enterprise_Privilege {
    /**
    * This is a short code given to a privilege.  This is what programmers will check against
    * when they are verifying authorization levels
    * @access private
    * @var string
    */
    private $privilegeCode = null;
    
    /**
    * This is a text description as to what the privilege is used for
    * @access private
    * @var string
    */
    private $privilegeDesc = null;
    
    public function toArray()
    {
        $tmpArray = array();
        $tmpArray['privilegeCode'] = $this->privilegeCode;
        $tmpArray['privilegeDesc'] = $this->privilegeDesc;
        
        return $tmpArray;
    }
    
    public function __construct($code = '', $desc = '')
    {
        $this->privilegeCode = $code;
        $this->privilegeDesc = $desc;
    }
    
    /**
    * Setter for the privilege code
    *
    * @author Tony Bibbs <tony at geeklog.net
    * @access public
    * @param string $code Privilege code
    *
    */
    public function setPrivilegeCode($code)
    {
        $this->privilegeCode = $code;
    }
    
    /**
    * Getter for privilege code
    *
    * The privilege code is what is use inside your code for checking
    * authorization to that privilege for a user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return string The privilege code
    *
    */
    public function getPrivilegeCode()
    {
        return $this->privilegeCode;
    }
    
    /**
    * Setter for privilege description
    *
    * @author Tony Bibbs <tony at geeklog.net
    * @access public
    * @param string $desc Privilege description
    *
    */
    public function setPrivilegeDesc($desc)
    {
        $this->privilegeDesc = $desc;
    }
    
    /**
    * Getter for the privilege description
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return string Privilege description
    *
    */
    public function getPrivilegeDesc()
    {
        return $this->privilegeDesc;
    }
}

?>
--- NEW FILE: Constants.php ---
<?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 2004
* @version $Id: Constants.php,v 1.1 2004/07/08 14:36:16 jellybob Exp $
*
*/

/**
* This is a privilige that gives a user full (root) access to the Auth_Enterprise Service
* @const AE_ADMIN_PRIV
*/
define('AE_ADMIN_PRIV', 'AE_ADMIN_PRIV');

/**
* This privilege gives a user in Auth_Enterprise the ability to manage accounts for
* a specific provider
* @const AE_ACCOUNT_MGR
*/
define('AE_ACCOUNT_MGR', 'AE_ACCOUNT_MGR');

/**
* Used during XMLRPC communication to indicate an exception has been throw or caught
* @const AE_XMLRPC_EXCEPTION
*/
define('AE_XMLRPC_EXCEPTION', 'AE_XMLRPC_EXCEPTION');

define('AESQLExceptionResp', 3);
define('AEInvalidUserCredentialsResp', 4);
define('AEAccountLockedResp', 5);
define('AEPasswordExpiredResp', 6);
define('AEPasswordInHistoryResp', 7);
define('AEPasswordInvalidResp', 8);
define('AEUnableToConnectResp', 9);
define('AEUserNotAuthorizedResp', 10);
define('AEInvalidPrivilegeResp', 11);
define('AEInsufficientClientOptionsResp', 12);
define('AELDAPBindErrorResp', 13);
define('AENoProviderResp', 14);
define('AENoAppIdResp', 15);

?>
--- NEW FILE: Server.php ---
<?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 2004
* @version $Id: Server.php,v 1.1 2004/07/08 14:36:16 jellybob Exp $
*
*/

/**
* The Auth_Enterprise service inteface
*/
require_once 'Auth/Enterprise/ServiceInterface.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
*
*/
abstract class Auth_Enterprise_Server implements Auth_Enterprise_ServiceInterface {
    /**
    * An array of options
    * @access protected
    * @var array
    */
    protected $options = array();
    
    /**
    * User authentication can be fired multiple times for the same user which would be inefficient.
    * This attribute indicates if the user has been authenticated to save on these extra calls
    * @access protected
    * @var boolean
    */
    protected $isAuthenticated = false;
    
    /**
    * Constructor
    *
    * Sets the Application ID for the provider
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $appId Application ID assigned by Auth_Enterprise server.
    *
    */
    public function __construct($options)
    {
        $this->options = $options;
    }
    
    /**
    * Authenticates a user to an application
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function authenticate($userName, $password)
    {
    }
    
    /**
    * Registers a new account with the service
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function createAccountByAdmin($adminUserName, $adminPassword, $userName, $userPassword)
    {
    }
    
    /**
    * Changes a user's password
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function changePassword($userName, $newPassword)
    {
    }
    
    /**
    * Allows an application level admin to change a
    * user's password
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function changePasswordByAdmin($adminUserName, $adminPassword, $userName, $newPassword)
    {
    }
    
    /**
    * Resets a user's password
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $userName User to reset password for
    * @return string New password
    * 
    */
    public function resetPassword($userName)
    {
    }
    
    /**
    * Gets the application privileges for a given user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function getUserPrivileges($adminUserName, $adminPassword, $userName)
    {
    }
    
    /**
    * Sets the application privileges for a given user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function setUserPrivilegesByAdmin($adminUserName, $adminPassword, $userName, $privArray)
    {
    }
    
    /**
    * Lists all available privileges for a given application
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    public function listAppPrivilegesByAdmin($adminUserName, $adminPassword)
    {
    }
    
    public function getUserGroupsByAdmin($adminUserName, $adminPassword, $userName)
    {
    }
    
    public function setUsterGroupsByAdmin($adminUserName, $adminPassword, $userName, $groupArray)
    {
    }
    
}

?>

--- NEW FILE: Client.php ---
<?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 2004
* @version $Id: Client.php,v 1.1 2004/07/08 14:36:16 jellybob Exp $
*
*/

/**
* Constants used through out the Auth_Enterprise client
*/
require_once 'Auth/Enterprise/Client/Constants.php';

/**
* The Auth_Enterprise Service Interface
*/
require_once 'Auth/Enterprise/ServiceInterface.php';

/**
* Auth_Enterprise Client User Class
*/
require_once 'Auth/Enterprise/Client/User.php';

/**
* Auth_Enterprise Privilege Class
*/
require_once 'Auth/Enterprise/Privilege.php';

/**
* Set of Auth_Enterprise exceptions
*/
require_once 'Auth/Enterprise/Exceptions.php';

/**
* Auth_Enteprise Client
*
* @author Tony Bibbs <tony at geeklog.net>
* @package net.geeklog.auth_enterprise.client
*
*/
class Auth_Enterprise_Client implements Auth_Enterprise_ServiceInterface {
    /**
    * Application ID
    * @access private
    * @var string
    */
    protected $appId = null;
    
    /**
     * The options array passed to the constructor.
     * @access protected
     * @var array
     */
    protected $options = array();
    
    /**
    * Constructor
    *
    * Creates an instance of the client provider
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param int $provider Indicates which client implementation to use
    * @param array $providerOptions Options the client provider uses to talk to the service
    *
    */
    public function __construct($options)
    {
        $this->parseOptions($options);
    }
        
    /**
    * Returns the application ID
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return string Application ID
    *
    */
    protected function getAppId()
    {
        return $this->appId;
    }
    
    /**
    * Authenticates a user with the Auth_Enterprise service
    *
    * Uses the instance to the client provider to authenticate a user.  Typically this is the only
    * method in this class you should have to call directly.  After you successfully authentciate
    * you should have a valid AEUser instance and you can call the methods you need from there.
    *
    * NOTE: This method returns a user object that has the same clientProvider handle as this class.
    * Because of this, you should be able to free up an instance of this class after you call this
    * Method.  Obviously this is optional but strongly recommend.
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $userName Username to authenticate to the service with
    * @param string $password Password to authenticate with
    * @return object AEUser Object
    *
    */
    public function authenticate($userName, $password)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Registers a new account with the service
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $adminUserName Administrator's username
    * @param string $adminPassword Administrator's password
    * @param string $userName User name for new account
    * @param string $userPassowrd Password for new account
    * 
    */
    public function createAccountByAdmin($adminUserName, $adminPassword, $userName, $userPassword)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Changes a user's password
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $userName Username for user to change password for
    * @param string $newPassword User's new password
    *
    */
    public function changePassword($userName, $newPassword)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Allows an application level admin to change a
    * user's password
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $adminUserName Username of admin user making the request
    * @param string $adminPassword Password of admin user making the request
    * @param string $userName Username of user to change password for
    * @param string $newPassword New password for the given user
    *
    */
    public function changePasswordByAdmin($adminUserName, $adminPassword, $userName, $newPassword)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Resets a user's password to a randomly generated one
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @return string New randomly generated password
    *
    */
    public function resetPassword($userName)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Gets the application privileges for a given user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $adminUserName Admin user making the request
    * @param string $adminPassword Password for admin making the request
    * @param string $userName Username of user to get privileges for
    * @return Array
    *
    */
    public function getUserPrivilegesByAdmin($adminUserName, $adminPassword, $userName)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Sets the application privileges for a given user
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $adminUserName Admin user making the request
    * @param string $adminPassword Password for admin making the request
    * @param string $userName Username of user to set privileges for
    * @param array $privArray Array of privileges to give the user
    * @return null
    * 
    */
    public function setUserPrivilegesByAdmin($adminUserName, $adminPassword, $userName, $privArray)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Lists all available privileges for a given application
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $adminUserName Admin user making the request
    * @param string $adminPassword Password for admin making the request
    * @return Array An array of privileges
    *
    */
    public function listAppPrivilegesByAdmin($adminUserName, $adminPassword)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Allows an admin to get the groups a user belongs to
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $adminUserName The administrator's username
    * @param string $adminPassword The administrator's password
    * @param string $userName User to get groups for
    * @return array Array of group objects
    *
    */
    public function getUserGroupsByAdmin($adminUserName, $adminPassword, $userName)
    {
        throw new AENotImplemented();
    }
    
    /**
    * Allows an admin to set the groups a user belongs to
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $adminUserName The administrator's username
    * @param string $adminPassword The administrator's password
    * @param string $userName User to set groups for
    *
    */
    public function setUserGroupsByAdmin($adminUserName, $adminPassword, $userName, $groupArray)
    {
        throw new AENotImplemented();
    }
    
    /**
     * Handles any options passed to the constructor.
     *
     * Child classes should pass their options array onto here once they're done.
     *
     * @author Jon Wood <jon at jellybob.co.uk>
     * @access protected
     * @param array $options An array of options.
     * @return void
     */
    protected function parseOptions($options = array())
    {
        if (isset($options['appId'])) {
            $this->appId = $options['appId'];
        }
        
        $this->options = $options;
    }
}

?>

--- NEW FILE: Exceptions.php ---
<?php

/**
* Temporary Hack to bring in PEAR Exception.  I put it in the base PEAR directory
* for now.  Until the exception handling is figured out in PHP5, you may have to
* change the include path here.  In the end I'm guessing the PHP5 PEAR.php will
* include this class but until that happens I'm including it explicitly.  You can
* get the class from http://cvs.php.net/co.php/pear-core/PEAR/Exception.php
*
*/
require_once 'PEAR/Exception.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 2004
* @version $Id: Exceptions.php,v 1.1 2004/07/08 14:36:16 jellybob Exp $
* @todo Need to rename these from AE<exceptionname> to Enteprise_<exceptionname>.  This will take
* some work because they are used all over the place (sigh)
* 
*/

class AEBaseException extends PEAR_Exception {
    public $xmlRPCErrorOffset;
    public function getXMLErrorOffset()
    {
        return $this->xmlRPCErrorOffset;
    }
}

class AEUnknownException extends AEBaseException {
    public $xmlRPCErrorOffset = 2;
    
    public function __construct($message = '')
    {
        if (empty($message)) {
            $message = 'Auth_Enterprise encountered an unknown error';
        }
        
        parent::__construct($message);
    }
}

class AESQLException extends AEBaseException {
    public $xmlRPCErrorOffset = 3;
    public function __construct($message = '')
    {
        if (empty($message)) {
            $message = 'Auth_Enterprise generated a SQL Error';
        }
        
        parent::__construct($message);
    }
}

/**
* Generic group class used to pass group data between the A&A Server and A&A client(s)
*
* @author Tony Bibbs <tony at geeklog.net>
* @package net.geeklog.auth_enterprise.common.exceptions
*
*/
class AEInvalidUserCredentials extends AEBaseException {
    public $xmlRPCErrorOffset = 4;
    public function __construct($message = '')
    {
        if (empty($message)) {
            $message = 'Invalid username or password';
        }
        
        parent::__construct($message);
    }
}

class AEAccountLocked extends AEBaseException {
    public $xmlRPCErrorOffset = 5;
    public function __construct($message = '')
    {
        if (empty($message)) {
            $message = 'This Auth_Enterpirse account has been locked';
        }
        
        parent::__construct($message);
    }
}

class AEPasswordExpired extends AEBaseException {
    public $xmlRPCErrorOffset = 6;
    public function __construct($message = '')
    {
        if (empty($message)) {
            $message = 'The password supplied to Auth_Enterprise has expired';
        }
        
        parent::__construct($message);
    }
}

class AEPasswordInHistory extends AEBaseException {
    public $xmlRPCErrorOffset = 7;
    public function __construct($message = '')
    {
        if (empty($message)) {
            $message = 'The password supplied is still in the Auth_Enterprise history for the user';
        }
        
        parent::__construct($message);
    }
}

class AEPasswordInvalid extends AEBaseException {
    public $xmlRPCErrorOffset = 8;
    public function __construct($message = '')
    {
        if (empty($message)) {
            $message = 'The password supplied does not meet the Auth_Enterprise password rules';
        }
        
        parent::__construct($message);
    }
}

class AEUnableToConnect extends AEBaseException {
    public $xmlRPCErrorOffset = 9;
    public function __construct($message='')
    {
        if (empty($message)) {
            $message = 'Auth_Enterprise provider was unable to connect to datasource';
        }
        
        parent::__construct($message);
    }
}

class AEUserNotAuthorized extends AEBaseException {
    public $xmlRPCErrorOffset = 10;
    public function __construct($message='')
    {
        if (empty($message)) {
            $message = 'User is not permitted to perform the requested action';
        }
        
        parent::__construct($message);
    }
}

class AEInvalidPrivilege extends AEBaseException {
    public $xmlRPCErrorOffset = 11;
    public function __construct($message='')
    {
        if (empty($message)) {
            $message = 'The privilege given does not exist or is invalid';
        }
        
        parent::__construct($message);
    }
}

class AEInsufficientOptions extends AEBaseException {
    public $xmlRPCErrorOffset = 12;
    public function __construct($message='')
    {
        if (empty($message)) {
            $message = 'The options given to the client are not sufficient';
        }
        
        parent::__construct($message);
    }
}

class AEClientFactoryFailed extends AEBaseException {
    public $provider;
    public $options = array();
    
    public function __construct($provider = '', $options = array())
    {
        if (empty($message)) {
            $message = 'The client factory failed.';
        }
        
        $this->provider = $provider;
        $this->options = $options;
        
        parent::__construct($message);    
    }
}

class AELDAPBindError extends AEBaseException {
    public $xmlRPCErrorOffset = 13;
    public function __construct($message='')
    {
        if (empty($message)) {
            $message = 'Unable to bind to LDAP server';
        }
        
        parent::__construct($message);
    }
}

class AENoProvider extends AEBaseException {
    public $xmlRPCErrorOffset = 14;
    public function __construct($message='')
    {
        if (empty($message)) {
            $message = 'Unable to find a provider for the given application';
        }
        
        parent::__construct($message);
    }
}

class AENoAppId extends AEBaseException {
    public $xmlRPCErrorOffset = 15;
    public function __construct($message='')
    {
        if (empty($message)) {
            $message = 'No application ID was given in the request to the Auth_Enterprise service';
        }
        
        parent::__construct($message);
    }
}

class AENotImplemented extends AEBaseException {
    public function __construct($message='')
    {
        if (empty($message)) {
            $message = 'This method has not been implemented by this provider.';
        }
        
        parent::__construct($message);   
    }
}
?>




More information about the geeklog-cvs mailing list