ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
Auth_Container_File Class Reference
+ Inheritance diagram for Auth_Container_File:
+ Collaboration diagram for Auth_Container_File:

Public Member Functions

 Auth_Container_File ($filename)
 Constructor of the container class. More...
 
 fetchData ($user, $pass)
 Authenticate an user. More...
 
 listUsers ()
 List all available users. More...
 
 addUser ($user, $pass, $additional='')
 Add a new user to the storage container. More...
 
 removeUser ($user)
 Remove user from the storage container. More...
 
 changePassword ($username, $password)
 Change password for user in the storage container. More...
 
_load ()
 Load and initialize the File_Passwd object. More...
 
 _setDefaults ()
 Set some default options. More...
 
 _parseOptions ($array)
 Parse options passed to the container class. More...
 
- Public Member Functions inherited from Auth_Container
 Auth_Container ()
 Constructor. More...
 
 fetchData ($username, $password, $isChallengeResponse=false)
 Fetch data from storage container. More...
 
 verifyPassword ($password1, $password2, $cryptType="md5")
 Crypt and verfiy the entered password. More...
 
 supportsChallengeResponse ()
 Returns true if the container supports Challenge Response password authentication. More...
 
 getCryptType ()
 Returns the crypt current crypt type of the container. More...
 
 listUsers ()
 List all users that are available from the storage container. More...
 
 getUser ($username)
 Returns a user assoc array. More...
 
 addUser ($username, $password, $additional=null)
 Add a new user to the storage container. More...
 
 removeUser ($username)
 Remove user from the storage container. More...
 
 changePassword ($username, $password)
 Change password for user in the storage container. More...
 
 log ($message, $level=AUTH_LOG_DEBUG)
 Log a message to the Auth log. More...
 
- Public Member Functions inherited from ilAuthContainerBase
 loginObserver ($a_username, $a_auth)
 Called after successful login. More...
 
 failedLoginObserver ($a_username, $a_auth)
 Called after failed login. More...
 
 checkAuthObserver ($a_username, $a_auth)
 Called after check auth requests. More...
 
 logoutObserver ($a_username, $a_auth)
 Called after logout. More...
 
 supportsCaptchaVerification ()
 Returns whether or not the auth container supports the verification of captchas This should be true for those auth methods, which are available in the default login form. More...
 

Data Fields

 $pwfile = ''
 
 $options = array()
 
- Data Fields inherited from Auth_Container
 $activeUser = ""
 User that is currently selected from the storage container. More...
 
 $_auth_obj = null
 The Auth object this container is attached to. More...
 

Detailed Description

Definition at line 58 of file File.php.

Member Function Documentation

◆ _load()

& Auth_Container_File::_load ( )

Load and initialize the File_Passwd object.

Returns
object File_Passwd_Cvs|PEAR_Error

Definition at line 257 of file File.php.

References $res, AUTH_LOG_DEBUG, PEAR\isError(), and Auth_Container\log().

Referenced by addUser(), changePassword(), listUsers(), and removeUser().

258  {
259  static $pw_obj;
260 
261  if (!isset($pw_obj)) {
262  $this->log('Instanciating File_Password object of type '.$this->options['type'], AUTH_LOG_DEBUG);
263  $pw_obj = File_Passwd::factory($this->options['type']);
264  if (PEAR::isError($pw_obj)) {
265  return $pw_obj;
266  }
267 
268  $pw_obj->setFile($this->pwfile);
269 
270  $res = $pw_obj->load();
271  if (PEAR::isError($res)) {
272  return $res;
273  }
274  }
275 
276  return $pw_obj;
277  }
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _parseOptions()

Auth_Container_File::_parseOptions (   $array)

Parse options passed to the container class.

private

Parameters
array

Definition at line 302 of file File.php.

Referenced by Auth_Container_File().

303  {
304  foreach ($array as $key => $value) {
305  if (isset($this->options[$key])) {
306  $this->options[$key] = $value;
307  }
308  }
309  }
+ Here is the caller graph for this function:

◆ _setDefaults()

Auth_Container_File::_setDefaults ( )

Set some default options.

private

Returns
void

Definition at line 288 of file File.php.

Referenced by Auth_Container_File().

289  {
290  $this->options['type'] = 'Cvs';
291  }
+ Here is the caller graph for this function:

◆ addUser()

Auth_Container_File::addUser (   $user,
  $pass,
  $additional = '' 
)

Add a new user to the storage container.

Parameters
stringusername
stringpassword
mixedAdditional parameters to File_Password_*::addUser()
Returns
boolean

Definition at line 159 of file File.php.

References $additional, $params, $pass, $res, _load(), AUTH_LOG_DEBUG, PEAR\isError(), and Auth_Container\log().

160  {
161  $this->log('Auth_Container_File::addUser() called.', AUTH_LOG_DEBUG);
162  $params = array($user, $pass);
163  if (is_array($additional)) {
164  foreach ($additional as $item) {
165  $params[] = $item;
166  }
167  } else {
168  $params[] = $additional;
169  }
170 
171  $pw_obj = &$this->_load();
172  if (PEAR::isError($pw_obj)) {
173  return false;
174  }
175 
176  $res = call_user_func_array(array(&$pw_obj, 'addUser'), $params);
177  if (PEAR::isError($res)) {
178  return false;
179  }
180 
181  $res = $pw_obj->save();
182  if (PEAR::isError($res)) {
183  return false;
184  }
185 
186  return true;
187  }
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
& _load()
Load and initialize the File_Passwd object.
Definition: File.php:257
$additional
Definition: goto.php:89
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
$params
Definition: example_049.php:96
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ Here is the call graph for this function:

◆ Auth_Container_File()

Auth_Container_File::Auth_Container_File (   $filename)

Constructor of the container class.

Parameters
string$filenamepath to passwd file
Returns
object Auth_Container_File new Auth_Container_File object

Definition at line 86 of file File.php.

References $filename, _parseOptions(), and _setDefaults().

86  {
87  $this->_setDefaults();
88 
89  // Only file is a valid option here
90  if(is_array($filename)) {
91  $this->pwfile = $filename['file'];
92  $this->_parseOptions($filename);
93  } else {
94  $this->pwfile = $filename;
95  }
96  }
_parseOptions($array)
Parse options passed to the container class.
Definition: File.php:302
_setDefaults()
Set some default options.
Definition: File.php:288
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ changePassword()

Auth_Container_File::changePassword (   $username,
  $password 
)

Change password for user in the storage container.

Parameters
stringUsername
stringThe new password

Definition at line 228 of file File.php.

References $res, _load(), AUTH_LOG_DEBUG, PEAR\isError(), and Auth_Container\log().

229  {
230  $this->log('Auth_Container_File::changePassword() called.', AUTH_LOG_DEBUG);
231  $pw_obj = &$this->_load();
232  if (PEAR::isError($pw_obj)) {
233  return false;
234  }
235 
236  $res = $pw_obj->changePasswd($username, $password);
237  if (PEAR::isError($res)) {
238  return false;
239  }
240 
241  $res = $pw_obj->save();
242  if (PEAR::isError($res)) {
243  return false;
244  }
245 
246  return true;
247  }
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
& _load()
Load and initialize the File_Passwd object.
Definition: File.php:257
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ Here is the call graph for this function:

◆ fetchData()

Auth_Container_File::fetchData (   $user,
  $pass 
)

Authenticate an user.

Parameters
stringusername
stringpassword
Returns
mixed boolean|PEAR_Error

Definition at line 108 of file File.php.

References $pass, AUTH_LOG_DEBUG, and Auth_Container\log().

109  {
110  $this->log('Auth_Container_File::fetchData() called.', AUTH_LOG_DEBUG);
111  return File_Passwd::staticAuth($this->options['type'], $this->pwfile, $user, $pass);
112  }
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
+ Here is the call graph for this function:

◆ listUsers()

Auth_Container_File::listUsers ( )

List all available users.

Returns
array

Definition at line 122 of file File.php.

References _load(), AUTH_LOG_DEBUG, PEAR\isError(), and Auth_Container\log().

123  {
124  $this->log('Auth_Container_File::listUsers() called.', AUTH_LOG_DEBUG);
125 
126  $pw_obj = &$this->_load();
127  if (PEAR::isError($pw_obj)) {
128  return array();
129  }
130 
131  $users = $pw_obj->listUser();
132  if (!is_array($users)) {
133  return array();
134  }
135 
136  foreach ($users as $key => $value) {
137  $retVal[] = array("username" => $key,
138  "password" => $value['passwd'],
139  "cvsuser" => $value['system']);
140  }
141 
142  $this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG);
143 
144  return $retVal;
145  }
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
& _load()
Load and initialize the File_Passwd object.
Definition: File.php:257
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ Here is the call graph for this function:

◆ removeUser()

Auth_Container_File::removeUser (   $user)

Remove user from the storage container.

Parameters
stringUsername
Returns
boolean

Definition at line 198 of file File.php.

References $res, _load(), AUTH_LOG_DEBUG, PEAR\isError(), and Auth_Container\log().

199  {
200  $this->log('Auth_Container_File::removeUser() called.', AUTH_LOG_DEBUG);
201  $pw_obj = &$this->_load();
202  if (PEAR::isError($pw_obj)) {
203  return false;
204  }
205 
206  $res = $pw_obj->delUser($user);
207  if (PEAR::isError($res)) {
208  return false;
209  }
210 
211  $res = $pw_obj->save();
212  if (PEAR::isError($res)) {
213  return false;
214  }
215 
216  return true;
217  }
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
& _load()
Load and initialize the File_Passwd object.
Definition: File.php:257
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ Here is the call graph for this function:

Field Documentation

◆ $options

Auth_Container_File::$options = array()

Definition at line 75 of file File.php.

◆ $pwfile

Auth_Container_File::$pwfile = ''

Definition at line 68 of file File.php.


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