Elgg  Version 5.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Elgg\Security\PasswordGeneratorService Class Reference

Password generator service. More...

Public Member Functions

 __construct (Config $config, Translator $translator, EventsService $events)
 Constructor. More...
 
 generatePassword (int $length=12)
 Generate a new random password. More...
 
 assertValidPassword (string $password)
 Assert that a given string matches the password requirements. More...
 
 isValidPassword (string $password)
 Validate that a given string matches the password requirements. More...
 
 getInputRegEx ()
 Get the regex to set on an input/password to validate password requirements during input. More...
 
 getPasswordRequirementsDescription ()
 Get a description of how a valid password should be made. More...
 
 addInputRequirements (\Elgg\Event $event)
 Add the security password requirements to an input/password field. More...
 
 registerUserPasswordValidation (\Elgg\Event $event)
 Validate password during user registration. More...
 

Protected Member Functions

 getGenerator ()
 Get helper generator. More...
 
 getValidLength (int $length)
 Make sure the password length requirement can be met by the password settings. More...
 
 validatePasswordLength (string $password)
 Validate that a password meets the minimal length requirement. More...
 

Protected Attributes

 $config
 
 $translator
 
 $events
 

Detailed Description

Password generator service.

Can generate and validate passwords based on config settings regarding password requirements

Since
3.2

Definition at line 22 of file PasswordGeneratorService.php.

Constructor & Destructor Documentation

Elgg\Security\PasswordGeneratorService::__construct ( Config  $config,
Translator  $translator,
EventsService  $events 
)

Constructor.

Parameters
Config$configElgg config
Translator$translatorTranslator
EventsService$eventsEvents service

Definition at line 46 of file PasswordGeneratorService.php.

Member Function Documentation

Elgg\Security\PasswordGeneratorService::addInputRequirements ( \Elgg\Event  $event)

Add the security password requirements to an input/password field.

Parameters
\Elgg\Event$event'view_vars', 'input/password'
Returns
void|array

Definition at line 238 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::assertValidPassword ( string  $password)

Assert that a given string matches the password requirements.

Parameters
string$passwordthe password to validate
Returns
void
Exceptions
InvalidPasswordLengthException
InvalidPasswordCharacterRequirementsException

Definition at line 78 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::generatePassword ( int  $length = 12)

Generate a new random password.

Parameters
int$lengththe length of the password (can't be less the minimal password length config setting)
Returns
string

Definition at line 59 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::getGenerator ( )
protected

Get helper generator.

Returns
RequirementPasswordGenerator

Definition at line 283 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::getInputRegEx ( )

Get the regex to set on an input/password to validate password requirements during input.

Note: This regex is meant for use in html/javascript NOT PHP

Returns
string

Definition at line 119 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::getPasswordRequirementsDescription ( )

Get a description of how a valid password should be made.

Returns
string

Definition at line 183 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::getValidLength ( int  $length)
protected

Make sure the password length requirement can be met by the password settings.

Parameters
int$lengththe requested length
Returns
int

Definition at line 345 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::isValidPassword ( string  $password)

Validate that a given string matches the password requirements.

Parameters
string$passwordthe password to validate
Returns
bool

Definition at line 98 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::registerUserPasswordValidation ( \Elgg\Event  $event)

Validate password during user registration.

Parameters
\Elgg\Event$event'registeruser:validate:password', 'all'
Returns
void
Exceptions
RegistrationException

Definition at line 264 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::validatePasswordLength ( string  $password)
protected

Validate that a password meets the minimal length requirement.

Parameters
string$passwordthe password to check
Returns
bool

Definition at line 363 of file PasswordGeneratorService.php.

Member Data Documentation

Elgg\Security\PasswordGeneratorService::$config
protected

Definition at line 27 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::$events
protected

Definition at line 37 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::$translator
protected

Definition at line 32 of file PasswordGeneratorService.php.


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