Package com.axelor.auth.password
Interface PasswordPolicy
- All Known Subinterfaces:
DigitsPasswordPolicy,LengthPasswordPolicy,LowerCasePasswordPolicy,NotCodePasswordPolicy,NotSamePasswordPolicy,PatternPasswordPolicy,ScorePasswordPolicy,SpecialCharsPasswordPolicy,UpperCasePasswordPolicy
- All Known Implementing Classes:
DefaultDigitsPasswordPolicy,DefaultLengthPasswordPolicy,DefaultLowerCasePasswordPolicy,DefaultNotCodePasswordPolicy,DefaultNotSamePasswordPolicy,DefaultPatternPasswordPolicy,DefaultScorePasswordPolicy,DefaultSpecialCharsPasswordPolicy,DefaultUpperCasePasswordPolicy
public interface PasswordPolicy
Represents a single password policy rule.
Implementations should return an InvalidPolicy when the password violates the rule.
Multiple policies are aggregated by AuthPasswordManager.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a description of this policy's requirement, suitable for display on the login or change-password page as guidance before the user submits.Returns the unique identifier of this policy, used to look up its configuration.default booleanReturns whether this policy is enabled by default when no explicit configuration is found.default booleanReturns whether this policy is mandatory and cannot be disabled via configuration.Checks whether the given password satisfies this policy rule.
-
Method Details
-
getPolicyId
String getPolicyId()Returns the unique identifier of this policy, used to look up its configuration. The corresponding enabled setting isuser.password.<policyId>.enabled.- Returns:
- the policy identifier
-
isEnabledByDefault
default boolean isEnabledByDefault()Returns whether this policy is enabled by default when no explicit configuration is found. Policies that are opt-in should override this to returnfalse.- Returns:
trueif this policy is active by default
-
isMandatory
default boolean isMandatory()Returns whether this policy is mandatory and cannot be disabled via configuration. Mandatory policies are always enforced regardless of theuser.password.<id>.enabledsetting.- Returns:
trueif this policy cannot be disabled
-
validate
Checks whether the given password satisfies this policy rule.- Parameters:
user- the user for context-aware checks, ornullfor new userspassword- the plain-text password to check- Returns:
- an
InvalidPolicyif the password violates this rule
-
getDescription
Returns a description of this policy's requirement, suitable for display on the login or change-password page as guidance before the user submits. This is distinct from the error message returned on violation.Implementations may return
nullwhen the policy has no meaningful description (e.g. a pattern policy with no pattern configured).- Returns:
- a
PolicyDescription, ornullif not applicable
-