19 require_once(BASE.
"wcmf/lib/security/class.User.php");
20 require_once(BASE.
"wcmf/lib/security/class.UserManager.php");
21 require_once(BASE.
"wcmf/lib/security/class.RightsManager.php");
22 require_once(BASE.
"wcmf/lib/core/class.WCMFException.php");
23 require_once(BASE.
"wcmf/lib/util/class.ObjectFactory.php");
24 require_once(BASE.
"wcmf/lib/util/class.InifileParser.php");
48 function login($login, $password, $isPasswordEncrypted=
false)
53 if (!$isPasswordEncrypted)
59 $isAnonymous = $rightsManager->isAnonymous();
61 $rightsManager->deactivate();
66 $user = &$userInstance->getUser($login, $password);
73 $this->_user = &$user->duplicate();
74 $this->
setOID($user->getOID());
78 if (strlen($config) > 0)
80 if (!$parser->parseIniFile(
$GLOBALS[
'CONFIG_PATH'].$config,
true))
85 if (($policies = $parser->getSection(
'authorization')) ===
false)
90 $this->_login_time = strftime(
"%c", mktime());
96 $rightsManager->activate();
108 foreach ($policies AS $key => $value)
110 if (!isset($this->_policies[$key]))
113 $this->_policies[$key] = $parsedPolicies;
126 if ($actionKey ==
'')
129 if (isset($this->_policies[$actionKey]))
130 return $this->
matchRoles($this->_policies[$actionKey]);
143 if (isset($val[
'allow']))
144 foreach ($val[
'allow'] as $value)
148 if (isset($val[
'deny']))
149 foreach ($val[
'deny'] as $value)
153 return $val[
'default'];
166 $roles = explode(
" ", $val);
167 foreach ($roles as $value)
170 if (strlen($value)==2 && substr($value,1,1) ==
"*")
172 if (substr($value,0,1)==
"+")
173 $rtn[
'default'] =
true;
174 else if (substr($value,0,1)==
"-")
175 $rtn[
'default'] =
false;
179 if (substr($value,0,1)==
"+")
180 $rtn[
'allow'][] = substr($value,1);
181 else if (substr($value,0,1)==
"-")
182 $rtn[
'deny'][] = substr($value,1);
186 $rtn[
'allow'][] = $value;
199 $this->_defaulPolicy = $val;
217 if ($this->_user != null)
218 return $this->_user->toString();
240 if ($this->_user != null)
241 $this->_user->setLogin($login);
249 if ($this->_user != null)
250 return $this->_user->getLogin();
259 if ($this->_user != null)
260 $this->_user->setPassword($password);
268 if ($this->_user != null)
269 return $this->_user->getPassword();
278 if ($this->_user != null)
279 $this->_user->setName($name);
287 if ($this->_user != null)
288 return $this->_user->getName();
297 if ($this->_user != null)
298 $this->_user->setFirstname($firstname);
306 if ($this->_user != null)
307 return $this->_user->getFirstname();
316 if ($this->_user != null)
317 $this->_user->setConfig($config);
327 if ($this->_user != null)
328 return basename($this->_user->getConfig());
353 if ($this->_user != null)
354 return $this->_user->hasRole($rolename);
364 if ($this->_user != null)
365 return $this->_user->getRoles();
382 if (($userClassName = $parser->getValue(
'User',
'implementation')) ===
false)
384 $userClassFile = $objectFactory->getClassfileFromConfig($userClassName);
386 if (($roleClassName = $parser->getValue(
'Role',
'implementation')) ===
false)
388 $roleClassName = $objectFactory->getClassfileFromConfig($roleClassName);
390 return array(__FILE__, BASE.$userClassFile, BASE.$roleClassName);
AuthUser provides a storage and methods for user data used for authentication/authorization purposes...
Abstract base class for user classes that represent a system user.
throwEx($message, $file='', $line='')
getClassDefinitionFiles()
encryptPassword($password)
login($login, $password, $isPasswordEncrypted=false)