Class CryptoService
- java.lang.Object
-
- org.forgerock.selfservice.core.crypto.CryptoService
-
public class CryptoService extends Object
Cryptography Service for the user self service project.- Since:
- 0.2.0
-
-
Constructor Summary
Constructors Constructor Description CryptoService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonValue
hash(String plainTextValue, String algorithm)
Hashes a string value.JsonValue
hash(String plainTextValue, String algorithm, JsonValue config)
Hashes a string value.boolean
isHashed(JsonValue value)
Detects if a String is hashed.boolean
matches(String plainTextValue, JsonValue value)
Returns true if the supplied plain text value of a field matches the supplied hashed value.
-
-
-
Method Detail
-
hash
public JsonValue hash(String plainTextValue, String algorithm) 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.- 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
public boolean isHashed(JsonValue value)
Detects if a String is hashed.- Parameters:
value
- the JSON value to check.- Returns:
- true if hashed, false otherwise.
-
matches
public boolean matches(String plainTextValue, JsonValue value) throws JsonCryptoException
Returns true if the supplied plain text value of a field matches the supplied hashed value.- Parameters:
plainTextValue
- aString
representing the plain text value of a fieldvalue
- aJsonValue
representing 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
-
-