ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules 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 
107  function Auth_Container_Multiple($options)
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 ?>
$result
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
$containers
The instanciated containers.
Definition: Multiple.php:96
Auth_Container_Multiple($options)
Constructor for Array Container.
Definition: Multiple.php:107
$options
The options for each container.
Definition: Multiple.php:89
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is a wrapper that returns an instance of the configured error class with this object&#39;s de...
Definition: PEAR.php:524
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
fetchData($user, $pass)
Get user information from array.
Definition: Multiple.php:138
$_auth_obj
The Auth object this container is attached to.
Definition: Container.php:56
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279