ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CAS_ProxyChain Class Reference

A normal proxy-chain definition that lists each level of the chain as either a string or regular expression. More...

+ Inheritance diagram for CAS_ProxyChain:
+ Collaboration diagram for CAS_ProxyChain:

Public Member Functions

 __construct (array $chain)
 A chain is an array of strings or regexp strings that will be matched against. More...
 
 matches (array $list)
 Match a list of proxies. More...
 
- Public Member Functions inherited from CAS_ProxyChain_Interface
 matches (array $list)
 Match a list of proxies. More...
 

Protected Member Functions

 isSizeValid (array $list)
 Validate the size of the the list as compared to our chain. More...
 

Protected Attributes

 $chain = array()
 

Detailed Description

A normal proxy-chain definition that lists each level of the chain as either a string or regular expression.

Definition at line 42 of file ProxyChain.php.

Constructor & Destructor Documentation

◆ __construct()

CAS_ProxyChain::__construct ( array  $chain)

A chain is an array of strings or regexp strings that will be matched against.

Regexp will be matched with preg_match and strings will be matched from the beginning. A string must fully match the beginning of an proxy url. So you can define a full domain as acceptable or go further down. Proxies have to be defined in reverse from the service to the user. If a user hits service A get proxied via B to service C the list of acceptable proxies on C would be array(B,A);

Parameters
array$chainA chain of proxies

Definition at line 58 of file ProxyChain.php.

59  {
60  // Ensure that we have an indexed array
61  $this->chain = array_values($chain);
62  }

Member Function Documentation

◆ isSizeValid()

CAS_ProxyChain::isSizeValid ( array  $list)
protected

Validate the size of the the list as compared to our chain.

Parameters
array$listList of proxies
Returns
bool

Definition at line 121 of file ProxyChain.php.

Referenced by matches().

122  {
123  return (sizeof($this->chain) == sizeof($list));
124  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
+ Here is the caller graph for this function:

◆ matches()

CAS_ProxyChain::matches ( array  $list)

Match a list of proxies.

Parameters
array$listThe list of proxies in front of this service.
Returns
bool

Definition at line 71 of file ProxyChain.php.

References $i, isSizeValid(), and phpCAS\trace().

72  {
73  $list = array_values($list); // Ensure that we have an indexed array
74  if ($this->isSizeValid($list)) {
75  $mismatch = false;
76  foreach ($this->chain as $i => $search) {
77  $proxy_url = $list[$i];
78  if (preg_match('/^\/.*\/[ixASUXu]*$/s', $search)) {
79  if (preg_match($search, $proxy_url)) {
81  "Found regexp " . $search . " matching " . $proxy_url
82  );
83  } else {
85  "No regexp match " . $search . " != " . $proxy_url
86  );
87  $mismatch = true;
88  break;
89  }
90  } else {
91  if (strncasecmp($search, $proxy_url, strlen($search)) == 0) {
93  "Found string " . $search . " matching " . $proxy_url
94  );
95  } else {
97  "No match " . $search . " != " . $proxy_url
98  );
99  $mismatch = true;
100  break;
101  }
102  }
103  }
104  if (!$mismatch) {
105  phpCAS::trace("Proxy chain matches");
106  return true;
107  }
108  } else {
109  phpCAS::trace("Proxy chain skipped: size mismatch");
110  }
111  return false;
112  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
static trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:599
isSizeValid(array $list)
Validate the size of the the list as compared to our chain.
Definition: ProxyChain.php:121
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

Field Documentation

◆ $chain

CAS_ProxyChain::$chain = array()
protected

Definition at line 44 of file ProxyChain.php.


The documentation for this class was generated from the following file: