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

docs/examples/example_proxy.php

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

Generated on Mon Oct 4 2010 08:11:25 for phpCAS by  doxygen 1.7.1