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

Using the Zend_InfoCard component standalone

It is also possible to use the Zend_InfoCard component as a standalone component by interacting with the Zend_InfoCard class directly. Using the Zend_InfoCard class is very similar to its use with the Zend_Auth component. An example of its use is shown below:


<?php
if (isset($_POST['xmlToken'])) {
    
$infocard = new Zend_InfoCard();
    
$infocard->addCertificatePair('/usr/local/Zend/apache2/conf/server.key',
                                  
'/usr/local/Zend/apache2/conf/server.crt');

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

    if(
$claims->isValid()) {
        print 
"Given Name: {$claims->givenname}<br />";
        print 
"Surname: {$claims->surname}<br />";
        print 
"Email Address: {$claims->emailaddress}<br />";
        print 
"PPI: {$claims->getCardID()}<br />";
    } else {
        print 
"Error Validating identity: {$claims->getErrorMsg()}";
    }
}
?>
<hr />
<div id="login" style="font-family: arial; font-size: 2em;">
 <p>Simple Login Demo</p>
 <form method="post">
  <input type="submit" value="Login" />
   <object type="application/x-informationCard" name="xmlToken">
    <param name="tokenType"
          value="urn:oasis:names:tc:SAML:1.0:assertion" />
    <param name="requiredClaims"
          value="http://.../claims/givenname
                 http://.../claims/surname
                 http://.../claims/emailaddress
                 http://.../claims/privatepersonalidentifier" />
   </object>
 </form>
</div>

In the example above, we use the Zend_InfoCard component independently to validate the token provided by the user. As was the case with the Zend_Auth_Adapter_InfoCard, we create an instance of Zend_InfoCard and then set one or more SSL certificate public/private key pairs used by the web server. Once configured, we can use the process() method to process the information card and return the results.

Zend Framework