Class PasswordHash
- java.lang.Object
-
- org.openbravo.authentication.hashing.PasswordHash
-
public class PasswordHash extends Object
Handles hashing passwords to be stored in database supporting differentHashingAlgorithm
s.- Since:
- 3.0PR20Q1
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
generateHash(String plainText)
Generates a hash for theplainText
using current defaultHashingAlgorithm
static Optional<User>
getUserWithPassword(String userName, String password)
static boolean
matches(String plainTextPassword, String hashedPassword)
Checks whether a plain text password matches with a hashed password
-
-
-
Method Detail
-
getUserWithPassword
public static Optional<User> getUserWithPassword(String userName, String password)
Checks if userName matches password, returning anOptional
User
in case it matches.Important Note: In case password matches with the current one for the user and it was hashed with a
HashingAlgorithm
with a version lower than current default, hash will be promoted to the default algorithm. In this case, user's password field will be updated and DAL current transaction will be flushed to DB.- Parameters:
userName
- user name to checkpassword
- user's password in plain text as provided by the user- Returns:
- an
Optional
describing theUser
matching the provideduserName
andpassword
pair; or an emptyOptional
if there is noUser
matching them
-
generateHash
public static String generateHash(String plainText)
Generates a hash for theplainText
using current defaultHashingAlgorithm
-
-