System.Security
[ class tree: System.Security ] [ index: System.Security ] [ all elements ]

Class: TUser

Source Location: /Security/TUser.php

Class Overview


TUser class

Class Details

[line 52]
TUser class

TUser class is a very basic implementation of IUser interface.

TUser is meant to be as the base class of other user classes (but not the only one.) TUser uses username and password as the authentication elements. You can access the username by the property Username. Whether the user is authenticated can be determined by the property IsAuthenticated.

Derived classes should override login and logout methods to accomplish the real authentication work (such as authenticating the user/password against DB). If Roles are used for authorization, isInRole should also be overriden. The methods onAuthenticationRequired and onAuthorizationRequired will be invoked by the framework when authentication and authorization fail, respectively. Default implementation simply displays an error message. In most cases, the two methods should be overriden to provide customized handlings (such as transfer to the login page).

Namespace: System.Security

Properties

  • Username, string
    Gets or sets the username of TUser.
  • IsAuthenticated, boolean, default=true
    Gets or sets whether the user passes the authentication.




version:  v1.0, last update on 2004/10/24 12:00:00
author:  Qiang Xue <qiang.xue@gmail.com>, Tim Evans <tim.evans@gmail.com>


[ Top ]

Methods



Class Methods


constructor __construct [line 69]

TUser __construct( mixed $config)

Constructor.



Parameters:

mixed   $config   the app spec related with user class.

[ Top ]

method getUsername [line 131]

string getUsername( )



return:  the username of TUser
access:  public


[ Top ]

method isAuthenticated [line 114]

boolean isAuthenticated( )



return:  whether the user is authenticated
access:  public


[ Top ]

method isInRole [line 80]

boolean isInRole( string $role)

Checks if the user is of certain role.

Default implementation will only return true if the role to be checked is empty. Derived classes should override this method if roles are used for authorization.




return:  if the user is of the role
access:  public


Parameters:

string   $role   the role to be checked

[ Top ]

method login [line 154]

boolean login( string $username, string $password)

Authenticates a user by his/her username and password.

Default implementation simply saves the username and sets authentication true. Derived classes should override this method to do real authentication work such as check the username/password against DB.




return:  if authentication succeeds
access:  public


Parameters:

string   $username   the username
string   $password   the password

[ Top ]

method logout [line 166]

void logout( )

Sets authentication false for the user.

Default implementation will destroy all session data related to the user visit. Derived classes may override this method to provide special treatment.




access:  public


[ Top ]

method onAuthenticationRequired [line 92]

void onAuthenticationRequired( string $pageName)

This method is invoked by the framework when authentication fails.

Default implementation simply displays an error message. Derived classes may override this method to provide customized treatment when authentication fails (e.g. transfer to login page)




access:  public


Parameters:

string   $pageName   the name of the page that requires authentication.

[ Top ]

method onAuthorizationRequired [line 105]

void onAuthorizationRequired( TPage $page)

This method is invoked by the framework when authorization fails.

Default implementation simply displays an error message. Derived classes may override this method to provide customized treatment when authorization fails (e.g. transfer to login page)




access:  public


Parameters:

TPage   $page   the page object that are not authorized to be accessed.

[ Top ]

method setAuthenticated [line 123]

void setAuthenticated( boolean $authenticated)

Sets the value indicating whether the user is authenticated.



access:  public


Parameters:

boolean   $authenticated   whether the user is authenticated.

[ Top ]

method setUsername [line 140]

void setUsername( string $username)

Sets the username of TUser object



access:  public


Parameters:

string   $username   the username

[ Top ]


© 2004-2005 PRADO Software Group. All Rights Reserved.