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

Password generator service. More...

Public Member Functions

 __construct (protected Config $config, protected Translator $translator, protected 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...
 

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 ( protected Config  $config,
protected Translator  $translator,
protected EventsService  $events 
)

Constructor.

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

Definition at line 31 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 224 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 64 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 45 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::getGenerator ( )
protected

Get helper generator.

Returns
RequirementPasswordGenerator

Definition at line 269 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 105 of file PasswordGeneratorService.php.

Elgg\Security\PasswordGeneratorService::getPasswordRequirementsDescription ( )

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

Returns
string

Definition at line 169 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 331 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 84 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 250 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 349 of file PasswordGeneratorService.php.


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