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

tony at iowaoutdoors.org tony at iowaoutdoors.org
Sun Jul 4 11:12:14 EDT 2004


Update of /var/cvs/Auth_Enterprise/Common
In directory www:/tmp/cvs-serv24029

Added Files:
	Constants.php Exceptions.php Group.php Privilege.php 
	ServiceInterface.php 
Log Message:
Had to rename classes and files to adhere to PEAR standards


--- 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/04 15:12:12 tony Exp $
*
*/

/**
* Auth_Enteprise Service Interfaces
*
* @author Tony Bibbs <tony at geeklog.net>
* @package net.geeklog.auth_enterprise.common
*
*/
interface 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/04 15:12:12 tony 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/04 15:12:12 tony Exp $
*
*/

/**
* Indicates client should bypass all network traffic and talk to the Auth_Enterprise Service
* Directly
* @const AE_XMLRPC_CLIENT
*/
define('AE_LOCALHOST_CLIENT', 'AELocalhostClient');

/**
* Indicates client should use XMLRPC to talk to the service
* @const AE_XMLRPC_CLIENT
*/
define('AE_XMLRPC_CLIENT', 'AEXMLRPCClient');

/**
* Indicates client should use SOAP to talk to the service
* @const AE_XMLRPC_CLIENT
*/
define('AE_SOAP_CLIENT', 'AESOAPClient');

/**
* 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: Exceptions.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: Exceptions.php,v 1.1 2004/07/04 15:12:12 tony Exp $
*
*/

class AEBaseException extends 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 AEInsufficientClientOptions 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 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='');
    }
}

?>
--- 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/04 15:12:12 tony 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;
    }
}

?>



More information about the geeklog-cvs mailing list