Source for file papi1.5-customattr.php
Documentation is available at papi1.5-customattr.php
* This is a sample file to demonstrate the functionality of the phpPoA2 package.
* @author Jaime Perez <jaime.perez@rediris.es>
* @subpackage PAPIAuthenticationEngine
$poa = new PoA("samples");
$auth = $poa->authenticate();
echo "<h1>PAPI 1.5 Example #2</h1>";
echo "<h2>authenticate() + addHook() + getAttributes()</h2>";
function handler($assertion, &$attributes) {
$attributes = explode("@", $assertion);
public function handle($assertion, &$attributes) {
$attributes = explode(",", $assertion);
echo "<p><strong>authenticate()</strong>: <div style=\"background: #ccffcc; padding: 5px\"><tt>AUTHN_SUCCESS</tt></div></p>";
echo "<p><strong>addHook(\"PAPI_ATTRIBUTE_PARSER\", new Hook(\"handler\"))</strong>:<br/>";
echo "<div style=\"background: #cccccc; padding: 5px\"><pre>function handler(\$assertion, &\$attributes) {\n";
echo " \$attributes = explode(\"@\", \$assertion);\n";
echo "<p><strong>getAttributes()</strong>:</p>";
$fhook = new Hook("handler");
$poa->addHook("PAPI_ATTRIBUTE_PARSER", $fhook);
echo "<div style=\"background: #cccccc; padding: 5px\"><pre style=\"overflow: auto\">". print_r($poa->getAttributes(),true). "</pre></div>";
echo "<p><strong>addHook(\"PAPI_ATTRIBUTE_PARSER\", new Hook(array(\"AttributeHandler\",\"handler\")))</strong>:<br/>";
echo "<div style=\"background: #cccccc; padding: 5px\"><pre>class AttributeHandler {\n";
echo " public function handler(\$assertion, &\$attributes) {\n";
echo " \$attributes = explode(\",\", \$assertion);\n";
echo " }\n}</pre></div>";
$poa->removeHook("PAPI_ATTRIBUTE_PARSER", $fhook);
$ohook = new Hook(array($o, "handle"));
$poa->addHook("PAPI_ATTRIBUTE_PARSER", $ohook);
echo "<p><strong>getAttributes()</strong>:</p>";
echo "<div style=\"background: #cccccc; padding: 5px\"><pre style=\"overflow: auto\">". print_r($poa->getAttributes(),true). "</pre></div>";
echo "<p><strong>authenticate()</strong>: <div style=\"background: #ffcccc; padding: 5px\"><tt>AUTHN_FAILED</tt></div></p>";
|