Source for file authentication.php
Documentation is available at authentication.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Authentication class, provides an interface for the Joomla authentication system
* @package Joomla.Platform
* This is the status code returned when the authentication is success (permit login)
* @const STATUS_SUCCESS successful response
// These are for authentication purposes (username and password is valid)
* Status to indicate cancellation of authentication (unused)
* @const STATUS_CANCEL cancelled request (unused)
* This is the status code returned when the authentication failed (prevent login if no success)
* @const STATUS_FAILURE failed request
// These are for authorisation purposes (can the user login)
* This is the status code returned when the account has expired (prevent login)
* @const STATUS_EXPIRED an expired account (will prevent login)
* This is the status code returned when the account has been denied (prevent login)
* @const STATUS_DENIED denied request (will prevent login)
* This is the status code returned when the account doesn't exist (not an error)
* @const STATUS_UNKNOWN unknown account (won't permit or prevent login)
* An array of Observer objects to notify
* The state of the observable object
* A multi dimensional array of [function][] = key for observers
* @var JAuthentication JAuthentication instances container.
protected static $instance;
JLog::add(JText::_('JLIB_USER_ERROR_AUTHENTICATION_LIBRARIES'), JLog::WARNING, 'jerror');
* Returns the global authentication object, only creating it
* if it doesn't already exist.
* @return JAuthentication The global JAuthentication object
if (empty(self::$instance))
self::$instance =
new JAuthentication;
* Get the state of the JAuthentication object
* @return mixed The state of the object.
* Attach an observer object
* @param object $observer An observer object to attach
public function attach($observer)
if (!isset
($observer['handler']) ||
!isset
($observer['event']) ||
!is_callable($observer['handler']))
// Make sure we haven't already attached this array as an observer
if (is_array($check) &&
$check['event'] ==
$observer['event'] &&
$check['handler'] ==
$observer['handler'])
$methods =
array($observer['event']);
// Make sure we haven't already attached this object as an observer
if ($check instanceof
$class)
foreach ($methods as $method)
if (!isset
($this->methods[$method]))
* Detach an observer object
* @param object $observer An observer object to detach.
* @return boolean True if the observer object was detached.
public function detach($observer)
foreach ($this->methods as &$method)
* Finds out if a set of login credentials are valid by asking all observing
* objects to run their respective authentication routines.
* @param array $credentials Array holding the user credentials.
* @param array $options Array holding user options.
* @return JAuthenticationResponse Response object with status variable filled in for last plugin or first successful plugin.
* @see JAuthenticationResponse
public function authenticate($credentials, $options =
array())
// Create authentication response
* Loop through the plugins and check if the credentials can be used to authenticate
* Any errors raised in the plugin should be returned via the JAuthenticationResponse
* and handled appropriately.
foreach ($plugins as $plugin)
$className =
'plg' .
$plugin->type .
$plugin->name;
$plugin =
new $className($this, (array)
$plugin);
// Bail here if the plugin can't be created
JLog::add(JText::sprintf('JLIB_USER_ERROR_AUTHENTICATION_FAILED_LOAD_PLUGIN', $className), JLog::WARNING, 'jerror');
$plugin->onUserAuthenticate($credentials, $options, $response);
// If authentication is successful break out of the loop
if ($response->status ===
self::STATUS_SUCCESS)
if (empty($response->type))
$response->type = isset
($plugin->_name) ?
$plugin->_name :
$plugin->name;
if (empty($response->username))
$response->username =
$credentials['username'];
if (empty($response->fullname))
$response->fullname =
$credentials['username'];
if (empty($response->password) && isset
($credentials['password']))
$response->password =
$credentials['password'];
* Authorises that a particular user should be able to login
* @param JAuthenticationResponse $response response including username of the user to authorise
* @param array $options list of options
* @return array[JAuthenticationResponse] results of authorisation
public static function authorise($response, $options =
array())
// Get plugins in case they haven't been imported already
$results =
$dispatcher->trigger('onUserAuthorisation', array($response, $options));
* Authentication response class, provides an object for storing user and error details
* @package Joomla.Platform
* Response status (see status codes)
public $status =
JAuthentication::STATUS_FAILURE;
* The type of authentication that was successful
* Any UTF-8 string that the End User wants to use as a username.
* Any UTF-8 string that the End User wants to use as a password.
* The email address of the End User as specified in section 3.4.1 of [RFC2822]
* UTF-8 string free text representation of the End User's full name.
* The End User's date of birth as YYYY-MM-DD. Any values whose representation uses
* fewer than the specified number of digits should be zero-padded. The length of this
* value MUST always be 10. If the End User user does not want to reveal any particular
* component of this value, it MUST be set to zero.
* For instance, if a End User wants to specify that his date of birth is in 1980, but
* not the month or day, the value returned SHALL be "1980-00-00".
* The End User's gender, "M" for male, "F" for female.
* UTF-8 string free text that SHOULD conform to the End User's country's postal system.
* The End User's country of residence as specified by ISO3166.
* End User's preferred language as specified by ISO639.
* ASCII string from TimeZone database
Documentation generated on Tue, 19 Nov 2013 14:54:10 +0100 by phpDocumentor 1.4.3