Class Answers
java.lang.Object
org.forgerock.selfservice.core.util.Answers
Utility methods for hashing and normalising answers to KBA questions.
- Since:
- 0.9.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonValuehashAnswer(CryptoService cryptoService, JsonValue answer) Hashes the given answer.static JsonValuehashAnswer(CryptoService cryptoService, JsonValue cryptoConfig, JsonValue answer) Hashes the given answer.static StringnormaliseAnswer(String answer) Normalises the given answer.
-
Method Details
-
hashAnswer
public static JsonValue hashAnswer(CryptoService cryptoService, JsonValue answer) throws InternalServerErrorException Hashes the given answer. If already hashed, it is returned unchanged. ThrowsInternalServerErrorExceptionif the provided answer is not a String or cannot be hashed.- Parameters:
cryptoService- an instance of theCryptoServiceto perform the hashinganswer- the value to be hashed.- Returns:
- the hashed string value.
- Throws:
InternalServerErrorException- if the provided answer is not a String or cannot be hashed
-
hashAnswer
public static JsonValue hashAnswer(CryptoService cryptoService, JsonValue cryptoConfig, JsonValue answer) throws InternalServerErrorException Hashes the given answer. If already hashed, it is returned unchanged. ThrowsInternalServerErrorExceptionif the provided answer is not a String or cannot be hashed.- Parameters:
cryptoService- an instance of theCryptoServiceto perform the hashingcryptoConfig- configuration for the hash algorithmanswer- the value to be hashed.- Returns:
- the hashed string value.
- Throws:
InternalServerErrorException- if the provided answer is not a String or cannot be hashed
-
normaliseAnswer
Normalises the given answer.- Parameters:
answer- the string value to be normalised.- Returns:
- normalised string value.
-