~wenbo/kylin-software-center/ukdlp

« back to all changes in this revision

Viewing changes to CAS-1.1.2RC2/docs/examples/example_proxy.php

  • Committer: wenbo
  • Date: 2018-05-29 07:53:32 UTC
  • Revision ID: wenbo@kylinos.cn-20180529075332-4omip2b16o9rgxuz
ukdlp init 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
//
 
4
// phpCAS proxy client
 
5
//
 
6
 
 
7
// import phpCAS lib
 
8
include_once('CAS.php');
 
9
 
 
10
// set debug mode
 
11
phpCAS::setDebug();
 
12
 
 
13
// initialize phpCAS
 
14
phpCAS::proxy(CAS_VERSION_2_0,'sso-cas.univ-rennes1.fr',443,'');
 
15
 
 
16
// no SSL validation for the CAS server
 
17
phpCAS::setNoCasServerValidation();
 
18
 
 
19
// force CAS authentication
 
20
phpCAS::forceAuthentication();
 
21
 
 
22
// at this step, the user has been authenticated by the CAS server
 
23
// and the user's login name can be read with phpCAS::getUser().
 
24
 
 
25
// moreover, a PGT was retrieved from the CAS server that will
 
26
// permit to gain accesses to new services.
 
27
 
 
28
?>
 
29
<html>
 
30
  <head>
 
31
    <title>phpCAS proxy example</title>
 
32
  </head>
 
33
  <body>
 
34
    <h1>phpCAS proxy example</h1>
 
35
    <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
 
36
<?php
 
37
// access to external services
 
38
$services = array('http://phpcas-test.ifsic.univ-rennes1.fr/examples/example_service.php',
 
39
                  'http://phpcas-test.ifsic.univ-rennes1.fr/examples/example_proxy2.php',
 
40
                          'http://www.ifsic.univ-rennes1.fr/xxx');
 
41
foreach ( $services as $service ) {
 
42
  echo '<h2>Response from service '.$service.'</h2><ul><hr>';
 
43
  flush();
 
44
  // call the service and change the color depending on the result
 
45
  if ( phpCAS::serviceWeb($service,$err_code,$output) ) {
 
46
    echo '<font color="#00FF00">';
 
47
  } else {
 
48
    echo '<font color="#FF0000">';
 
49
  }
 
50
  echo $output;
 
51
  echo '</font><hr></ul>';
 
52
}
 
53
?>
 
54
  </body>
 
55
</html>
 
56