example_proxy.php

00001 <?php
00002 
00003 //
00004 // phpCAS proxy client
00005 //
00006 
00007 // import phpCAS lib
00008 include_once('CAS/CAS.php');
00009 
00010 // set debug mode
00011 phpCAS::setDebug();
00012 
00013 // initialize phpCAS
00014 phpCAS::proxy(CAS_VERSION_2_0,'sso-cas.univ-rennes1.fr',443,'');
00015 
00016 // force CAS authentication
00017 phpCAS::forceAuthentication();
00018 
00019 // at this step, the user has been authenticated by the CAS server
00020 // and the user's login name can be read with phpCAS::getUser().
00021 
00022 // moreover, a PGT was retrieved from the CAS server that will
00023 // permit to gain accesses to new services.
00024 
00025 ?>
00026 <html>
00027   <head>
00028     <title>phpCAS proxy example</title>
00029   </head>
00030   <body>
00031     <h1>phpCAS proxy example</h1>
00032     <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
00033 <?php
00034 // access to external services
00035 $services = array('http://phpcas-test.ifsic.univ-rennes1.fr/examples/example_service.php',
00036                   'http://phpcas-test.ifsic.univ-rennes1.fr/examples/example_proxy2.php',
00037                           'http://www.ifsic.univ-rennes1.fr/xxx');
00038 foreach ( $services as $service ) {
00039   echo '<h2>Response from service '.$service.'</h2><ul><hr>';
00040   flush();
00041   // call the service and change the color depending on the result
00042   if ( phpCAS::serviceWeb($service,$err_code,$output) ) {
00043     echo '<font color="#00FF00">';
00044   } else {
00045     echo '<font color="#FF0000">';
00046   }
00047   echo $output;
00048   echo '</font><hr></ul>';
00049 }
00050 ?>
00051   </body>
00052 </html>
00053 

Generated on Wed Mar 14 14:55:56 2007 for phpCAS by  doxygen 1.5.0