View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Auth_Adapter_Chain
{zone-data}

{zone-data:proposer-list}
[Geoffrey Tran| http://geoffreytran.com]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 1 January 2008: Initial Draft.
{zone-data}

{zone-data:overview}
This adapter allows the chaining of other authentication adapters to authenticate from multiple sources.
{zone-data}

{zone-data:references}
* [Zym_Auth_Adapter_Chain|http://code.google.com/p/zym/source/browse/trunk/incubator/library/Zym/Auth/Adapter/Chain.php]
{zone-data}

{zone-data:requirements}
* This component *will* return the successful authenticated adapter
* This component *will* use no more memory than twice the size of all data it contains.
{zone-data}

{zone-data:dependencies}
* Zend_Auth_Result
* Zend_Auth_Adapter_Interface
{zone-data}

{zone-data:operation}
Authentication adapter used for chaining other auth adapters to authenticate from multiple sources
* Adapters are processed in FIFO order.
{zone-data}

{zone-data:milestones}
* Milestone 1: [DONE] Working prototype
* Milestone 2: Unit tests, Documentation
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.
{zone-data}

{zone-data:class-list}
* Zend_Auth_Adapter_Chain
{zone-data}

{zone-data:use-cases}
||UC-01||

{code}
$auth = Zend_Auth::getInstance();

$ldap = new Zend_Auth_Adapter_Ldap();
$db = new Zend_Auth_Adapter_DbTable();

$chain->setAdapters(array($ldap, $db));

$result = $auth->authenticate($chain);
if ($result->isValid()) {
$adapter = $chain->getLastSuccessfulAdapter();
// do something with it...
}
{code}
{zone-data}

{zone-data:skeletons}
{code}
<?php
/**
* Zym Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
*
* @category Zym
* @package Zym_Auth
* @subpackage Adapter
* @copyright Copyright (c) 2008 Zym. (http://www.zym-project.com/)
* @license http://www.zym-project.com/license New BSD License
*/

/**
* @see Zend_Auth_Adapter_Interface
*/
require_once 'Zend/Auth/Adapter/Interface.php';

/**
* @see Zend_Auth_Result
*/
require_once 'Zend/Auth/Result.php';

/**
* Authentication adapter used for chaining other auth adapters
* to authenticate from multiple sources
*
* Adapters are processed in FIFO order.
*
* @author Geoffrey Tran
* @license http://www.zym-project.com/license New BSD License
* @category Zym
* @package Zym_Auth
* @subpackage Adapter
* @copyright Copyright (c) 2008 Zym. (http://www.zym-project.com/)
*/
class Zym_Auth_Adapter_Chain implements Zend_Auth_Adapter_Interface
{
/**
* Authentication adapter instances
*
* @var array Array of Zend_Auth_Adapters
*/
private $_adapters = array();

/**
* Get the last successfully authenticated adapter
*
* @var Zend_Auth_Adapter_Interface
*/
private $_lastSuccessfulAdapter;

/**
* authenticate() - defined by Zend_Auth_Adapter_Interface. This method is called to
* attempt an authenication. Previous to this call, this adapter would have already
* been configured with all nessissary information to successfully connect to a database
* table and attempt to find a record matching the provided identity.
*
* @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible
* @return Zend_Auth_Result
*/
public function authenticate()
{
}

/**
* Get array of authentication adapters
*
* @return array
*/
public function getAdapters()
{
}

/**
* Add adapter to the stack in FIFO order
*
* @param Zend_Auth_Adapter_Interface $adapter
* @return Zym_Auth_Adapter_Chain
*/
public function addAdapter(Zend_Auth_Adapter_Interface $adapter)
{
}

/**
* Set array of authentication adapters
*
* @param array $adapters
* @return Zym_Auth_Adapter_Chain
*/
public function setAdapters(array $adapters)
{
}

/**
* Get last successfully authenticated adapter instance
*
* @return Zend_Auth_Adapter_Interface
*/
public function getLastSuccessfulAdapter()
{
}
}

{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>