ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAuthProviderDatabase.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Authentication/classes/Provider/class.ilAuthProvider.php';
6 include_once './Services/Authentication/interfaces/interface.ilAuthProviderInterface.php';
7 
15 {
16 
17 
22  public function doAuthentication(ilAuthStatus $status)
23  {
24  include_once './Services/User/classes/class.ilUserPasswordManager.php';
25 
29  $user = ilObjectFactory::getInstanceByObjId(ilObjUser::_loginExists($this->getCredentials()->getUsername()), false);
30 
31  $this->getLogger()->debug('Trying to authenticate user: ' . $this->getCredentials()->getUsername());
32  if ($user instanceof ilObjUser) {
33 
34  if ($user->getId() == ANONYMOUS_USER_ID) {
35  $this->getLogger()->notice('Failed authentication for anonymous user id. ');
36  $this->handleAuthenticationFail($status, 'err_wrong_login');
37  return false;
38  }
39  if (!ilAuthUtils::isLocalPasswordEnabledForAuthMode($user->getAuthMode(true))) {
40  $this->getLogger()->debug('DB authentication failed: current user auth mode does not allow local validation.');
41  $this->getLogger()->debug('User auth mode: ' . $user->getAuthMode(true));
42  $this->handleAuthenticationFail($status, 'err_wrong_login');
43  return false;
44  }
45  if (ilUserPasswordManager::getInstance()->verifyPassword($user, $this->getCredentials()->getPassword())) {
46  $this->getLogger()->debug('Successfully authenticated user: ' . $this->getCredentials()->getUsername());
48  $status->setAuthenticatedUserId($user->getId());
49  return true;
50  }
51  }
52  $this->handleAuthenticationFail($status, 'err_wrong_login');
53  return false;
54  }
55 }
setAuthenticatedUserId($a_id)
Description of class class.
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
Base class for authentication providers (radius, ldap, apache, ...)
Standard interface for auth provider implementations.
setStatus($a_status)
Set auth status.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getLogger()
Get logger.
static isLocalPasswordEnabledForAuthMode($a_authmode)
Check if local password validation is enabled for a specific auth_mode.
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
doAuthentication(\ilAuthStatus $status)
Do authentication.
Auth status implementation.
static getInstance()
Single method to reduce footprint (included files, created instances)