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

docs/examples/example_db.php

Go to the documentation of this file.
00001 <?php
00002 
00003 //
00004 // phpCAS proxy client with PGT storage to database
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 // set PGT storage to file in XML format in the same directory as session files
00020 phpCAS::setPGTStorageDB('user',
00021                         'password',
00022                         '',// database_type defaults to `mysql'
00023                         '',// hostname defaults to `localhost'
00024                         0,// use default port
00025                         '',// database defaults to phpCAS
00026                         '' // table defaults to `pgt'
00027                         );
00028 
00029 // force CAS authentication
00030 phpCAS::forceAuthentication();
00031 
00032 // at this step, the user has been authenticated by the CAS server
00033 // and the user's login name can be read with phpCAS::getUser().
00034 
00035 // moreover, a PGT was retrieved from the CAS server that will
00036 // permit to gain accesses to new services.
00037 
00038 $service = 'http://phpcas-test.univ-rennes1.fr/examples/example_service.php';
00039 
00040 ?>
00041 <html>
00042   <head>
00043     <title>phpCAS proxy example with PGT storage to database</title>
00044   </head>
00045   <body>
00046     <h1>phpCAS proxy example with PGT storage to database</h1>
00047     <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
00048     <h2>Response from service <?php echo $service; ?></h2><ul><hr>
00049 <?php
00050   flush();
00051   // call a service and change the color depending on the result
00052   if ( phpCAS::serviceWeb($service,$err_code,$output) ) {
00053     echo '<font color="#00FF00">';
00054   } else {
00055     echo '<font color="#FF0000">';
00056   }
00057   echo $output;
00058   echo '</font><hr></ul>';
00059 ?>
00060   </body>
00061 </html>

Generated on Tue Aug 3 2010 08:38:39 for phpCAS by  doxygen 1.7.1