Class Argon2PasswordEncoder
java.lang.Object
org.ametys.plugins.core.impl.hash.Argon2PasswordEncoder
Password encoder using Argon2 hashing algorithm.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionencode
(CharSequence rawPassword) Encode the raw password with argon2id hash algorithm.static byte[]
Get a pepper for a given id and generate it if it does not already existsboolean
matches
(CharSequence rawPassword, String encodedPassword) Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded.
-
Field Details
-
ROLE
Avalon Role
-
-
Constructor Details
-
Argon2PasswordEncoder
Constructor for Argon2PasswordEncoder- Parameters:
pepper
- the pepper used by the Argon2PasswordEncoder
-
-
Method Details
-
getOrCreatePepper
Get a pepper for a given id and generate it if it does not already exists- Parameters:
id
- the id of the pepper- Returns:
- the value of the paper
- Throws:
IOException
- if I/O error occurred.
-
encode
Encode the raw password with argon2id hash algorithm.- Parameters:
rawPassword
- the raw password- Returns:
- the hash
-
matches
Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded. Returns true if the passwords match, false if they do not. The stored password itself is never decoded.- Parameters:
rawPassword
- the raw password to encode and matchencodedPassword
- the encoded password from storage to compare with- Returns:
- true if the raw password, after encoding, matches the encoded password from storage
-