example_file.php

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

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