1<?php 2 3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5include_once './Services/Authentication/classes/Provider/class.ilAuthProvider.php'; 6include_once './Services/Authentication/interfaces/interface.ilAuthProviderInterface.php'; 7 8/** 9 * Description of class class 10 * 11 * @author Stefan Meyer <smeyer.ilias@gmx.de> 12 * 13 */ 14class ilAuthProviderDatabase extends ilAuthProvider implements ilAuthProviderInterface 15{ 16 17 18 /** 19 * Do authentication 20 * @return bool 21 */ 22 public function doAuthentication(ilAuthStatus $status) 23 { 24 include_once './Services/User/classes/class.ilUserPasswordManager.php'; 25 26 /** 27 * @var $user ilObjUser 28 */ 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 if ($user->getId() == ANONYMOUS_USER_ID) { 34 $this->getLogger()->notice('Failed authentication for anonymous user id. '); 35 $this->handleAuthenticationFail($status, 'err_wrong_login'); 36 return false; 37 } 38 if (!ilAuthUtils::isLocalPasswordEnabledForAuthMode($user->getAuthMode(true))) { 39 $this->getLogger()->debug('DB authentication failed: current user auth mode does not allow local validation.'); 40 $this->getLogger()->debug('User auth mode: ' . $user->getAuthMode(true)); 41 $this->handleAuthenticationFail($status, 'err_wrong_login'); 42 return false; 43 } 44 if (ilUserPasswordManager::getInstance()->verifyPassword($user, $this->getCredentials()->getPassword())) { 45 $this->getLogger()->debug('Successfully authenticated user: ' . $this->getCredentials()->getUsername()); 46 $status->setStatus(ilAuthStatus::STATUS_AUTHENTICATED); 47 $status->setAuthenticatedUserId($user->getId()); 48 return true; 49 } 50 } 51 $this->handleAuthenticationFail($status, 'err_wrong_login'); 52 return false; 53 } 54} 55