ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilUserPasswordManager Class Reference
+ Collaboration diagram for ilUserPasswordManager:

Public Member Functions

 __construct (array $config=array())
 Please use the singleton method for instance creation The constructor is still public because of the unit tests.
 getEncoderName ()
 setEncoderName ($encoder_name)
 getEncoderFactory ()
 setEncoderFactory (ilUserPasswordEncoderFactory $encoder_factory)
 encodePassword (ilObjUser $user, $raw)
 isEncodingTypeSupported ($name)
 verifyPassword (ilObjUser $user, $raw)

Data Fields

const MIN_SALT_SIZE = 16

Protected Attributes

 $encoder_factory
 $encoder_name
 $config = array()

Static Private Attributes

static $instance

Detailed Description

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

Constructor & Destructor Documentation

ilUserPasswordManager::__construct ( array  $config = array())

Please use the singleton method for instance creation The constructor is still public because of the unit tests.

Parameters
array$config
Exceptions
ilUserException

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

References $config, getEncoderFactory(), getEncoderName(), setEncoderFactory(), and setEncoderName().

{
if(!empty($config))
{
foreach($config as $key => $value)
{
switch(strtolower($key))
{
case 'password_encoder':
$this->setEncoderName($value);
break;
case 'encoder_factory':
$this->setEncoderFactory($value);
break;
}
}
}
if(!$this->getEncoderName())
{
throw new ilUserException(sprintf('"password_encoder" must be set in %s.', json_encode($config)));
}
{
throw new ilUserException(sprintf('"encoder_factory" must be instance of ilUserPasswordEncoderFactory and set in %s.', json_encode($config)));
}
}

+ Here is the call graph for this function:

Member Function Documentation

ilUserPasswordManager::encodePassword ( ilObjUser  $user,
  $raw 
)
Parameters
ilObjUser$user
string$rawThe raw password

Definition at line 145 of file class.ilUserPasswordManager.php.

References ilPasswordUtils\getBytes(), getEncoderFactory(), getEncoderName(), ilObjUser\getPasswordSalt(), IL_PASSWD_CRYPTED, ilObjUser\setPasswd(), ilObjUser\setPasswordEncodingType(), and ilObjUser\setPasswordSalt().

{
$encoder = $this->getEncoderFactory()->getEncoderByName($this->getEncoderName());
$user->setPasswordEncodingType($encoder->getName());
if($encoder->requiresSalt())
{
require_once 'Services/Password/classes/class.ilPasswordUtils.php';
substr(str_replace('+', '.', base64_encode(ilPasswordUtils::getBytes(self::MIN_SALT_SIZE))), 0, 22)
);
}
else
{
$user->setPasswordSalt(null);
}
$user->setPasswd($encoder->encodePassword($raw, $user->getPasswordSalt()), IL_PASSWD_CRYPTED);
}

+ Here is the call graph for this function:

ilUserPasswordManager::getEncoderFactory ( )
Returns
ilUserPasswordEncoderFactory

Definition at line 128 of file class.ilUserPasswordManager.php.

References $encoder_factory.

Referenced by __construct(), encodePassword(), isEncodingTypeSupported(), and verifyPassword().

+ Here is the caller graph for this function:

ilUserPasswordManager::getEncoderName ( )
Returns
string

Definition at line 112 of file class.ilUserPasswordManager.php.

References $encoder_name.

Referenced by __construct(), encodePassword(), and verifyPassword().

{
}

+ Here is the caller graph for this function:

ilUserPasswordManager::isEncodingTypeSupported (   $name)
Parameters
string$name
Returns
bool

Definition at line 167 of file class.ilUserPasswordManager.php.

References getEncoderFactory().

{
return in_array($name, $this->getEncoderFactory()->getSupportedEncoderNames());
}

+ Here is the call graph for this function:

ilUserPasswordManager::setEncoderFactory ( ilUserPasswordEncoderFactory  $encoder_factory)
Parameters
ilUserPasswordEncoderFactory$encoder_factory

Definition at line 136 of file class.ilUserPasswordManager.php.

References $encoder_factory.

Referenced by __construct().

{
$this->encoder_factory = $encoder_factory;
}

+ Here is the caller graph for this function:

ilUserPasswordManager::setEncoderName (   $encoder_name)
Parameters
string$encoder_name

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

References $encoder_name.

Referenced by __construct().

{
$this->encoder_name = $encoder_name;
}

+ Here is the caller graph for this function:

ilUserPasswordManager::verifyPassword ( ilObjUser  $user,
  $raw 
)
Parameters
ilObjUser$user
string$raw
Returns
bool

Definition at line 177 of file class.ilUserPasswordManager.php.

References getEncoderFactory(), getEncoderName(), ilObjUser\getPasswd(), ilObjUser\getPasswordEncodingType(), and ilObjUser\getPasswordSalt().

{
$encoder = $this->getEncoderFactory()->getEncoderByName($user->getPasswordEncodingType(), true);
if($this->getEncoderName() != $encoder->getName())
{
if($encoder->isPasswordValid($user->getPasswd(), $raw, $user->getPasswordSalt()))
{
$user->resetPassword($raw, $raw);
return true;
}
return false;
}
else
{
return $encoder->isPasswordValid($user->getPasswd(), $raw, $user->getPasswordSalt());
}
}

+ Here is the call graph for this function:

Field Documentation

ilUserPasswordManager::$config = array()
protected

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

Referenced by __construct().

ilUserPasswordManager::$encoder_factory
protected

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

Referenced by getEncoderFactory(), and setEncoderFactory().

ilUserPasswordManager::$encoder_name
protected

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

Referenced by getEncoderName(), and setEncoderName().

ilUserPasswordManager::$instance
staticprivate

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

const ilUserPasswordManager::MIN_SALT_SIZE = 16

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


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