Class CryptoService
java.lang.Object
org.forgerock.selfservice.core.crypto.CryptoService
Cryptography Service for the user self service project.
- Since:
- 0.2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionHashes a string value.Hashes a string value.booleanDetects if a String is hashed.booleanReturns true if the supplied plain text value of a field matches the supplied hashed value.
-
Constructor Details
-
CryptoService
public CryptoService()
-
-
Method Details
-
hash
Hashes a string value. Generates a new salt value.- Parameters:
plainTextValue- the string value to be hashed.algorithm- the hashing algorithm to use.- Returns:
- a copy of the value, hashed with the specified algorithm and salt.
- Throws:
JsonCryptoException- if an exception occurred while hashing
-
hash
public JsonValue hash(String plainTextValue, String algorithm, JsonValue config) throws JsonCryptoException Hashes a string value. Generates a new salt value.- Parameters:
plainTextValue- the string value to be hashed.algorithm- the hashing algorithm to use.config- additional configuration data for the algorithm- Returns:
- a copy of the value, hashed with the specified algorithm and salt.
- Throws:
JsonCryptoException- if an exception occurred while hashing
-
isHashed
Detects if a String is hashed.- Parameters:
value- the JSON value to check.- Returns:
- true if hashed, false otherwise.
-
matches
Returns true if the supplied plain text value of a field matches the supplied hashed value.- Parameters:
plainTextValue- aStringrepresenting the plain text value of a fieldvalue- aJsonValuerepresenting the hashed and encoded value of a field- Returns:
- true if the fields values match, false otherwise.
- Throws:
JsonCryptoException- if an exception occurred while matching
-