ILIAS  release_8 Revision v8.24
ilUserPasswordEncoderFactory Class Reference
+ Collaboration diagram for ilUserPasswordEncoderFactory:

Public Member Functions

 __construct (array $config=[])
 
 getDefaultEncoder ()
 
 setDefaultEncoder (string $defaultEncoder)
 
 getEncoders ()
 
 setEncoders (array $encoders)
 
 getSupportedEncoderNames ()
 
 getEncoderByName (?string $name, bool $get_default_on_mismatch=false)
 
 getFirstEncoderForEncodedPasswordAndMatchers (string $encoded, array $matchers)
 

Protected Member Functions

 getValidEncoders (array $config)
 
 initEncoders (array $config)
 

Protected Attributes

string $defaultEncoder = null
 
array $encoders = []
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilUserPasswordEncoderFactory::__construct ( array  $config = [])
Parameters
array$config
Exceptions
ilPasswordException

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

37 {
38 if (!empty($config)) {
39 foreach ($config as $key => $value) {
40 switch (strtolower($key)) {
41 case 'default_password_encoder':
42 $this->setDefaultEncoder($value);
43 break;
44 }
45 }
46 }
47
48 $this->initEncoders($config);
49 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
string $key
Consumer key/client ID value.
Definition: System.php:193

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultEncoder()

ilUserPasswordEncoderFactory::getDefaultEncoder ( )

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

81 : ?string
82 {
84 }

References $defaultEncoder.

Referenced by getEncoderByName(), and getFirstEncoderForEncodedPasswordAndMatchers().

+ Here is the caller graph for this function:

◆ getEncoderByName()

ilUserPasswordEncoderFactory::getEncoderByName ( ?string  $name,
bool  $get_default_on_mismatch = false 
)
Parameters
string$name
bool$get_default_on_mismatch
Returns
ilPasswordEncoder
Exceptions
ilUserException

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

132 {
133 if ($name !== null && isset($this->encoders[$name])) {
134 return $this->encoders[$name];
135 }
136
137 if (!$get_default_on_mismatch) {
138 throw new ilUserException(sprintf('The encoder "%s" was not configured.', $name));
139 } elseif (!$this->getDefaultEncoder()) {
140 throw new ilUserException('No default encoder specified, fallback not possible.');
141 } elseif (!isset($this->encoders[$this->getDefaultEncoder()])) {
142 throw new ilUserException("No default encoder found for name: '{$this->getDefaultEncoder()}'.");
143 }
144
145 return $this->encoders[$this->getDefaultEncoder()];
146 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($format !==null) $name
Definition: metadata.php:247

References $name, and getDefaultEncoder().

Referenced by getFirstEncoderForEncodedPasswordAndMatchers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEncoders()

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

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

References $encoders.

Referenced by getFirstEncoderForEncodedPasswordAndMatchers(), and getSupportedEncoderNames().

+ Here is the caller graph for this function:

◆ getFirstEncoderForEncodedPasswordAndMatchers()

ilUserPasswordEncoderFactory::getFirstEncoderForEncodedPasswordAndMatchers ( string  $encoded,
array  $matchers 
)
Parameters
string$encoded
array$matchersAn key/value pair callback functions (accepting the encoded password) assigned to the respective encoder name
Returns
ilPasswordEncoder
Exceptions
ilUserException

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

155 {
156 foreach ($this->getEncoders() as $encoder) {
157 foreach ($matchers as $encoderName => $callback) {
158 if (
159 is_callable($callback) &&
160 $encoder->getName() === $encoderName &&
161 $callback($encoded) === true
162 ) {
163 return $encoder;
164 }
165 }
166 }
167
168 return $this->getEncoderByName($this->getDefaultEncoder());
169 }
getEncoderByName(?string $name, bool $get_default_on_mismatch=false)

References getDefaultEncoder(), getEncoderByName(), and getEncoders().

+ Here is the call graph for this function:

◆ getSupportedEncoderNames()

ilUserPasswordEncoderFactory::getSupportedEncoderNames ( )
Returns
string[]

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

120 : array
121 {
122 return array_keys($this->getEncoders());
123 }

References getEncoders().

+ Here is the call graph for this function:

◆ getValidEncoders()

ilUserPasswordEncoderFactory::getValidEncoders ( array  $config)
protected
Parameters
array$config
Returns
ilPasswordEncoder[]
Exceptions
ilPasswordException

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

References $config.

Referenced by initEncoders().

+ Here is the caller graph for this function:

◆ initEncoders()

ilUserPasswordEncoderFactory::initEncoders ( array  $config)
protected
Parameters
array$config
Exceptions
ilPasswordException

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

69 : void // Missing array type.
70 {
71 $this->encoders = [];
72
74 foreach ($encoders as $encoder) {
75 if ($encoder->isSupportedByRuntime()) {
76 $this->encoders[$encoder->getName()] = $encoder;
77 }
78 }
79 }

References $encoders, and getValidEncoders().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDefaultEncoder()

ilUserPasswordEncoderFactory::setDefaultEncoder ( string  $defaultEncoder)

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

86 : void
87 {
88 $this->defaultEncoder = $defaultEncoder;
89 }

References $defaultEncoder.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setEncoders()

ilUserPasswordEncoderFactory::setEncoders ( array  $encoders)
Parameters
ilPasswordEncoder[]$encoders
Exceptions
ilUserException

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

103 : void
104 {
105 $this->encoders = [];
106 foreach ($encoders as $encoder) {
107 if (!($encoder instanceof ilPasswordEncoder)) {
108 throw new ilUserException(sprintf(
109 'One of the passed encoders is not valid: %s.',
110 json_encode($encoder, JSON_THROW_ON_ERROR)
111 ));
112 }
113 $this->encoders[$encoder->getName()] = $encoder;
114 }
115 }

References $encoders.

Field Documentation

◆ $defaultEncoder

string ilUserPasswordEncoderFactory::$defaultEncoder = null
protected

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

Referenced by getDefaultEncoder(), and setDefaultEncoder().

◆ $encoders

array ilUserPasswordEncoderFactory::$encoders = []
protected

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

Referenced by getEncoders(), initEncoders(), and setEncoders().


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