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

Public Member Functions

 __construct (array $config=array())
 
 getDefaultEncoder ()
 
 setDefaultEncoder ($default_encoder)
 
 getEncoders ()
 
 setEncoders (array $encoders)
 
 getSupportedEncoderNames ()
 
 getEncoderByName ($name, $get_default_on_mismatch=false)
 

Protected Member Functions

 initEncoders (array $config)
 

Protected Attributes

 $default_encoder
 
 $encoders = array()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilUserPasswordEncoderFactory::__construct ( array  $config = array())
Parameters
array$config

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

References $config, $key, initEncoders(), and setDefaultEncoder().

27  {
28  if (!empty($config)) {
29  foreach ($config as $key => $value) {
30  switch (strtolower($key)) {
31  case 'default_password_encoder':
32  $this->setDefaultEncoder($value);
33  break;
34  }
35  }
36  }
37 
38  $this->initEncoders($config);
39  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultEncoder()

ilUserPasswordEncoderFactory::getDefaultEncoder ( )
Returns
string

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

References $default_encoder.

Referenced by getEncoderByName().

+ Here is the caller graph for this function:

◆ getEncoderByName()

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

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

References $name, and getDefaultEncoder().

115  {
116  if (!isset($this->encoders[$name])) {
117  if (!$get_default_on_mismatch) {
118  throw new ilUserException(sprintf('The encoder "%s" was not configured.', $name));
119  } elseif (!$this->getDefaultEncoder()) {
120  throw new ilUserException('No default encoder specified, fallback not possible.');
121  } elseif (!isset($this->encoders[$this->getDefaultEncoder()])) {
122  throw new ilUserException("No default encoder found for name: '{$this->getDefaultEncoder()}'.");
123  }
124 
125  return $this->encoders[$this->getDefaultEncoder()];
126  }
127 
128  return $this->encoders[$name];
129  }
Class for user related exception handling in ILIAS.
if($format !==null) $name
Definition: metadata.php:146
+ Here is the call graph for this function:

◆ getEncoders()

ilUserPasswordEncoderFactory::getEncoders ( )
Returns
ilPasswordEncoder[]

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

References $encoders.

Referenced by getSupportedEncoderNames().

+ Here is the caller graph for this function:

◆ getSupportedEncoderNames()

ilUserPasswordEncoderFactory::getSupportedEncoderNames ( )
Returns
string[]

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

References getEncoders().

104  {
105  return array_keys($this->getEncoders());
106  }
+ Here is the call graph for this function:

◆ initEncoders()

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

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

References $encoders.

Referenced by __construct().

45  {
46  $this->encoders = [];
47 
48  $encoders = [
52  ];
53 
54  foreach ($encoders as $encoder) {
55  if ($encoder->isSupportedByRuntime()) {
56  $this->encoders[$encoder->getName()] = $encoder;
57  }
58  }
59  }
+ Here is the caller graph for this function:

◆ setDefaultEncoder()

ilUserPasswordEncoderFactory::setDefaultEncoder (   $default_encoder)
Parameters
string$default_encoder

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

References $default_encoder.

Referenced by __construct().

73  {
74  $this->default_encoder = $default_encoder;
75  }
+ Here is the caller graph for this function:

◆ setEncoders()

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

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

References array.

90  {
91  $this->encoders = array();
92  foreach ($encoders as $encoder) {
93  if (!($encoder instanceof ilPasswordEncoder)) {
94  throw new ilUserException(sprintf('One of the passed encoders is not valid: %s.', json_encode($encoder)));
95  }
96  $this->encoders[$encoder->getName()] = $encoder;
97  }
98  }
Class for user related exception handling in ILIAS.
Create styles array
The data for the language used.

Field Documentation

◆ $default_encoder

ilUserPasswordEncoderFactory::$default_encoder
protected

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

Referenced by getDefaultEncoder(), and setDefaultEncoder().

◆ $encoders

ilUserPasswordEncoderFactory::$encoders = array()
protected

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

Referenced by getEncoders(), and initEncoders().


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