ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
sspmod_exampleauth_Auth_Source_UserPass Class Reference
+ Inheritance diagram for sspmod_exampleauth_Auth_Source_UserPass:
+ Collaboration diagram for sspmod_exampleauth_Auth_Source_UserPass:

Public Member Functions

 __construct ($info, $config)
 Constructor for this authentication source. More...
 
- Public Member Functions inherited from sspmod_core_Auth_UserPassBase
 __construct ($info, &$config)
 Constructor for this authentication source. More...
 
 setForcedUsername ($forcedUsername)
 Set forced username. More...
 
 getLoginLinks ()
 Return login links from configuration. More...
 
 getRememberUsernameEnabled ()
 Getter for the authsource config option remember.username.enabled. More...
 
 getRememberUsernameChecked ()
 Getter for the authsource config option remember.username.checked. More...
 
 isRememberMeEnabled ()
 Check if the "remember me" feature is enabled. More...
 
 isRememberMeChecked ()
 Check if the "remember me" checkbox should be checked. More...
 
 authenticate (&$state)
 Initialize login. More...
 
- Public Member Functions inherited from SimpleSAML_Auth_Source
 __construct ($info, &$config)
 Constructor for an authentication source. More...
 
 getAuthId ()
 Retrieve the ID of this authentication source. More...
 
 authenticate (&$state)
 Process a request. More...
 
 reauthenticate (array &$state)
 Reauthenticate an user. More...
 
 initLogin ($return, $errorURL=null, array $params=array())
 Start authentication. More...
 
 logout (&$state)
 Log out from this authentication source. More...
 

Protected Member Functions

 login ($username, $password)
 Attempt to log in using the given username and password. More...
 
- Protected Member Functions inherited from sspmod_core_Auth_UserPassBase
 login ($username, $password)
 Attempt to log in using the given username and password. More...
 
- Protected Member Functions inherited from SimpleSAML_Auth_Source
 addLogoutCallback ($assoc, $state)
 Add a logout callback association. More...
 
 callLogoutCallback ($assoc)
 Call a logout callback based on association. More...
 

Private Attributes

 $users
 Our users, stored in an associative array. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from sspmod_core_Auth_UserPassBase
static handleLogin ($authStateId, $username, $password)
 Handle login request. More...
 
- Static Public Member Functions inherited from SimpleSAML_Auth_Source
static getSourcesOfType ($type)
 Get sources of a specific type. More...
 
static completeAuth (&$state)
 Complete authentication. More...
 
static loginCompleted ($state)
 Called when a login operation has finished. More...
 
static completeLogout (&$state)
 Complete logout. More...
 
static getById ($authId, $type=null)
 Retrieve authentication source. More...
 
static logoutCallback ($state)
 Called when the authentication source receives an external logout request. More...
 
static getSources ()
 Retrieve list of authentication sources. More...
 
- Data Fields inherited from sspmod_core_Auth_UserPassBase
const STAGEID = 'sspmod_core_Auth_UserPassBase.state'
 The string used to identify our states. More...
 
const AUTHID = 'sspmod_core_Auth_UserPassBase.AuthId'
 The key of the AuthId field in the state. More...
 
- Static Protected Member Functions inherited from SimpleSAML_Auth_Source
static validateSource ($source, $id)
 Make sure that the first element of an auth source is its identifier. More...
 
- Protected Attributes inherited from sspmod_core_Auth_UserPassBase
 $loginLinks
 Links to pages from login page. More...
 
 $rememberUsernameEnabled = FALSE
 
 $rememberUsernameChecked = FALSE
 
 $rememberMeEnabled = FALSE
 
 $rememberMeChecked = FALSE
 
- Protected Attributes inherited from SimpleSAML_Auth_Source
 $authId
 

Detailed Description

Definition at line 12 of file UserPass.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_exampleauth_Auth_Source_UserPass::__construct (   $info,
  $config 
)

Constructor for this authentication source.

Parameters
array$infoInformation about this authentication source.
array$configConfiguration.

Definition at line 28 of file UserPass.php.

References $attributes, $config, $info, $password, array, and SimpleSAML\Utils\Attributes\normalizeAttributesArray().

28  {
29  assert('is_array($info)');
30  assert('is_array($config)');
31 
32  // Call the parent constructor first, as required by the interface
33  parent::__construct($info, $config);
34 
35  $this->users = array();
36 
37  // Validate and parse our configuration
38  foreach ($config as $userpass => $attributes) {
39  if (!is_string($userpass)) {
40  throw new Exception('Invalid <username>:<password> for authentication source ' .
41  $this->authId . ': ' . $userpass);
42  }
43 
44  $userpass = explode(':', $userpass, 2);
45  if (count($userpass) !== 2) {
46  throw new Exception('Invalid <username>:<password> for authentication source ' .
47  $this->authId . ': ' . $userpass[0]);
48  }
49  $username = $userpass[0];
50  $password = $userpass[1];
51 
52  try {
54  } catch(Exception $e) {
55  throw new Exception('Invalid attributes for user ' . $username .
56  ' in authentication source ' . $this->authId . ': ' .
57  $e->getMessage());
58  }
59 
60  $this->users[$username . ':' . $password] = $attributes;
61  }
62  }
static normalizeAttributesArray($attributes)
Validate and normalize an array with attributes.
Definition: Attributes.php:80
$attributes
$password
Definition: pwgen.php:17
Create styles array
The data for the language used.
$info
Definition: index.php:5
+ Here is the call graph for this function:

Member Function Documentation

◆ login()

sspmod_exampleauth_Auth_Source_UserPass::login (   $username,
  $password 
)
protected

Attempt to log in using the given username and password.

On a successful login, this function should return the users attributes. On failure, it should throw an exception. If the error was caused by the user entering the wrong username or password, a SimpleSAML_Error_Error('WRONGUSERPASS') should be thrown.

Note that both the username and the password are UTF-8 encoded.

Parameters
string$usernameThe username the user wrote.
string$passwordThe password the user wrote.
Returns
array Associative array with the users attributes.

Definition at line 78 of file UserPass.php.

References $password.

78  {
79  assert('is_string($username)');
80  assert('is_string($password)');
81 
82  $userpass = $username . ':' . $password;
83  if (!array_key_exists($userpass, $this->users)) {
84  throw new SimpleSAML_Error_Error('WRONGUSERPASS');
85  }
86 
87  return $this->users[$userpass];
88  }
$password
Definition: pwgen.php:17

Field Documentation

◆ $users

sspmod_exampleauth_Auth_Source_UserPass::$users
private

Our users, stored in an associative array.

The key of the array is "<username>:<password>", while the value of each element is a new array with the attributes for each user.

Definition at line 19 of file UserPass.php.


The documentation for this class was generated from the following file: