Wt
3.2.0
|
Validator for password strength. More...
Public Member Functions | |
virtual int | evaluateStrength (const WString &password, const WString &loginName, const std::string &email) const =0 |
Evaluates the strength of a password. | |
virtual bool | isValid (int result) const =0 |
Returns whether the password is considered strong enough. | |
virtual WString | message (int result) const =0 |
Returns a message describing a password strength. | |
virtual int | strength (int result) const |
Returns the password strength in a scale of 0 to 5. | |
virtual Result | validate (const WString &password, const WString &loginName, const std::string &email) const |
Validates a password. | |
virtual Result | validate (const WString &password) const |
Validates a password. |
Validator for password strength.
This class defines a specialized validator interface for evaluating password strength. The implementation allows to evaluate strength on a numeric scale (from 0 to 5) in addition to the normal validator functionality of validating a password.
The actual computation is done by validateStrength(), which returns an opaque number that is interpreted with isValid(), message() and strength() methods.
virtual int Wt::Auth::AbstractPasswordService::AbstractStrengthValidator::evaluateStrength | ( | const WString & | password, |
const WString & | loginName, | ||
const std::string & | |||
) | const [pure virtual] |
Evaluates the strength of a password.
The result is an opaque number which is interpreted by isValid(), message() and strength().
The validator may take into account the user's login name and email address, to exclude passwords that are too similar to these.
Implemented in Wt::Auth::PasswordStrengthValidator.
virtual bool Wt::Auth::AbstractPasswordService::AbstractStrengthValidator::isValid | ( | int | result | ) | const [pure virtual] |
Returns whether the password is considered strong enough.
This is used by validate() to return the validation state.
Implemented in Wt::Auth::PasswordStrengthValidator.
virtual WString Wt::Auth::AbstractPasswordService::AbstractStrengthValidator::message | ( | int | result | ) | const [pure virtual] |
Returns a message describing a password strength.
When the password is not strong enough, this should return a message which helps the user pick a stronger password.
Implemented in Wt::Auth::PasswordStrengthValidator.
int Wt::Auth::PasswordService::AbstractStrengthValidator::strength | ( | int | result | ) | const [virtual] |
Returns the password strength in a scale of 0 to 5.
The default implementation simply returns 5 for a valid, and 0 for an invalid password.
WValidator::Result Wt::Auth::PasswordService::AbstractStrengthValidator::validate | ( | const WString & | password, |
const WString & | loginName, | ||
const std::string & | |||
) | const [virtual] |
Validates a password.
This uses evaluateStrength(), isValid() and message() to return the result of password validation.
WValidator::Result Wt::Auth::PasswordService::AbstractStrengthValidator::validate | ( | const WString & | password | ) | const [virtual] |
Validates a password.
Calls validate(password, WString::Empty, "");
Reimplemented from Wt::WValidator.