Go to the documentation of this file.00001 <?php
00002
00003
00004
00005 include_once('config.php');
00006
00007 include_once($phpcas_path.'/CAS.php');
00008
00009
00010 phpCAS::setDebug();
00011
00012
00013 phpCAS::proxy(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
00014
00015
00016
00017
00018
00019
00020
00021
00022 phpCAS::setNoCasServerValidation();
00023
00024
00025 phpCAS::forceAuthentication();
00026
00027
00028
00029
00030
00031
00032
00033 ?>
00034 <html>
00035 <head>
00036 <title>phpCAS proxy example #2</title>
00037 <link rel="stylesheet" type='text/css' href='example.css'/>
00038 </head>
00039 <body>
00040 <h1>phpCAS proxied proxy example</h1>
00041 <?php include 'script_info.php' ?>
00042 <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
00043 <h2>Response from service <?php echo $serviceUrl; ?></h2>
00044 <?php
00045 flush();
00046
00047 // call a service and change the color depending on the result
00048 try {
00049 $service = phpCAS::getProxiedService(PHPCAS_PROXIED_SERVICE_HTTP_GET);
00050 $service->setUrl($serviceUrl);
00051 $service->send();
00052 if ($service->getResponseStatusCode() == 200) {
00053 echo '<div class="success">';
00054 echo $service->getResponseBody();
00055 echo '</div>';
00056 } else {
00057 // The service responded with an error code 404, 500, etc.
00058 echo '<div class="error">';
00059 echo 'The service responded with a '.$service->getResponseStatusCode().' error.';
00060 echo '</div>';
00061 }
00062 } catch (CAS_ProxyTicketException $e) {
00063 if ($e->getCode() == PHPCAS_SERVICE_PT_FAILURE) {
00064 echo '<div class="error">';
00065 echo "Your login has timed out. You need to log in again.";
00066 echo '</div>';
00067 } else
00068 // Other proxy ticket errors are from bad request format (shouldn't happen)
00069
00070 throw $e;
00071 } catch (CAS_ProxiedService_Exception $e) {
00072
00073
00074
00075
00076 throw $e;
00077 }
00078
00079
00080 ?>
00081 </body>
00082 </html>
00083