PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Creating Zend_InfoCard Adapters

The Zend_InfoCard component was designed to allow for growth in the information card standard through the use of a modular architecture. At this time, many of these hooks are unused and can be ignored, but there is one class that should be written for any serious information card implementation: the Zend_InfoCard adapter.

The Zend_InfoCard adapter is used as a callback mechanism within the component to perform various tasks, such as storing and retrieving Assertion IDs for information cards when they are processed by the component. While storing the assertion IDs of submitted information cards is not necessary, failing to do so opens up the possibility of the authentication scheme being compromised through a replay attack.

To prevent this, one must implement the Zend_InfoCard_Adapter_Interface and set an instance of this interface prior to calling either the process() (standalone) or authenticate() method as a Zend_Auth adapter. To set this interface, the setAdapter() method should be used. In the example below, we set a Zend_InfoCard adapter and use it in our application:

<?php
class myAdapter implements Zend_InfoCard_Adapter_Interface
{
    public function 
storeAssertion($assertionURI,
                                   
$assertionID,
                                   
$conditions)
    {
        
/* Store the assertion and its conditions by ID and URI */
    
}

    public function 
retrieveAssertion($assertionURI$assertionID)
    {
        
/* Retrieve the assertion by URI and ID */
    
}

    public function 
removeAssertion($assertionURI$assertionID)
    {
        
/* Delete a given assertion by URI/ID */
    
}
}

$adapter  = new myAdapter();

$infoCard = new Zend_InfoCard();
$infoCard->addCertificatePair(SSL_PRIVATESSL_PUB);
$infoCard->setAdapter($adapter);

$claims $infoCard->process($_POST['xmlToken']);

Zend Framework