PHP Class YiiPassword\Strategy

Inheritance: extends CValidator
显示文件 Open project: phpnode/yiipassword

Public Properties

Property Type Description
$daysValid integer | boolean Defaults to false, meaning passwords do not expire
$maxLength integer | boolean There is no good reason to set this value unless you're using it for legacy authentication Defaults to false meaning no maximum password length.
$minDigits integer Defaults to 0 meaning no minimum.
$minLength integer The minimum password length
$minLowerCaseLetters integer Defaults to 0 meaning no minimum.
$minSpecialCharacters integer Defaults to 0 meaning no minimum.
$minUpperCaseLetters integer Defaults to 0 meaning no minimum.
$name string The name of this password strategy
$specialCharacters array The special characters that should appear in passwords if $minSpecialCharacters is set

Public Methods

Method Description
canUpgradeTo ( Strategy $strategy ) : boolean Checks whether this strategy can be upgraded to another given strategy.
compare ( string $password, string $encoded ) : boolean Compare a plain text password to the given encoded password
encode ( string $password ) : string Encode a plain text password.
getSalt ( boolean $forceRefresh = false ) : string Gets the salt to use with this strategy, if supported.
getUsername ( ) : string Gets the username to use with this strategt
setSalt ( string $salt ) Sets the salt to use with this strategy, if supported
setUsername ( string $username ) Sets the username to use with this strategy

Protected Methods

Method Description
generateSalt ( ) : string | boolean Generates a random salt.
validateAttribute ( CModel $object, string $attribute ) : boolean Validates a new password to ensure that it meets the minimum complexity requirements

Method Details

canUpgradeTo() public method

If this strategy's complexity requirements are equal or greater than that of the given strategy, then it can be upgraded. Otherwise the user must be prompted to enter a new password that meets the complexity requirements.
public canUpgradeTo ( Strategy $strategy ) : boolean
$strategy Strategy the strategy to upgrade to
return boolean true if this strategy can be upgraded to the given strategy

compare() public method

Compare a plain text password to the given encoded password
public compare ( string $password, string $encoded ) : boolean
$password string the plain text password to compare
$encoded string the encoded password to compare to
return boolean true if the passwords are equal, otherwise false

encode() abstract public method

Child classes should implement this method and do their encoding here
abstract public encode ( string $password ) : string
$password string the plain text password to encode
return string the encoded password

generateSalt() protected method

Generates a random salt.
protected generateSalt ( ) : string | boolean
return string | boolean the generated salt, or false if not supported by this strategy

getSalt() public method

Gets the salt to use with this strategy, if supported.
public getSalt ( boolean $forceRefresh = false ) : string
$forceRefresh boolean whether to force generate a new salt
return string the generated salt

getUsername() public method

Gets the username to use with this strategt
public getUsername ( ) : string
return string the username

setSalt() public method

Sets the salt to use with this strategy, if supported
public setSalt ( string $salt )
$salt string the salt

setUsername() public method

Sets the username to use with this strategy
public setUsername ( string $username )
$username string the username

validateAttribute() protected method

Validates a new password to ensure that it meets the minimum complexity requirements
protected validateAttribute ( CModel $object, string $attribute ) : boolean
$object CModel the data object being validated
$attribute string the name of the attribute to be validated.
return boolean true if validation succeeded

Property Details

$daysValid public_oe property

Defaults to false, meaning passwords do not expire
public int|bool $daysValid
return integer | boolean

$maxLength public_oe property

There is no good reason to set this value unless you're using it for legacy authentication Defaults to false meaning no maximum password length.
public int|bool $maxLength
return integer | boolean

$minDigits public_oe property

Defaults to 0 meaning no minimum.
public int $minDigits
return integer

$minLength public_oe property

The minimum password length
public int $minLength
return integer

$minLowerCaseLetters public_oe property

Defaults to 0 meaning no minimum.
public int $minLowerCaseLetters
return integer

$minSpecialCharacters public_oe property

Defaults to 0 meaning no minimum.
public int $minSpecialCharacters
return integer

$minUpperCaseLetters public_oe property

Defaults to 0 meaning no minimum.
public int $minUpperCaseLetters
return integer

$name public_oe property

The name of this password strategy
public string $name
return string

$specialCharacters public_oe property

The special characters that should appear in passwords if $minSpecialCharacters is set
public array $specialCharacters
return array