ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 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.

27 {
28 if(!empty($config))
29 {
30 foreach($config as $key => $value)
31 {
32 switch(strtolower($key))
33 {
34 case 'default_password_encoder':
35 $this->setDefaultEncoder($value);
36 break;
37 }
38 }
39 }
40
41 $this->initEncoders($config);
42 }

References setDefaultEncoder().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultEncoder()

ilUserPasswordEncoderFactory::getDefaultEncoder ( )
Returns
string

Definition at line 77 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 129 of file class.ilUserPasswordEncoderFactory.php.

130 {
131 if(!isset($this->encoders[$name]))
132 {
133 if(!$get_default_on_mismatch)
134 {
135 throw new ilUserException(sprintf('The encoder "%s" was not configured.', $name));
136 }
137 else if(!$this->getDefaultEncoder())
138 {
139 throw new ilUserException('No default encoder specified, fallback not possible.');
140 }
141 else if(!isset($this->encoders[$this->getDefaultEncoder()]))
142 {
143 throw new ilUserException("No default encoder found for name: '{$this->getDefaultEncoder()}'.");
144 }
145
146 return $this->encoders[$this->getDefaultEncoder()];
147 }
148
149 return $this->encoders[$name];
150 }
Class for user related exception handling in ILIAS.

References getDefaultEncoder().

+ Here is the call graph for this function:

◆ getEncoders()

ilUserPasswordEncoderFactory::getEncoders ( )
Returns
ilPasswordEncoder[]

Definition at line 93 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 118 of file class.ilUserPasswordEncoderFactory.php.

119 {
120 return array_keys($this->getEncoders());
121 }

References getEncoders().

+ Here is the call graph for this function:

◆ setDefaultEncoder()

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

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

86 {
87 $this->default_encoder = $default_encoder;
88 }

References $default_encoder.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setEncoders()

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

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

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

References $encoders.

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 setEncoders().


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