102 if ( !isset( $config[
'type'] ) ) {
103 throw new MWException(
'Password configuration must contain a type name.' );
105 $this->config = $config;
106 $this->factory = $factory;
108 if (
$hash !==
null && strlen(
$hash ) >= 3 ) {
123 return $this->config[
'type'];
154 if ( !$other instanceof
self ) {
158 $obj->crypt( $other );
162 return hash_equals( $this->
toString(), $other->toString() );
178 $result =
':' . $this->config[
'type'] .
':' . $this->hash;
194 if ( strlen(
$hash ) > self::MAX_HASH_SIZE ) {
208 abstract public function crypt( $password );
Show an error when any operation involving passwords fails to run.
Factory class for creating and checking Password objects.
Represents a password hash for use in authentication.
getType()
Get the type name of the password.
parseHash( $hash)
Perform any parsing necessary on the hash to see if the hash is valid and/or to perform logic for see...
crypt( $password)
Hash a password and store the result in this object.
const MAX_HASH_SIZE
Hash must fit in user_password, which is a tinyblob.
needsUpdate()
Determine if the hash needs to be updated.
__construct(PasswordFactory $factory, array $config, $hash=null)
Construct the Password object using a string hash.
assertIsSafeSize( $hash)
Assert that hash will fit in a tinyblob field.
string $hash
String representation of the hash without the type.
equals( $other)
Compare one Password object to this object.
toString()
Convert this hash to a string that can be stored in the database.
array $config
Array of configuration variables injected from the constructor.
PasswordFactory $factory
Factory that created the object.
namespace being checked & $result