phpCAS version 1.3.6

ProxyChain.php
Go to the documentation of this file.
1 <?php
2
42 class CAS_ProxyChain
43 implements CAS_ProxyChain_Interface
44 {
45
46 protected $chain = array();
47
60 public function __construct(array $chain)
61 {
62 // Ensure that we have an indexed array
63 $this->chain = array_values($chain);
64 }
65
73 public function matches(array $list)
74 {
75 $list = array_values($list); // Ensure that we have an indexed array
76 if ($this->isSizeValid($list)) {
77 $mismatch = false;
78 foreach ($this->chain as $i => $search) {
79 $proxy_url = $list[$i];
80 if (preg_match('/^\/.*\/[ixASUXu]*$/s', $search)) {
81 if (preg_match($search, $proxy_url)) {
82 phpCAS::trace(
83 "Found regexp " . $search . " matching " . $proxy_url
84 );
85 } else {
86 phpCAS::trace(
87 "No regexp match " . $search . " != " . $proxy_url
88 );
89 $mismatch = true;
90 break;
91 }
92 } else {
93 if (strncasecmp($search, $proxy_url, strlen($search)) == 0) {
94 phpCAS::trace(
95 "Found string " . $search . " matching " . $proxy_url
96 );
97 } else {
98 phpCAS::trace(
99 "No match " . $search . " != " . $proxy_url
100 );
101 $mismatch = true;
102 break;
103 }
104 }
105 }
106 if (!$mismatch) {
107 phpCAS::trace("Proxy chain matches");
108 return true;
109 }
110 } else {
111 phpCAS::trace("Proxy chain skipped: size mismatch");
112 }
113 return false;
114 }
115
123 protected function isSizeValid (array $list)
124 {
125 return (sizeof($this->chain) == sizeof($list));
126 }
127 }
CAS_ProxyChain_Interface
Definition: Interface.php:41
phpCAS\trace
static trace($str)
Definition: CAS.php:579
CAS_ProxyChain\isSizeValid
isSizeValid(array $list)
Definition: ProxyChain.php:123
CAS_ProxyChain\$chain
$chain
Definition: ProxyChain.php:46
CAS_ProxyChain
Definition: ProxyChain.php:42
CAS_ProxyChain\__construct
__construct(array $chain)
Definition: ProxyChain.php:60
CAS_ProxyChain\matches
matches(array $list)
Definition: ProxyChain.php:73