Package com.axelor.auth
Class AuthService
java.lang.Object
com.axelor.auth.AuthService
The
AuthService class provides various utility services including password encryption,
password match and saving user password in encrypted form.
The AuthService should not be manually instantiated but either injected or user getInstance() method to get the instance of the service.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchangePassword(User user, String password) Changes user password.Encrypt the password of the given user.This is an adapter method to be used with data import.Encrypt the given password text if it's not encrypted yet.static AuthServiceGet the instance of theAuthService.Returns the translated descriptions of all currently enabled password policies, in evaluation order.booleanMatch the given plain and saved passwords.validatePasswordPolicies(User user, String password) Validates the given password against the configured password policies for the specified user.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
AuthService
public AuthService()
-
-
Method Details
-
getInstance
Get the instance of theAuthService.- Returns:
- the
AuthServiceinstance - Throws:
IllegalStateException- if AuthService is not initialized
-
encrypt
Encrypt the given password text if it's not encrypted yet.The method tests the password for a special format to check if it is already encrypted, and In that case the password is returned as it is to avoid multiple encryption.
- Parameters:
password- the password to encrypt- Returns:
- encrypted password
-
encrypt
Encrypt the password of the given user.- Parameters:
user- the user whose password needs to be encrypted- Returns:
- the same user instance
-
encrypt
This is an adapter method to be used with data import.This method can be used as
call="com.axelor.auth.AuthService:encrypt"while importing user data to ensure user passwords are encrypted.- Parameters:
user- the object instance passed by data import enginecontext- the data import context- Returns:
- the same instance passed
-
match
Match the given plain and saved passwords.- Parameters:
plain- the plain password textsaved- the saved password text (hashed)- Returns:
- true if they match
-
changePassword
Changes user password.- Parameters:
user- the user whose password needs to be changedpassword- the new plain-text password- Throws:
ChangePasswordException- if unable to validate password policies
-
validatePasswordPolicies
Validates the given password against the configured password policies for the specified user.- Parameters:
user- the user for whom the password policies need to be validatedpassword- the password to validate against the policies- Returns:
InvalidPolicyif any policy is violated, null otherwise
-
getPasswordPolicyDescriptions
Returns the translated descriptions of all currently enabled password policies, in evaluation order. Intended for display as requirements guidance on the login or change-password page.- Returns:
- an ordered list of translated policy requirement strings
-