Class TUserManager

Description

Implements interfaces:

TUserManager class

TUserManager manages a static list of users TUser. The user information is specified via module configuration using the following XML syntax,

  1. <module id="users" class="System.Security.TUserManager" PasswordMode="Clear">
  2. <user name="Joe" password="demo" />
  3. <user name="John" password="demo" />
  4. <role name="Administrator" users="John" />
  5. <role name="Writer" users="Joe,John" />
  6. </module>

In addition, user information can also be loaded from an external file specified by UserFile property. Note, the property only accepts a file path in namespace format. The user file format is similar to the above sample.

The user passwords may be specified as clear text, SH1 or MD5 hashed by setting PasswordMode as Clear, SHA1 or MD5. The default name for a guest user is Guest. It may be changed by setting GuestName property.

TUserManager may be used together with TAuthManager which manages how users are authenticated and authorized in a Prado application.

  • since: 3.0
  • version: $Id: TUserManager.php 1398 2006-09-08 19:31:03Z xue $
  • author: Qiang Xue <qiang.xue@gmail.com>

Located in /Security/TUserManager.php (line 50)

TComponent
   |
   --TApplicationComponent
      |
      --TModule
         |
         --TUserManager
Class Constant Summary
 USER_FILE_EXT = '.xml'
Method Summary
string getGuestName ()
array getRoles ()
TUser getUser ([string $username = null])
string getUserFile ()
array getUsers ()
void init (TXmlElement $config)
void setGuestName (string $value)
void setUserFile (string $value)
void switchToGuest (TUser $user)
boolean validateUser (string $username, string $password)
Methods
getGuestName (line 175)
  • return: guest name, defaults to 'Guest'
  • access: public
string getGuestName ()
getPasswordMode (line 191)
  • return: how password is stored, clear text, or MD5 or SHA1 hashed. Default to TUserManagerPasswordMode::MD5.
  • access: public
TUserManagerPasswordMode getPasswordMode ()
getRoles (line 145)

Returns an array of user role information.

Each array element represents the roles for a single user. The array key is the username in lower case, and the array value is the roles (represented as an array) that the user is in.

  • return: list of user role information
  • access: public
array getRoles ()
getUser (line 225)

Returns a user instance given the user name.

  • return: the user instance, null if the specified username is not in the user database.
  • access: public
TUser getUser ([string $username = null])
  • string $username: user name, null if it is a guest.

Redefinition of:
TApplicationComponent::getUser()
getUserFile (line 153)
  • return: the full path to the file storing user/role information
  • access: public
string getUserFile ()
getUsers (line 133)

Returns an array of all users.

Each array element represents a single user. The array key is the username in lower case, and the array value is the corresponding user password.

  • return: list of users
  • access: public
array getUsers ()
init (line 88)

Initializes the module.

This method is required by IModule and is invoked by application. It loads user/role information from the module configuration.

  • access: public
void init (TXmlElement $config)

Redefinition of:
TModule::init()
Initializes the module.
setGuestName (line 183)
  • access: public
void setGuestName (string $value)
  • string $value: name to be used for guest users.
setPasswordMode (line 199)
  • access: public
void setPasswordMode (TUserManagerPasswordMode $value)
setUserFile (line 164)
  • access: public
  • throws: TInvalidOperationException if the module is already initialized
  • throws: TConfigurationException if the file is not in proper namespace format
void setUserFile (string $value)
  • string $value: user/role data file path (in namespace form). The file format is XML whose content is similar to that user/role block in application configuration.
switchToGuest (line 255)

Sets a user as a guest.

User name is changed as guest name, and roles are emptied.

  • access: public
void switchToGuest (TUser $user)
  • TUser $user: the user to be changed to a guest.
validateUser (line 210)

Validates if the username and password are correct.

  • return: true if validation is successful, false otherwise.
  • access: public
boolean validateUser (string $username, string $password)
  • string $username: user name
  • string $password: password

Inherited Methods

Inherited From TModule

TModule::getID()
TModule::init()
TModule::setID()

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Class Constants
USER_FILE_EXT = '.xml' (line 55)

extension name to the user file

Documentation generated on Sun, 14 Jan 2007 21:44:58 -0500 by phpDocumentor 1.3.0RC4