• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • Examples
  • File List
  • File Members

docs/examples/example_file.php

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

Generated on Sat Mar 26 2011 12:11:03 for phpCAS by  doxygen 1.7.1