PHP Class Horde_Auth, horde

Author: Chuck Hagenbuch ([email protected])
Author: Michael Slusarz ([email protected])
Exibir arquivo Open project: horde/horde Class Usage Examples

Public Methods

Method Description
checkPasswordPolicy ( string $password, array $policy ) Checks whether a password matches some expected policy.
checkPasswordSimilarity ( string $password, array $dict, float $max = 80 ) Checks whether a password is too similar to a dictionary of strings.
factory ( string $driver, array $params = null ) : Horde_Auth_Base Attempts to return a concrete Horde_Auth_Base instance based on $driver.
genRandomPassword ( ) : string Generates a random, hopefully pronounceable, password. This can be used when resetting automatically a user's password.
getCryptedPassword ( string $plaintext, string $salt = '', string $encryption = 'md5-hex', boolean $show_encrypt = false ) : string Formats a password using the current encryption.
getSalt ( string $encryption = 'md5-hex', string $seed = '', string $plaintext = '' ) : string Returns a salt for the appropriate kind of password encryption.

Protected Methods

Method Description
_toAPRMD5 ( string $value, integer $count ) : string Converts to allowed 64 characters for APRMD5 passwords.

Method Details

_toAPRMD5() protected static method

Converts to allowed 64 characters for APRMD5 passwords.
protected static _toAPRMD5 ( string $value, integer $count ) : string
$value string The value to convert
$count integer The number of iterations
return string $value converted to the 64 MD5 characters.

checkPasswordPolicy() public static method

Checks whether a password matches some expected policy.
public static checkPasswordPolicy ( string $password, array $policy )
$password string A password.
$policy array A configuration with policy rules. Supported rules: - minLength: Minimum length of the password - maxLength: Maximum length of the password - maxSpace: Maximum number of white space characters The following are the types of characters required in a password. Either specific characters, character classes, or both can be required. Specific types are: - minUpper: Minimum number of uppercase characters - minLower: Minimum number of lowercase characters - minNumeric: Minimum number of numeric characters (0-9) - minAlphaNum: Minimum number of alphanumeric characters - minAlpha: Minimum number of alphabetic characters - minSymbol: Minimum number of punctuation / symbol characters - minNonAlpha: Minimum number of non-alphabetic characters Alternatively (or in addition to), the minimum number of character classes can be configured by setting the following. The valid range is 0 through 4 character classes may be required for a password. The classes are: 'upper', 'lower', 'number', and 'symbol'. For example: A password of 'p@ssw0rd' satisfies three classes ('number', 'lower', and 'symbol'), while 'passw0rd' only satisfies two classes ('lower' and 'number'). - minClasses: Minimum number (0 through 4) of character classes.

checkPasswordSimilarity() public static method

Checks whether a password is too similar to a dictionary of strings.
public static checkPasswordSimilarity ( string $password, array $dict, float $max = 80 )
$password string A password.
$dict array A dictionary to check for similarity, for example the user name or an old password.
$max float The maximum allowed similarity in percent.

factory() public static method

Attempts to return a concrete Horde_Auth_Base instance based on $driver.
Deprecation:
public static factory ( string $driver, array $params = null ) : Horde_Auth_Base
$driver string Either a driver name, or the full class name to use (class must extend Horde_Auth_Base).
$params array A hash containing any additional configuration or parameters a subclass might need.
return Horde_Auth_Base The newly created concrete instance.

genRandomPassword() public static method

Generates a random, hopefully pronounceable, password. This can be used when resetting automatically a user's password.
public static genRandomPassword ( ) : string
return string A random password

getCryptedPassword() public static method

Formats a password using the current encryption.
public static getCryptedPassword ( string $plaintext, string $salt = '', string $encryption = 'md5-hex', boolean $show_encrypt = false ) : string
$plaintext string The plaintext password to encrypt.
$salt string The salt to use to encrypt the password. If not present, a new salt will be generated.
$encryption string The kind of pasword encryption to use. Defaults to md5-hex.
$show_encrypt boolean Some password systems prepend the kind of encryption to the crypted password ({SHA}, etc). Defaults to false.
return string The encrypted password.

getSalt() public static method

Optionally takes a seed and a plaintext password, to extract the seed of an existing password, or for encryption types that use the plaintext in the generation of the salt.
public static getSalt ( string $encryption = 'md5-hex', string $seed = '', string $plaintext = '' ) : string
$encryption string The kind of pasword encryption to use. Defaults to md5-hex.
$seed string The seed to get the salt from (probably a previously generated password). Defaults to generating a new seed.
$plaintext string The plaintext password that we're generating a salt for. Defaults to none.
return string The generated or extracted salt.