@Singleton public class AuthService extends Object
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.
Modifier and Type | Field and Description |
---|---|
static AuthService |
instance |
Constructor and Description |
---|
AuthService(String hashAlgorihm,
int hashIterations) |
Modifier and Type | Method and Description |
---|---|
Object |
encrypt(Object user,
Map context)
This is an adapter method to be used with data import.
|
String |
encrypt(String password)
Encrypt the given password text if it's not encrypted yet.
|
User |
encrypt(User user)
Encrypt the password of the given user.
|
static AuthService |
getInstance()
Get the instance of the
AuthService . |
boolean |
match(String plain,
String saved)
Match the given plain and saved passwords.
|
void |
validate(ActionRequest request,
ActionResponse response)
A helper method used to encrypt user password when the user record is
saved with user interface.
|
public static AuthService instance
public static AuthService getInstance()
AuthService
.AuthService
instanceIllegalStateException
- if AuthService is not initializedpublic String encrypt(String password)
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.
password
- the password to encryptpublic User encrypt(User user)
user
- the user whose password needs to be encryptedpublic Object encrypt(Object user, Map context)
This method can be used as
call="com.axelor.auth.AuthService:encrypt"
while importing
user data to ensure user passwords are encrypted.
user
- the object instance passed by data import enginecontext
- the data import contextpublic boolean match(String plain, String saved)
plain
- the plain password textsaved
- the saved password text (hashed)public void validate(ActionRequest request, ActionResponse response)
request
- the request with user object as contextresponse
- the response, which is updated according to the validation