[geeklog-cvs] geeklog-2/lib/A_and_A/client LocalhostInvoker.class.php,NONE,1.1

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Fri Jul 11 16:16:50 EDT 2003


Update of /usr/cvs/geeklog/geeklog-2/lib/A_and_A/client
In directory internal.geeklog.net:/tmp/cvs-serv28517

Added Files:
	LocalhostInvoker.class.php 
Log Message:
This localhost invoker assume the A&A client is on the same server as the A&A server.  It will call on the service via native method calls instead of through HTTP requests making it faster than the other invokers.  Obviously this invoker can't call on an A&A service on a remote host.

--- NEW FILE: LocalhostInvoker.class.php ---
<?php

/* Reminder: always indent with 4 spaces (no tabs). */
/**
* Enterprise Authentication & Authorization Service (A&A)
*
* The license for this software is yet to be determined.  In the meantime,
* all rights are reserved.  Use of this software is not permitted without
* the expressed written consent of Tony Bibbs
*
* @author Tony Bibbs <tony at geeklog.net>
* @copyright Tony Bibbs 2003
* @version $Id: LocalhostInvoker.class.php,v 1.1 2003/07/11 20:16:48 tony Exp $
*
*/

/**
* AAServiceUser class.  This is the main interface into A&A regardless of invokation.
* This localhost invoker simply calls methods directly
*/
require_once 'A_and_A/server/AAServiceUser.class.php';

/**
* LocalhostInvoker to the A&A service.
*
* This class it the strategy for interacting
* with the A&A service directly in the case the
* A&A service and client run on the same server.
*
* @author Tony Bibbs <tony at geeklog.net>
* @package net.geeklog.enterprise.aa.client
*
*/
class LocalhostInvoker extends Invoker {
    private $_serviceUser = null;
    
    /**
    * Constructor
    *
    * Sets up the A&A server properties
    *
    */
    function __construct()
    {
        $this->_serviceUser = new AAServiceUser();
    }
    
    /**
    * Authenticates a user to an application 
    * 
    * This method authenticates the userId and password for the specified
    * application. It returns an AAUser object which holds authorization 
    * privieges for that user and any exeptions that may have occured 
    * during authentication
    * 
    * @author Tony Bibbs <tony at geeklog.net>
    * @param string $appId Application to authenticate to
    * @param string $userName User to authenticate
    * @param string $userPass Password to authenticate with
    * @return AAUser Object containing a list of authorization levels
    * 
    */
    public function &authenticate($appId, $userName, $userPass) {
        return $this->_serviceUser->authenticate($appId, $userName, $userPass);
    }
    
    /**
    * Changes a password for a user
    *
    * This method changes the password for the given userId, password and 
    * application ID combination.
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @param string $appId Application to change password for 
    * @param string $userName User to change password for
    * @param string $userPass Current password 
    * @param string $newPass New password
    * @return boolean True if change worked, otherwise false
    *
    */
    public function changePassword($appId, $userName, $userPass, $newPass)
    {
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($userName);
        $this->_serviceUser->setPassword($password);
        return $this->_serviceUser->changePassword($newPassword);
    }
    
    /**
    * Allows admin to change a user's password
    *
    * This method allows an admin user ot change the password of a user to a 
    * particular value.
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $appId Application to change password for 
    * @param string $adminUserName User to change password for
    * @param string $adminPass Current password 
    * @param string $userName User to change password for
    * @param string $newPass New password
    *
    */
    public function changePasswordByAdmin($appId, $adminUserName, $adminPass, $userName, $newPass)
    {        
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($adminUserName);
        $this->_serviceUser->setPassword($adminPassword);
        return $this->_serviceUser->changePasswordByAdmin($userName, $newPassword);
    }
    
    /**
    * Allows admin to change a user's password
    *
    * This method allows an admin user ot change the password of a user to a 
    * particular value.
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $appId Application to change password for 
    * @param string $adminUserName User to  change password for
    * @param string $adminPass Current password 
    * @param string $userName User to  change password for
    *
    */
    public function resetPassword($appId, $adminUserName, $adminPass, $userName)
    {
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($adminUserName);
        $this->_serviceUser->setPassword($adminPass);
        return $this->_serviceUser->resetPassword($userName);
    }
    
    /**
    * Gets application priveliges for specified user
    *
    * This method retrieves the privilges of the specified user
    *
    * @param string $appId Application to get privilegs for 
    * @param string $adminUserName Admin making the request 
    * @param string $adminPass Admin's password 
    * @param string $userName User to get privileges for
    * @return AAPrivilegeInterface Object holding the user's privileges 
    *
    */
    public function getUserPrivileges($appId, $adminUserName, $adminPass, $userName)
    {
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($adminUserName);
        $this->_serviceUser->setPassword($adminPass);
        return $this->_serviceUser->getUserPrivileges($userName);
    }
    
    /**
    * Sets the privileges for a given user and application
    *
    * @param string $appId App to set privileges for 
    * @param string $adminUserName Admin making the request 
    * @param string $adminPass Admin's password 
    * @param string $userName User to set privileges for
    * @param AAPrivilege[] $privileges Privileges to give to the user
    * 
    */
    public function setUserPrivileges($appId, $adminUserName, $adminPass, $userName, $privArray)
    {
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($adminUserName);
        $this->_serviceUser->setPassword($adminPass);
        return $this->_serviceUser->setUserPrivileges($userName, $privArray);
    }
    
    /**
    * Lists all available privileges for a given application
    *
    * @param string $appId App to set privileges for 
    * @param string $adminUserName Admin making the request 
    * @param string $adminPass Admin's password 
    * @return AAPrivilegeInterface Complete list of privileges
    *
    */
    public function listAppPrivileges($appId, $adminUserName, $adminPass)
    {
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($adminUserName);
        $this->_serviceUser->setPassword($adminPass);
        return $this->_serviceUser->listAppPrivileges();
    }
    
    /**
    * Lists all available privileges for a given application
    *
    * @param string $appId Application to set privileges for 
    * @param string $adminUserName Admin making the request 
    * @param string $adminPass Admin's password 
    * @return AAPrivilegeInterface Complete list of privileges
    *
    */
    public function listAppGroups($appId, $adminUserName, $adminPass)
    {
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($adminUserName);
        $this->_serviceUser->setPassword($adminPass);
        return $this->_serviceUser->listAppGroups();
    }
    
    /**
    * Gets the privileges for a given user and application
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $appId ID to operate against
    * @param string $userName User to get privileges for
    *
    */
    public function getPrivileges($appId, $userName)
    {
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($adminUserName);
        return $this->_serviceUser->getPrivileges();
    }
    
    /**
    * Gets the security groups for a given user and application
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    * @param string $appId Application to operate against
    * @param string $userName User to get security groups for.
    *
    */
    public function getGroups($appId, $userName)
    {
        $this->_serviceUser->setAppId($appId);
        $this->_serviceUser->setUserName($adminUserName);
        return $this->_serviceUser->getGroups();
    }
}

?>




More information about the geeklog-cvs mailing list