MediaWiki
1.30.0
|
Factory class for creating and checking Password objects. More...
Public Member Functions | |
getDefaultType () | |
Get the default password type. More... | |
getTypes () | |
Get the list of types of passwords. More... | |
init (Config $config) | |
Initialize the internal static variables using the global variables. More... | |
needsUpdate (Password $password) | |
Determine whether a password object needs updating. More... | |
newFromCiphertext ( $hash) | |
Create a new Hash object from an existing string hash. More... | |
newFromPlaintext ( $password, Password $existing=null) | |
Create a new Hash object from a plaintext password. More... | |
newFromType ( $type) | |
Make a new default password of the given type. More... | |
register ( $type, array $config) | |
Register a new type of password hash. More... | |
setDefaultType ( $type) | |
Set the default password type. More... | |
Static Public Member Functions | |
static | generateRandomPasswordString ( $minLength=10) |
Generate a random string suitable for a password. More... | |
static | newInvalidPassword () |
Create an InvalidPassword. More... | |
Private Attributes | |
string | $default = '' |
The default PasswordHash type. More... | |
array | $types |
Mapping of password types to classes. More... | |
Factory class for creating and checking Password objects.
Definition at line 28 of file PasswordFactory.php.
|
static |
Generate a random string suitable for a password.
int | $minLength | Minimum length of password to generate |
Definition at line 198 of file PasswordFactory.php.
References MWCryptRand\generateHex().
Referenced by ResetUserEmail\execute(), BotPassword\generatePassword(), MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newRandom(), User\randomPassword(), and PasswordFactoryTest\testGenerateRandomPasswordString().
PasswordFactory::getDefaultType | ( | ) |
Get the default password type.
Definition at line 76 of file PasswordFactory.php.
References $default.
PasswordFactory::getTypes | ( | ) |
Get the list of types of passwords.
Definition at line 98 of file PasswordFactory.php.
References $types.
PasswordFactory::init | ( | Config | $config | ) |
Initialize the internal static variables using the global variables.
Config | $config | Configuration object to load data from |
Definition at line 85 of file PasswordFactory.php.
References $options, $type, as, Config\get(), and setDefaultType().
Referenced by PasswordFactoryTest\testInit().
PasswordFactory::needsUpdate | ( | Password | $password | ) |
Determine whether a password object needs updating.
Check whether the given password is of the default type. If it is, pass off further needsUpdate checks to Password::needsUpdate.
Password | $password |
Definition at line 184 of file PasswordFactory.php.
References $default, Password\getType(), and Password\needsUpdate().
PasswordFactory::newFromCiphertext | ( | $hash | ) |
Create a new Hash object from an existing string hash.
Parse the type of a hash and create a new hash object based on the parsed type. Pass the raw hash to the constructor of the new object. Use InvalidPassword type if a null hash is given.
string | null | $hash | Existing hash or null for an invalid password |
PasswordError | If hash is invalid or type is not recognized |
Definition at line 113 of file PasswordFactory.php.
References $type.
PasswordFactory::newFromPlaintext | ( | $password, | |
Password | $existing = null |
||
) |
Create a new Hash object from a plaintext password.
If no existing object is given, make a new default object. If one is given, clone that object. Then pass the plaintext to Password::crypt().
string | null | $password | Plaintext password, or null for an invalid password |
Password | null | $existing | Optional existing hash to get options from |
Definition at line 157 of file PasswordFactory.php.
References $default.
PasswordFactory::newFromType | ( | $type | ) |
Make a new default password of the given type.
string | $type | Existing type |
PasswordError | If hash is invalid or type is not recognized |
Definition at line 137 of file PasswordFactory.php.
References $type.
|
static |
Create an InvalidPassword.
Definition at line 214 of file PasswordFactory.php.
Referenced by User\addToDatabase(), User\createNew(), BotPassword\getPassword(), BotPassword\invalidateAllPasswordsForCentralId(), BotPassword\save(), PasswordFactoryTest\testNewInvalidPassword(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testTestUserCanAuthenticate(), and MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testTestUserCanAuthenticate().
PasswordFactory::register | ( | $type, | |
array | $config | ||
) |
Register a new type of password hash.
string | $type | Unique type name for the hash |
array | $config | Array of configuration options |
Definition at line 53 of file PasswordFactory.php.
References $type.
Referenced by PasswordFactoryTest\testNeedsUpdate(), PasswordFactoryTest\testNewFromCiphertext(), PasswordFactoryTest\testNewFromCiphertextErrors(), PasswordFactoryTest\testNewFromPlaintext(), PasswordFactoryTest\testNewFromType(), PasswordFactoryTest\testNewFromTypeError(), PasswordFactoryTest\testRegister(), and PasswordFactoryTest\testSetDefaultType().
PasswordFactory::setDefaultType | ( | $type | ) |
Set the default password type.
InvalidArgumentException | If the type is not registered |
string | $type | Password hash type |
Definition at line 64 of file PasswordFactory.php.
References $type.
Referenced by init(), and PasswordFactoryTest\testSetDefaultTypeError().
|
private |
The default PasswordHash type.
Definition at line 35 of file PasswordFactory.php.
Referenced by getDefaultType(), needsUpdate(), and newFromPlaintext().
|
private |
Mapping of password types to classes.
Definition at line 43 of file PasswordFactory.php.
Referenced by getTypes().