BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
PasswordFactory Class Reference

Public Member Functions

 register ($type, array $config)
 
 setDefaultType ($type)
 
 getDefaultType ()
 
 init (Config $config)
 
 getTypes ()
 
 newFromCiphertext ($hash)
 
 newFromType ($type)
 
 newFromPlaintext ($password, Password $existing=null)
 
 needsUpdate (Password $password)
 

Static Public Member Functions

static generateRandomPasswordString ($minLength=10)
 
static newInvalidPassword ()
 

Detailed Description

Factory class for creating and checking Password objects

Since
1.24

Member Function Documentation

static PasswordFactory::generateRandomPasswordString (   $minLength = 10)
static

Generate a random string suitable for a password

Parameters
int$minLengthMinimum length of password to generate
Returns
string
PasswordFactory::getDefaultType ( )

Get the default password type

Returns
string
PasswordFactory::getTypes ( )

Get the list of types of passwords

Returns
array
PasswordFactory::init ( Config  $config)

Initialize the internal static variables using the global variables

Parameters
Config$configConfiguration object to load data from
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.

Parameters
Password$password
Returns
bool True if needs update, false otherwise
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.

Parameters
string | null$hashExisting hash or null for an invalid password
Returns
Password
Exceptions
PasswordErrorIf hash is invalid or type is not recognized
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().

Parameters
string | null$passwordPlaintext password, or null for an invalid password
Password | null$existingOptional existing hash to get options from
Returns
Password
PasswordFactory::newFromType (   $type)

Make a new default password of the given type.

Parameters
string$typeExisting type
Returns
Password
Exceptions
PasswordErrorIf hash is invalid or type is not recognized
static PasswordFactory::newInvalidPassword ( )
static

Create an InvalidPassword

Returns
InvalidPassword
PasswordFactory::register (   $type,
array  $config 
)

Register a new type of password hash

Parameters
string$typeUnique type name for the hash
array$configArray of configuration options
PasswordFactory::setDefaultType (   $type)

Set the default password type

Exceptions
InvalidArgumentExceptionIf the type is not registered
Parameters
string$typePassword hash type

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