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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
changePassword
(User user, String password) Changes user password.void
checkPassword
(ActionRequest request, ActionResponse response) Helper action to check 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 AuthService
Get the instance of theAuthService
.Gets configured user password pattern.Gets configured user password pattern description.boolean
Match the given plain and saved passwords.boolean
passwordMatchesPattern
(String password) Checks whether the password matches the configured pattern.
-
Constructor Details
-
AuthService
public AuthService()
-
-
Method Details
-
getInstance
Get the instance of theAuthService
.- Returns:
- the
AuthService
instance - 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
-
checkPassword
Helper action to check user password.- Parameters:
request
- the request with username and password as context or dataresponse
- the response, with user details if password matched
-
changePassword
Changes user password.- Parameters:
user
-password
-
-
passwordMatchesPattern
Checks whether the password matches the configured pattern.- Parameters:
password
-- Returns:
-
getPasswordPattern
Gets configured user password pattern.- Returns:
-
getPasswordPatternTitle
Gets configured user password pattern description.- Returns:
-