ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
Multiple.php
Go to the documentation of this file.
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
3 
27 require_once "Auth/Container.php";
31 require_once "PEAR.php";
32 
81 
82  // {{{ properties
83 
89  var $options = array();
90 
96  var $containers = array();
97 
98  // }}}
99  // {{{ Auth_Container_Multiple()
100 
108  {
109  if (!is_array($options)) {
110  PEAR::raiseError('The options for Auth_Container_Multiple must be an array');
111  }
112  if (count($options) < 1) {
113  PEAR::raiseError('You must define at least one sub container to use in Auth_Container_Multiple');
114  }
115  foreach ($options as $option) {
116  if (!isset($option['type'])) {
117  PEAR::raiseError('No type defined for sub container');
118  }
119  }
120  $this->options = $options;
121  }
122 
123  // }}}
124  // {{{ fetchData()
125 
138  function fetchData($user, $pass)
139  {
140  $this->log('Auth_Container_Multiple::fetchData() called.', AUTH_LOG_DEBUG);
141 
142  foreach ($this->options as $key => $options) {
143 
144  $this->log('Using Container '.$key.' of type '.$options['type'].'.', AUTH_LOG_DEBUG);
145 
146  if (isset($this->containers[$key]) && is_a($this->containers[$key], 'Auth_Container')) {
147 
148  $container = &$this->containers[$key];
149 
150  } else {
151 
152  $this->containers[$key] = &$this->_auth_obj->_factory($options['type'], $options['options']);
153  $this->containers[$key]->_auth_obj = &$this->_auth_obj;
154  $container = &$this->containers[$key];
155 
156  }
157 
158  $result = $container->fetchData($user, $pass);
159 
160  if (PEAR::isError($result)) {
161 
162  $this->log('Container '.$key.': '.$result->getMessage(), AUTH_LOG_ERR);
163  return $result;
164 
165  } elseif ($result == true) {
166 
167  $this->log('Container '.$key.': Authentication successful.', AUTH_LOG_DEBUG);
168  return true;
169 
170  } else {
171 
172  $this->log('Container '.$key.': Authentication failed.', AUTH_LOG_DEBUG);
173 
174  }
175 
176  }
177 
178  $this->log('Auth_Container_Multiple: All containers rejected user credentials.', AUTH_LOG_DEBUG);
179 
180  return false;
181 
182  }
183 
184  // }}}
185 
186 }
187 
188 ?>