Class NUser


Authentication and authorization.

NObject
   |
   --NUser

Implements interfaces:

Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Web/User.php (line 42)
Public Method Summary
void
authenticate (string $username, string $password, [mixed $extra = NULL])
Conducts the authentication process.
IAuthenticator
Returns authentication handler.
IAuthorizator
Returns current authorization handler.
IIdentity
Returns current user identity, if any.
string
Returns current namespace.
array
Returns a list of effective roles that a user has been granted.
int
Why was user signed out?
bool
isAllowed ([string $resource = NULL], [string $privilege = NULL])
Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.
bool
Is this user authenticated?
bool
isInRole (string $role)
Is a user in the specified effective role?
NUser
Sets authentication handler.
NUser
Sets authorization handler.
NUser
setExpiration (mixed $seconds, [bool $whenBrowserIsClosed = TRUE], [bool $clearIdentity = FALSE])
Enables sign out after inactivity.
NUser
setNamespace (string $namespace)
Changes namespace; allows more users to share a session.
void
signOut ([bool $clearIdentity = FALSE])
Logs off the user from the current session.
Protected Method Summary
protected NSession
Returns session handler.
protected NSessionNamespace
Returns and initializes $this->session.
protected NUser
setAuthenticated (bool $state)
Sets the authenticated status of this user.
protected NUser
setIdentity ([$identity = NULL])
Sets the user identity.
Methods Inherited From NObject
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Constant Summary
int BROWSER_CLOSED 3

line 47

sign-out reason NUser::getSignOutReason()
int INACTIVITY 2

line 46

sign-out reason NUser::getSignOutReason()
int MANUAL 1

line 45

sign-out reason NUser::getSignOutReason()
Variable Summary
string $authenticatedRole 'authenticated'

line 54

default role for authenticated user without own identity
string $guestRole 'guest'

line 51

default role for unauthenticated user
array $onAuthenticated

line 57

of function(NUser $sender); Occurs when the user is successfully authenticated
array $onSignedOut

line 60

of function(NUser $sender); Occurs when the user is logged off

Method Details

line 88

authenticate

public void authenticate (string $username, string $password, [mixed $extra = NULL])

Conducts the authentication process.

Implementation of:

Input
string $username
string $password
mixed $extra
Output
void  
Throws
throws NAuthenticationException if authentication was not successful

line 170

getAuthenticationHandler

public IAuthenticator getAuthenticationHandler ()

Returns authentication handler.

Output
IAuthenticator  

line 416

getAuthorizationHandler

public IAuthorizator getAuthorizationHandler ()

Returns current authorization handler.

Output
IAuthorizator  

line 145

getIdentity

public IIdentity getIdentity ()

Returns current user identity, if any.

Implementation of:

Output
IIdentity  

line 200

getNamespace

public string getNamespace ()

Returns current namespace.

Implementation of:

Output
string  

line 352

getRoles

public array getRoles ()

Returns a list of effective roles that a user has been granted.

Implementation of:

Output
array  

line 434

getSession

protected NSession getSession ()

Returns session handler.

Output
NSession  

line 257

getSessionNamespace

protected NSessionNamespace getSessionNamespace ($need)

Returns and initializes $this->session.

Input
$need
Output
NSessionNamespace  

line 245

getSignOutReason

public int getSignOutReason ()

Why was user signed out?

Output
int  

line 383

isAllowed

public bool isAllowed ([string $resource = NULL], [string $privilege = NULL])

Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.

Implementation of:

Input
string $resource resource
string $privilege privilege
Output
bool  

line 133

isAuthenticated

public bool isAuthenticated ()

Is this user authenticated?

Implementation of:

Output
bool  

line 369

isInRole

public bool isInRole (string $role)

Is a user in the specified effective role?

Implementation of:

Input
string $role
Output
bool  

line 310

setAuthenticated

protected NUser setAuthenticated (bool $state)

Sets the authenticated status of this user.

Input
bool $state flag indicating the authenticated status of user
Output
NUser provides a fluent interface

line 158

setAuthenticationHandler

public NUser setAuthenticationHandler ($handler)

Sets authentication handler.

Input
$handler
Output
NUser provides a fluent interface

line 404

setAuthorizationHandler

public NUser setAuthorizationHandler ($handler)

Sets authorization handler.

Input
$handler
Output
NUser provides a fluent interface

line 214

setExpiration

public NUser setExpiration (mixed $seconds, [bool $whenBrowserIsClosed = TRUE], [bool $clearIdentity = FALSE])

Enables sign out after inactivity.

Input
mixed $seconds number of seconds or timestamp
bool $whenBrowserIsClosed sign out when the browser is closed?
bool $clearIdentity clear the identity from persistent storage?
Output
NUser provides a fluent interface

line 336

setIdentity

protected NUser setIdentity ([$identity = NULL])

Sets the user identity.

Input
$identity
Output
NUser provides a fluent interface

line 185

setNamespace

public NUser setNamespace (string $namespace)

Changes namespace; allows more users to share a session.

Implementation of:

Input
string $namespace
Output
NUser provides a fluent interface

line 115

signOut

public void signOut ([bool $clearIdentity = FALSE])

Logs off the user from the current session.

Implementation of:

Input
bool $clearIdentity clear the identity from persistent storage?
Output
void