ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilUserPasswordEncoderFactory Class Reference
+ Collaboration diagram for ilUserPasswordEncoderFactory:

Public Member Functions

 __construct (array $config=[])
 
 getDefaultEncoder ()
 
 setDefaultEncoder (string $default_encoder)
 
 getSupportedEncoders ()
 
 setSupportedEncoders (array $supported_encoders)
 
 getSupportedEncoderNames ()
 
 getEncoderByName (?string $name)
 

Private Member Functions

 getEncoders (array $config)
 
 initEncoders (array $config)
 

Private Attributes

string $default_encoder = null
 
array $supported_encoders = []
 

Detailed Description

Definition at line 21 of file class.ilUserPasswordEncoderFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserPasswordEncoderFactory::__construct ( array  $config = [])
Parameters
array<string,mixed>$config
Exceptions
ilPasswordException

Definition at line 31 of file class.ilUserPasswordEncoderFactory.php.

References ILIAS\LTI\ToolProvider\$key, initEncoders(), and setDefaultEncoder().

32  {
33  if (!empty($config)) {
34  foreach ($config as $key => $value) {
35  switch (strtolower($key)) {
36  case 'default_password_encoder':
37  $this->setDefaultEncoder($value);
38  break;
39  }
40  }
41  }
42 
43  $this->initEncoders($config);
44  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultEncoder()

ilUserPasswordEncoderFactory::getDefaultEncoder ( )

Definition at line 77 of file class.ilUserPasswordEncoderFactory.php.

References $default_encoder.

Referenced by getEncoderByName().

77  : ?string
78  {
80  }
+ Here is the caller graph for this function:

◆ getEncoderByName()

ilUserPasswordEncoderFactory::getEncoderByName ( ?string  $name)
Exceptions
ilUserException

Definition at line 124 of file class.ilUserPasswordEncoderFactory.php.

References getDefaultEncoder().

125  {
126  if ($name !== null && isset($this->supported_encoders[$name])) {
127  return $this->supported_encoders[$name];
128  }
129 
130  if (!$this->getDefaultEncoder()) {
131  throw new ilUserException('No default encoder specified, fallback not possible.');
132  } elseif (!isset($this->supported_encoders[$this->getDefaultEncoder()])) {
133  throw new ilUserException("No default encoder found for name: '{$this->getDefaultEncoder()}'.");
134  }
135 
136  return $this->supported_encoders[$this->getDefaultEncoder()];
137  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getEncoders()

ilUserPasswordEncoderFactory::getEncoders ( array  $config)
private
Parameters
array<string,mixed>$config
Returns
list<ilPasswordEncoder>
Exceptions
ilPasswordException

Definition at line 51 of file class.ilUserPasswordEncoderFactory.php.

Referenced by initEncoders().

+ Here is the caller graph for this function:

◆ getSupportedEncoderNames()

ilUserPasswordEncoderFactory::getSupportedEncoderNames ( )
Returns
list<string>

Definition at line 116 of file class.ilUserPasswordEncoderFactory.php.

References getSupportedEncoders().

116  : array
117  {
118  return array_keys($this->getSupportedEncoders());
119  }
+ Here is the call graph for this function:

◆ getSupportedEncoders()

ilUserPasswordEncoderFactory::getSupportedEncoders ( )
Returns
array<string, ilPasswordEncoder>

Definition at line 90 of file class.ilUserPasswordEncoderFactory.php.

References $supported_encoders.

Referenced by getSupportedEncoderNames().

90  : array
91  {
93  }
+ Here is the caller graph for this function:

◆ initEncoders()

ilUserPasswordEncoderFactory::initEncoders ( array  $config)
private
Parameters
array<string,mixed>$config
Exceptions
ilPasswordException

Definition at line 65 of file class.ilUserPasswordEncoderFactory.php.

References getEncoders().

Referenced by __construct().

65  : void
66  {
67  $this->supported_encoders = [];
68 
69  $encoders = $this->getEncoders($config);
70  foreach ($encoders as $encoder) {
71  if ($encoder->isSupportedByRuntime()) {
72  $this->supported_encoders[$encoder->getName()] = $encoder;
73  }
74  }
75  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDefaultEncoder()

ilUserPasswordEncoderFactory::setDefaultEncoder ( string  $default_encoder)

Definition at line 82 of file class.ilUserPasswordEncoderFactory.php.

References $default_encoder.

Referenced by __construct().

82  : void
83  {
84  $this->default_encoder = $default_encoder;
85  }
+ Here is the caller graph for this function:

◆ setSupportedEncoders()

ilUserPasswordEncoderFactory::setSupportedEncoders ( array  $supported_encoders)
Parameters
list<ilPasswordEncoder>$supported_encoders
Exceptions
ilUserException

Definition at line 99 of file class.ilUserPasswordEncoderFactory.php.

Referenced by ilObjUserPasswordTest\testFactoryReturnsCorrectEncoderIfAMatchingEncoderWasFound(), and ilObjUserPasswordTest\testFactoryReturnsTheDefaultEncoderIfAnUnsupportedEncoderIsRequestedAndASupportedDefaultEncoderWasSpecifiedInFallbackMode().

99  : void
100  {
101  $this->supported_encoders = [];
102  foreach ($supported_encoders as $encoder) {
103  if (!($encoder instanceof ilPasswordEncoder) || !$encoder->isSupportedByRuntime()) {
104  throw new ilUserException(sprintf(
105  'One of the passed encoders is not valid: %s.',
106  print_r($encoder, true)
107  ));
108  }
109  $this->supported_encoders[$encoder->getName()] = $encoder;
110  }
111  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

Field Documentation

◆ $default_encoder

string ilUserPasswordEncoderFactory::$default_encoder = null
private

Definition at line 23 of file class.ilUserPasswordEncoderFactory.php.

Referenced by getDefaultEncoder(), and setDefaultEncoder().

◆ $supported_encoders

array ilUserPasswordEncoderFactory::$supported_encoders = []
private

Definition at line 25 of file class.ilUserPasswordEncoderFactory.php.

Referenced by getSupportedEncoders().


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