## Class TUserManager

Description

Implements interfaces:

- IUserManager

TUserManager class

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

     <module id="users" class="System.Security.TUserManager" PasswordMode="Clear">
       <user name="Joe" password="demo" />
       <user name="John" password="demo" />
       <role name="Administrator" users="John" />
       <role name="Writer" users="Joe,John" />
     </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 2541 2008-10-21 15:05:13Z qiang.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 ()
TUserManagerPasswordMode getPasswordMode ()
array getRoles ()
TUser getUser ([string $username = null])
string getUserFile ()
TUser getUserFromCookie (THttpCookie $cookie)
array getUsers ()
void init (TXmlElement $config)
void loadUserData (TXmlElement $xmlNode)
void saveUserToCookie (THttpCookie $cookie)
void setGuestName (string $value)
void setPasswordMode (TUserManagerPasswordMode $value)
void setUserFile (string $value)
void switchToGuest (TUser $user)
boolean validateUser (string $username, string $password)
Methods
getGuestName (line 178)

- return: guest name, defaults to 'Guest'
- access: public

string getGuestName ()
getPasswordMode (line 194)

- return: how password is stored, clear text, or MD5 or SHA1 hashed. Default to TUserManagerPasswordMode::MD5.
- access: public

TUserManagerPasswordMode getPasswordMode ()
getRoles (line 148)

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 228)

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 156)

- return: the full path to the file storing user/role information
- access: public

string getUserFile ()
getUserFromCookie (line 259)

Returns a user instance according to auth data stored in a cookie.

- return: the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
- access: public
- since: 3.1.1

TUser getUserFromCookie (THttpCookie $cookie)

- THttpCookie $cookie: the cookie storing user authentication information

getUsers (line 136)

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)

- TXmlElement $config: module configuration

Redefinition of:

TModule::init()
  Initializes the module.

loadUserData (line 104)

Loads user/role information from an XML node.

- access: protected

void loadUserData (TXmlElement $xmlNode)

- TXmlElement $xmlNode: the XML node containing the user information

saveUserToCookie (line 279)

Saves user auth data into a cookie.

- access: public
- since: 3.1.1

void saveUserToCookie (THttpCookie $cookie)

- THttpCookie $cookie: the cookie to receive the user auth data.

setGuestName (line 186)

- access: public

void setGuestName (string $value)

- string $value: name to be used for guest users.

setPasswordMode (line 202)

- access: public

void setPasswordMode (TUserManagerPasswordMode $value)

- TUserManagerPasswordMode $value: how password is stored, clear text, or MD5 or SHA1 hashed.

setUserFile (line 167)

- 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 295)

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 213)

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 Mon, 22 Feb 2010 12:18:58 +0000 by phpDocumentor 1.3.0RC4